diff --git a/app/controllers/admin/registered_sites_controller.rb b/app/controllers/admin/registered_sites_controller.rb index 769d1bb..16a0f31 100644 --- a/app/controllers/admin/registered_sites_controller.rb +++ b/app/controllers/admin/registered_sites_controller.rb @@ -1,16 +1,37 @@ # encoding: utf-8 class Admin::RegisteredSitesController < OrbitAdminController + before_action ->(module_app = @app_title) { set_variables module_app } def index - @registeredsites = RegisteredSite.all + @registeredsites = RegisteredSite.all.order_by(sort) + .with_categories(filters("category")) + .with_tags(filters("tag")) @table_fields = table_fields - @filter_fields = {} - @registeredsites = @registeredsites.page(params[:page]).per(10) + @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 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 + def change_access_status status = params[:status] site = RegisteredSite.find_by(:uid => params[:uid]) @@ -29,6 +50,10 @@ class Admin::RegisteredSitesController < OrbitAdminController private def table_fields - [:domain, :admin_email, :status, :permission] + [:domain, :admin_email, :status, :category, :tags, :permission] + end + + def registered_site_params + params.require(:registered_site).permit! end end \ No newline at end of file diff --git a/app/models/registered_site.rb b/app/models/registered_site.rb index a183bda..06a7ee9 100644 --- a/app/models/registered_site.rb +++ b/app/models/registered_site.rb @@ -1,9 +1,13 @@ class RegisteredSite include Mongoid::Document include Mongoid::Timestamps + include OrbitTag::Taggable + include OrbitCategory::Categorizable include Slug field :site_domain + field :title, as: :slug_title, localize: true + field :description, localize: true field :access_granted, type: Boolean, :default => false field :admin_email field :site_confirmed, type: Boolean, :default => false @@ -20,4 +24,8 @@ class RegisteredSite self.save end + def active? + return self.access_granted && self.site_confirmed + end + end \ No newline at end of file diff --git a/app/views/admin/registered_sites/_form.html.erb b/app/views/admin/registered_sites/_form.html.erb new file mode 100644 index 0000000..e508746 --- /dev/null +++ b/app/views/admin/registered_sites/_form.html.erb @@ -0,0 +1,123 @@ +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/fileupload" %> + <%= stylesheet_link_tag "lib/main-list" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/bootstrap-fileupload" %> + <%= javascript_include_tag "lib/bootstrap-datetimepicker" %> + <%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %> + <%= javascript_include_tag "lib/file-type" %> + <%= javascript_include_tag "lib/module-area" %> +<% end %> + + +