diff --git a/Gemfile b/Gemfile index 6c6e481..bd1f43b 100644 --- a/Gemfile +++ b/Gemfile @@ -34,7 +34,7 @@ # ------------------------------------------------ # SUPER ADMIN SECTION -gem "administrate", :github => 'thoughtbot/administrate', :branch =>'576976a12d' +gem "administrate", :github => 'thoughtbot/administrate', :branch =>'v0.4.0' # ------------------------------------------------ # USERS diff --git a/Gemfile.lock b/Gemfile.lock index 4bada0b..ca4b10f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,9 +1,9 @@ GIT remote: git://github.com/thoughtbot/administrate.git - revision: 576976a12d3725570576ec8e5a005d1647af999c - branch: 576976a12d + revision: 5ee0c2ffe4de99ebf639befd63831c1083dc535f + branch: v0.4.0 specs: - administrate (0.3.0) + administrate (0.4.0) autoprefixer-rails (~> 6.0) bourbon (~> 4.2) datetime_picker_rails (~> 0.0.7) diff --git a/app/controllers/admin/answers_controller.rb b/app/controllers/admin/answers_controller.rb index 398e2e3..c220635 100644 --- a/app/controllers/admin/answers_controller.rb +++ b/app/controllers/admin/answers_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = Answer.all.paginate(10, params[:page]) + # @resources = Answer. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # Answer.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/application_controller.rb b/app/controllers/admin/application_controller.rb index 5cc60df..0018efc 100644 --- a/app/controllers/admin/application_controller.rb +++ b/app/controllers/admin/application_controller.rb @@ -23,107 +23,3 @@ # end end end - - -class ApplicationController < ActionController::Base - protect_from_forgery with: :exception - - # Look for template overrides before rendering - before_filter :prepend_view_paths - - include GlobalHelpers - include Pundit - helper_method GlobalHelpers.instance_methods - - - rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized - - def user_not_authorized - redirect_to root_url, alert: I18n.t('unauthorized') - end - - before_filter :get_languages - before_filter :set_gettext_locale - - after_filter :store_location - - def get_languages - @languages = Language.sorted_by_abbreviation - end - - # Sets FastGettext locale for every request made - def set_gettext_locale - FastGettext.locale = session[:locale] || FastGettext.default_locale - end - - # PATCH /locale/:locale REST method - def set_locale_session - if FastGettext.default_available_locales.include?(params[:locale]) - session[:locale] = params[:locale] - end - redirect_to root_path - end - - def store_location - # store last url - this is needed for post-login redirect to whatever the user last visited. - if (request.fullpath != "/users/sign_in" && \ - request.fullpath != "/users/sign_up" && \ - request.fullpath != "/users/password" && \ - request.fullpath != "/users/sign_up?nosplash=true" && \ - !request.xhr?) # don't store ajax calls - session[:previous_url] = request.fullpath - end - end - - def after_sign_in_path_for(resource) - session[:previous_url] || root_path - end - - def after_sign_up_path_for(resource) - session[:previous_url] || root_path - end - - def after_sign_in_error_path_for(resource) - session[:previous_url] || root_path - end - - def after_sign_up_error_path_for(resource) - session[:previous_url] || root_path - end - - def authenticate_admin! - # currently if admin has any super-admin task, they can view the super-admin - redirect_to root_path unless user_signed_in? && (current_user.can_add_orgs? || current_user.can_change_org? || current_user.can_super_admin?) - end - - def get_plan_list_columns - if user_signed_in? - @selected_columns = current_user.settings(:plan_list).columns - - # handle settings saved and stored using an older version of the settings gem - if @selected_columns.kind_of? Hash - unless @selected_columns['elements'].nil? - @selected_columns = @selected_columns['elements'].collect{|k,v| puts "#{k} - #{v}"; k} - end - end - - # If the settings are missing or stored in the wrong format for some reason - # then use the defaults columns - @selected_columns = Settings::PlanList::DEFAULT_COLUMNS if @selected_columns.empty? - - @all_columns = Settings::PlanList::ALL_COLUMNS - end - end - - private - # Override rails default render action to look for a branded version of a - # template instead of using the default one. If no override exists, the - # default version in ./app/views/[:controller]/[:action] will be used - # - # The path in the app/views/branded/ directory must match the the file it is - # replacing. For example: - # app/views/branded/layouts/_header.html.erb -> app/views/layouts/_header.html.erb - def prepend_view_paths - prepend_view_path "app/views/branded" - end -end diff --git a/app/controllers/admin/exported_plans_controller.rb b/app/controllers/admin/exported_plans_controller.rb index 6ec1546..aecd7f0 100644 --- a/app/controllers/admin/exported_plans_controller.rb +++ b/app/controllers/admin/exported_plans_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = ExportedPlan.all.paginate(10, params[:page]) + # @resources = ExportedPlan. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # ExportedPlan.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/guidance_groups_controller.rb b/app/controllers/admin/guidance_groups_controller.rb index 7dec9b7..6b9ad4b 100644 --- a/app/controllers/admin/guidance_groups_controller.rb +++ b/app/controllers/admin/guidance_groups_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = GuidanceGroup.all.paginate(10, params[:page]) + # @resources = GuidanceGroup. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # GuidanceGroup.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/guidances_controller.rb b/app/controllers/admin/guidances_controller.rb index 6f2ccac..6690ff3 100644 --- a/app/controllers/admin/guidances_controller.rb +++ b/app/controllers/admin/guidances_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = Guidance.all.paginate(10, params[:page]) + # @resources = Guidance. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # Guidance.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/identifier_schemes_controller.rb b/app/controllers/admin/identifier_schemes_controller.rb index 2d923c1..43911d1 100644 --- a/app/controllers/admin/identifier_schemes_controller.rb +++ b/app/controllers/admin/identifier_schemes_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = IdentifierScheme.all.paginate(10, params[:page]) + # @resources = IdentifierScheme. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # IdentifierScheme.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/languages_controller.rb b/app/controllers/admin/languages_controller.rb index b8a32a2..e70e606 100644 --- a/app/controllers/admin/languages_controller.rb +++ b/app/controllers/admin/languages_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = Language.all.paginate(10, params[:page]) + # @resources = Language. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # Language.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/notes_controller.rb b/app/controllers/admin/notes_controller.rb index 3bd8dd0..c740124 100644 --- a/app/controllers/admin/notes_controller.rb +++ b/app/controllers/admin/notes_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = Note.all.paginate(10, params[:page]) + # @resources = Note. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # Note.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/orgs_controller.rb b/app/controllers/admin/orgs_controller.rb index e9f2860..91092db 100644 --- a/app/controllers/admin/orgs_controller.rb +++ b/app/controllers/admin/orgs_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = Org.all.paginate(10, params[:page]) + # @resources = Org. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # Org.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/perms_controller.rb b/app/controllers/admin/perms_controller.rb index 6764ca7..4e153cc 100644 --- a/app/controllers/admin/perms_controller.rb +++ b/app/controllers/admin/perms_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = Perm.all.paginate(10, params[:page]) + # @resources = Perm. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # Perm.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/phases_controller.rb b/app/controllers/admin/phases_controller.rb index de0724c..5877a50 100644 --- a/app/controllers/admin/phases_controller.rb +++ b/app/controllers/admin/phases_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = Phase.all.paginate(10, params[:page]) + # @resources = Phase. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # Phase.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/plan_guidance_groups_controller.rb b/app/controllers/admin/plan_guidance_groups_controller.rb index 4279dbf..0eeb458 100644 --- a/app/controllers/admin/plan_guidance_groups_controller.rb +++ b/app/controllers/admin/plan_guidance_groups_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = PlanGuidanceGroup.all.paginate(10, params[:page]) + # @resources = PlanGuidanceGroup. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # PlanGuidanceGroup.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/plans_controller.rb b/app/controllers/admin/plans_controller.rb index cb95550..aaa9189 100644 --- a/app/controllers/admin/plans_controller.rb +++ b/app/controllers/admin/plans_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = Plan.all.paginate(10, params[:page]) + # @resources = Plan. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # Plan.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/question_formats_controller.rb b/app/controllers/admin/question_formats_controller.rb index 115da2a..7644265 100644 --- a/app/controllers/admin/question_formats_controller.rb +++ b/app/controllers/admin/question_formats_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = QuestionFormat.all.paginate(10, params[:page]) + # @resources = QuestionFormat. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # QuestionFormat.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/question_options_controller.rb b/app/controllers/admin/question_options_controller.rb index b933695..237df25 100644 --- a/app/controllers/admin/question_options_controller.rb +++ b/app/controllers/admin/question_options_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = QuestionOption.all.paginate(10, params[:page]) + # @resources = QuestionOption. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # QuestionOption.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/questions_controller.rb b/app/controllers/admin/questions_controller.rb index 5bff3b9..1be38bf 100644 --- a/app/controllers/admin/questions_controller.rb +++ b/app/controllers/admin/questions_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = Question.all.paginate(10, params[:page]) + # @resources = Question. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # Question.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/regions_controller.rb b/app/controllers/admin/regions_controller.rb index 05ac844..44d2065 100644 --- a/app/controllers/admin/regions_controller.rb +++ b/app/controllers/admin/regions_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = Region.all.paginate(10, params[:page]) + # @resources = Region. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # Region.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/roles_controller.rb b/app/controllers/admin/roles_controller.rb index 56cd88b..6633242 100644 --- a/app/controllers/admin/roles_controller.rb +++ b/app/controllers/admin/roles_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = Role.all.paginate(10, params[:page]) + # @resources = Role. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # Role.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/sections_controller.rb b/app/controllers/admin/sections_controller.rb index 618423f..b06bb8c 100644 --- a/app/controllers/admin/sections_controller.rb +++ b/app/controllers/admin/sections_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = Section.all.paginate(10, params[:page]) + # @resources = Section. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # Section.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/splash_logs_controller.rb b/app/controllers/admin/splash_logs_controller.rb index 13dbf59..4cb0f85 100644 --- a/app/controllers/admin/splash_logs_controller.rb +++ b/app/controllers/admin/splash_logs_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = SplashLog.all.paginate(10, params[:page]) + # @resources = SplashLog. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # SplashLog.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/suggested_answers_controller.rb b/app/controllers/admin/suggested_answers_controller.rb index 3a86463..5ee314e 100644 --- a/app/controllers/admin/suggested_answers_controller.rb +++ b/app/controllers/admin/suggested_answers_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = SuggestedAnswer.all.paginate(10, params[:page]) + # @resources = SuggestedAnswer. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # SuggestedAnswer.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/templates_controller.rb b/app/controllers/admin/templates_controller.rb index a4de7e9..090a84b 100644 --- a/app/controllers/admin/templates_controller.rb +++ b/app/controllers/admin/templates_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = Template.all.paginate(10, params[:page]) + # @resources = Template. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # Template.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/themes_controller.rb b/app/controllers/admin/themes_controller.rb index 0bd30a1..f15a730 100644 --- a/app/controllers/admin/themes_controller.rb +++ b/app/controllers/admin/themes_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = Theme.all.paginate(10, params[:page]) + # @resources = Theme. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # Theme.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/token_permission_types_controller.rb b/app/controllers/admin/token_permission_types_controller.rb index ddfe9b4..7e90c37 100644 --- a/app/controllers/admin/token_permission_types_controller.rb +++ b/app/controllers/admin/token_permission_types_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = TokenPermissionType.all.paginate(10, params[:page]) + # @resources = TokenPermissionType. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # TokenPermissionType.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/user_identifiers_controller.rb b/app/controllers/admin/user_identifiers_controller.rb index 6db0f51..6699719 100644 --- a/app/controllers/admin/user_identifiers_controller.rb +++ b/app/controllers/admin/user_identifiers_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = UserIdentifier.all.paginate(10, params[:page]) + # @resources = UserIdentifier. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # UserIdentifier.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 43795c3..b456891 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -5,7 +5,9 @@ # # def index # super - # @resources = User.all.paginate(10, params[:page]) + # @resources = User. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ # User.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end