2014-10-27 11:01:37 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
class Admin::RegisteredSitesController < OrbitAdminController
|
2014-12-02 12:21:20 +00:00
|
|
|
before_action ->(module_app = @app_title) { set_variables module_app }
|
2014-10-27 11:01:37 +00:00
|
|
|
def index
|
2014-12-02 12:21:20 +00:00
|
|
|
@registeredsites = RegisteredSite.all.order_by(sort)
|
|
|
|
.with_categories(filters("category"))
|
|
|
|
.with_tags(filters("tag"))
|
2014-10-27 11:01:37 +00:00
|
|
|
@table_fields = table_fields
|
2014-12-02 12:21:20 +00:00
|
|
|
@tags = @module_app.tags
|
|
|
|
@categories = @module_app.categories.enabled
|
|
|
|
@filter_fields = filter_fields_without_status(@categories, @tags)
|
|
|
|
@registeredsites = search_data(@registeredsites,[:title]).page(params[:page]).per(10)
|
2014-10-27 11:01:37 +00:00
|
|
|
|
|
|
|
if request.xhr?
|
|
|
|
render :partial => "index"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-12-02 12:21:20 +00:00
|
|
|
def edit
|
|
|
|
@registered_site = RegisteredSite.find(params[:id])
|
|
|
|
if can_edit_or_delete?(@registered_site)
|
|
|
|
else
|
|
|
|
render_401
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
uid = params[:id].split('-').last
|
|
|
|
registered_site = RegisteredSite.find_by(:uid => uid)
|
|
|
|
registered_site.update_attributes(registered_site_params)
|
|
|
|
registered_site.save
|
|
|
|
redirect_to params['referer_url']
|
|
|
|
end
|
|
|
|
|
2014-10-27 11:01:37 +00:00
|
|
|
def change_access_status
|
|
|
|
status = params[:status]
|
|
|
|
site = RegisteredSite.find_by(:uid => params[:uid])
|
|
|
|
case status
|
|
|
|
when "revoke"
|
|
|
|
site.access_granted = false
|
|
|
|
site.save
|
|
|
|
when "grant"
|
|
|
|
site.access_granted = true
|
|
|
|
site.save
|
|
|
|
end
|
|
|
|
@table_fields = table_fields
|
|
|
|
@registeredsites = RegisteredSite.all.page(params[:page]).per(10)
|
|
|
|
# render :partial => "index"
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def table_fields
|
2014-12-02 12:21:20 +00:00
|
|
|
[:domain, :admin_email, :status, :category, :tags, :permission]
|
|
|
|
end
|
|
|
|
|
|
|
|
def registered_site_params
|
|
|
|
params.require(:registered_site).permit!
|
2014-10-27 11:01:37 +00:00
|
|
|
end
|
|
|
|
end
|