-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.rb
121 lines (70 loc) · 1.65 KB
/
helpers.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# Helpers
module Helpers
def login_box
if env['warden'].authenticated?
erb :logout_box
else
erb :login_form
end
end
def admin_links?
@admin_role = Role.get(1)
if env['warden'].authenticated? && admin?
erb :'/admin/admin_links'
end
end
def success?
if @user.saved? == true
flash[:success] = "#{@user.username} has been updated."
elsif @user.saved? == false
flash[:error] = "#{@user.username} failed to update."
else
flash[:error] = "Something went wrong."
end
end
def show_save?
if @show.saved?
flash[:success] = "#{@show.title} has been updated."
redirect "/admin/shows/edit/#{@show.id}"
elsif !@show.saved?
flash[:error] = "#{@show.title} could not be updated"
redirect "/admin/shows/new"
else
flash[:error] = "Something horrible went wrong."
redirect "/admin/shows/new"
end
end
def post_save?
if @post.saved?
flash[:success] = "#{@post.title} has been updated."
redirect "/admin/posts/edit/#{@post.id}"
elsif !@post.saved?
flash[:error] = "#{@post.title} could not be updated"
redirect "/admin/post/new"
else
flash[:error] = "Something horrible went wrong."
redirect "/admin/post/new"
end
end
def admin?
@admin_role = Role.get(1)
if env['warden'].user.roles.include?(@admin_role)
true
else
false
end
end
def dj?
if env['warden'].user.type == 'Dj'
true
else
false
end
end
def extra_info?
extra_info = false
if extra_info == true
erb :extra_info
end
end
end