2014-12-04 13:59:49 +00:00
|
|
|
class Admin::CustomizationLogsController < OrbitAdminController
|
|
|
|
before_action ->(module_app = @app_title) { set_variables module_app }
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super
|
|
|
|
@app_title = "registered_site"
|
|
|
|
end
|
|
|
|
|
|
|
|
def index
|
|
|
|
@registeredsites = RegisteredSite.all.order_by(sort)
|
|
|
|
.with_categories(filters("category"))
|
|
|
|
.with_tags(filters("tag"))
|
|
|
|
@table_fields = table_fields
|
|
|
|
@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)
|
|
|
|
if request.xhr?
|
|
|
|
render :partial => "index"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_log
|
|
|
|
@site = RegisteredSite.find(params[:id])
|
2014-12-05 10:08:10 +00:00
|
|
|
@logs = @site.site_logs.where(:archive.ne => true).desc(:created_at)
|
2014-12-04 13:59:49 +00:00
|
|
|
render :layout => false
|
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@log = SiteLog.new
|
|
|
|
@site = RegisteredSite.find(params[:id])
|
|
|
|
end
|
|
|
|
|
2014-12-05 10:08:10 +00:00
|
|
|
def archive
|
|
|
|
log = SiteLog.find(params[:id])
|
|
|
|
log.archive = true
|
|
|
|
log.save
|
|
|
|
render :json => {"success" => true}.to_json
|
|
|
|
end
|
|
|
|
|
2014-12-04 13:59:49 +00:00
|
|
|
def update
|
|
|
|
log = SiteLog.find(params[:id])
|
|
|
|
log.update_attributes(site_log_params)
|
|
|
|
log.save
|
|
|
|
redirect_to params['referer_url']
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@log = SiteLog.find(params[:id])
|
|
|
|
@site = @log.registered_site
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
log = SiteLog.new
|
|
|
|
log.update_attributes(site_log_params)
|
|
|
|
log.save
|
|
|
|
redirect_to params['referer_url']
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def table_fields
|
|
|
|
[:domain, :category, :tags, :actions]
|
|
|
|
end
|
|
|
|
|
|
|
|
def site_log_params
|
|
|
|
params.require(:site_log).permit!
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|