Page Menu
Home
GRNET
Search
Configure Global Search
Log In
Files
F905110
application_controller.rb
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Aug 29, 9:12 PM
Size
1 KB
Mime Type
text/x-ruby
Expires
Sun, Aug 31, 9:12 PM (9 h, 14 m)
Engine
blob
Format
Raw Data
Handle
252469
Attached To
rWEBDNS WebDNS (edet4)
application_controller.rb
View Options
class
ApplicationController
<
ActionController
::
Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery
with
:
:exception
attr_writer
:breadcrumb
helper_method
:admin?
helper_method
:dnssec?
def
admin?
return
false
if
params
.
key?
(
'user'
)
return
false
if
current_user
.
nil?
@admin_count
||=
begin
current_user
.
groups
.
where
(
name
:
WebDNS
.
settings
[
:admin_group
]
)
.
count
end
@admin_count
!=
0
end
def
admin_only!
return
if
admin?
redirect_to
root_path
,
alert
:
'Admin only area!'
end
def
dnssec?
WebDNS
.
settings
[
:dnssec
]
end
private
def
group
@group
||=
edit_group_scope
.
find
(
params
[
:group_id
]
||
params
[
:id
]
)
end
def
domain
@domain
||=
edit_domain_scope
.
find
(
params
[
:domain_id
]
||
params
[
:id
]
)
end
def
record
@record
||=
record_scope
.
find
(
params
[
:record_id
]
||
params
[
:id
]
)
end
def
show_group_scope
@show_group_scope
||=
current_user
.
groups
end
def
edit_group_scope
@edit_group_scope
||=
admin?
?
Group
.
all
:
show_group_scope
end
def
show_domain_scope
@show_domain_scope
||=
Domain
.
where
(
group
:
show_group_scope
)
end
def
edit_domain_scope
@edit_domain_scope
||=
admin?
?
Domain
.
all
:
Domain
.
where
(
group
:
show_group_scope
)
end
def
record_scope
@record_scope
||=
domain
.
records
end
def
notification
Notification
.
instance
end
end
Event Timeline
Log In to Comment