Updated routes for admins dashboard

• Updated:
- routes for admins dashboard (expenses, group categories, promotions, trending hashtags) that were in the /settings path but are now in the /admin path
- /filters to be in /settings/filters

• Removed:
- authorize_follow route
This commit is contained in:
mgabdev 2021-01-13 18:06:45 -05:00
parent 27389883dd
commit 8aeae9c45d
21 changed files with 50 additions and 53 deletions

View File

@ -1,11 +1,11 @@
class Settings::ExpensesController < Admin::BaseController class Admin::ExpensesController < Admin::BaseController
def index def index
@amount = Redis.current.get("monthly_funding_amount") || 0 @amount = Redis.current.get("monthly_funding_amount") || 0
end end
def create def create
Redis.current.set("monthly_funding_amount", params[:amount]) Redis.current.set("monthly_funding_amount", params[:amount])
redirect_to settings_expenses_path redirect_to admin_expenses_path
end end
end end

View File

@ -1,4 +1,4 @@
class Settings::GroupCategoriesController < Admin::BaseController class Admin::GroupCategoriesController < Admin::BaseController
before_action :set_category, except: [:index, :new, :create] before_action :set_category, except: [:index, :new, :create]
def index def index
@ -14,7 +14,7 @@ class Settings::GroupCategoriesController < Admin::BaseController
if @category.save if @category.save
log_action :create, @category log_action :create, @category
redirect_to settings_group_categories_path, notice: I18n.t('promotions.created_msg') redirect_to admin_group_categories_path, notice: I18n.t('promotions.created_msg')
else else
render :new render :new
end end
@ -24,7 +24,7 @@ class Settings::GroupCategoriesController < Admin::BaseController
@category.destroy! @category.destroy!
log_action :destroy, @category log_action :destroy, @category
flash[:notice] = I18n.t('promotions.destroyed_msg') flash[:notice] = I18n.t('promotions.destroyed_msg')
redirect_to settings_group_categories_path redirect_to admin_group_categories_path
end end
private private

View File

@ -1,4 +1,4 @@
class Settings::PromotionsController < Admin::BaseController class Admin::PromotionsController < Admin::BaseController
before_action :set_promotion, except: [:index, :new, :create] before_action :set_promotion, except: [:index, :new, :create]
def index def index
@ -14,7 +14,7 @@ class Settings::PromotionsController < Admin::BaseController
if @promotion.save if @promotion.save
log_action :create, @promotion log_action :create, @promotion
redirect_to settings_promotions_path, notice: I18n.t('promotions.created_msg') redirect_to admin_promotions_path, notice: I18n.t('promotions.created_msg')
else else
render :new render :new
end end
@ -30,14 +30,14 @@ class Settings::PromotionsController < Admin::BaseController
else else
flash[:alert] = I18n.t('promotions.update_failed_msg') flash[:alert] = I18n.t('promotions.update_failed_msg')
end end
redirect_to settings_promotions_path redirect_to admin_promotions_path
end end
def destroy def destroy
@promotion.destroy! @promotion.destroy!
log_action :destroy, @promotion log_action :destroy, @promotion
flash[:notice] = I18n.t('promotions.destroyed_msg') flash[:notice] = I18n.t('promotions.destroyed_msg')
redirect_to settings_promotions_path redirect_to admin_promotions_path
end end
private private

View File

@ -1,10 +1,10 @@
class Settings::TrendingHashtagsController < Admin::BaseController class Admin::TrendingHashtagsController < Admin::BaseController
def index def index
@trending_hashtags = Redis.current.get("admin_trending_hashtags") || '' @trending_hashtags = Redis.current.get("admin_trending_hashtags") || ''
end end
def create def create
Redis.current.set("admin_trending_hashtags", params[:trending_hashtags]) Redis.current.set("admin_trending_hashtags", params[:trending_hashtags])
redirect_to settings_trending_hashtags_path redirect_to admin_trending_hashtags_path
end end
end end

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
class FiltersController < ApplicationController class Settings::FiltersController < Settings::BaseController
include Authorization include Authorization
layout 'admin' layout 'admin'
@ -8,6 +8,7 @@ class FiltersController < ApplicationController
before_action :set_filters, only: :index before_action :set_filters, only: :index
before_action :set_filter, only: [:edit, :update, :destroy] before_action :set_filter, only: [:edit, :update, :destroy]
before_action :set_body_classes before_action :set_body_classes
before_action :authenticate_user!
def index def index
@filters = current_account.custom_filters @filters = current_account.custom_filters
@ -21,7 +22,7 @@ class FiltersController < ApplicationController
@filter = current_account.custom_filters.build(resource_params) @filter = current_account.custom_filters.build(resource_params)
if @filter.save if @filter.save
redirect_to filters_path redirect_to settings_filters_path
else else
render action: :new render action: :new
end end
@ -31,7 +32,7 @@ class FiltersController < ApplicationController
def update def update
if @filter.update(resource_params) if @filter.update(resource_params)
redirect_to filters_path redirect_to settings_filters_path
else else
render action: :edit render action: :edit
end end
@ -39,7 +40,7 @@ class FiltersController < ApplicationController
def destroy def destroy
@filter.destroy @filter.destroy
redirect_to filters_path redirect_to settings_filters_path
end end
private private

View File

@ -1,6 +1,6 @@
- content_for :page_title do - content_for :page_title do
= t('monthly_funding.title') = t('monthly_funding.title')
= form_tag settings_expenses_url, :method => :post do = form_tag admin_expenses_url, :method => :post do
= text_field_tag "amount", "", placeholder: "0-100", :value => @amount = text_field_tag "amount", "", placeholder: "0-100", :value => @amount
= submit_tag "Submit" = submit_tag "Submit"

View File

@ -0,0 +1,5 @@
%tr
%td= group_categories.created_at
%td= group_categories.text
%td
= table_link_to 'trash', t('group_categories.delete'), admin_group_categories_url(group_categories), method: :delete

View File

@ -1,7 +1,7 @@
- content_for :page_title do - content_for :page_title do
= t('group_categories.title') = t('group_categories.title')
= form_tag settings_group_categories_url, method: 'POST', class: 'simple_form' do = form_tag admin_group_categories_url, method: 'POST', class: 'simple_form' do
.fields-group .fields-group
.input.string.optional .input.string.optional
= text_field_tag :text, params[:text], class: 'string optional', placeholder: I18n.t("group_categories.text") = text_field_tag :text, params[:text], class: 'string optional', placeholder: I18n.t("group_categories.text")

View File

@ -0,0 +1,8 @@
%tr
%td= promotion.timeline_id
%td= promotion.status_id
%td= promotion.expires_at
%td= promotion.position
%td
= table_link_to 'pencil', t('promotions.edit'), edit_admin_promotion_path(promotion)
= table_link_to 'trash', t('promotions.delete'), admin_promotion_path(promotion), method: :delete, data: { confirm: t('settings.promotions.are_you_sure') }

View File

@ -1,7 +1,7 @@
- content_for :page_title do - content_for :page_title do
= t('promotions.title') = t('promotions.title')
= simple_form_for @promotion, url: settings_promotion_path(@promotion) do |f| = simple_form_for @promotion, url: admin_promotion_path(@promotion) do |f|
= render 'shared/error_messages', object: @promotion = render 'shared/error_messages', object: @promotion
.fields-group .fields-group

View File

@ -13,4 +13,4 @@
%tbody %tbody
= render @promotions = render @promotions
= link_to t('promotions.create'), new_settings_promotion_path, class: 'button' = link_to t('promotions.create'), new_admin_promotion_path, class: 'button'

View File

@ -1,7 +1,7 @@
- content_for :page_title do - content_for :page_title do
= t('.title') = t('.title')
= simple_form_for @promotion, url: settings_promotions_path do |f| = simple_form_for @promotion, url: admin_promotions_path do |f|
= render 'shared/error_messages', object: @promotion = render 'shared/error_messages', object: @promotion
.fields-group .fields-group

View File

@ -1,6 +1,6 @@
- content_for :page_title do - content_for :page_title do
= 'Trending Hashtags' = 'Trending Hashtags'
= form_tag settings_trending_hashtags_url, :method => :post do = form_tag admin_trending_hashtags_url, :method => :post do
= text_field_tag "trending_hashtags", "", :style => 'width:400px', placeholder: "StopTheSteal, Trump2020, Election2020", :value => @trending_hashtags = text_field_tag "trending_hashtags", "", :style => 'width:400px', placeholder: "StopTheSteal, Trump2020, Election2020", :value => @trending_hashtags
= submit_tag "Submit" = submit_tag "Submit"

View File

@ -1,7 +1,7 @@
- content_for :page_title do - content_for :page_title do
= t('filters.edit.title') = t('filters.edit.title')
= simple_form_for @filter, url: filter_path(@filter), method: :put do |f| = simple_form_for @filter, url: settings_filter_path(@filter), method: :put do |f|
= render 'fields', f: f = render 'fields', f: f
.actions .actions

View File

@ -14,7 +14,7 @@
%td= filter.phrase %td= filter.phrase
%td= filter.context.map { |context| I18n.t("filters.contexts.#{context}") }.join(', ') %td= filter.context.map { |context| I18n.t("filters.contexts.#{context}") }.join(', ')
%td %td
= table_link_to 'pencil', t('filters.edit.title'), edit_filter_path(filter) = table_link_to 'pencil', t('filters.edit.title'), edit_settings_filter_path(filter)
= table_link_to 'times', t('filters.index.delete'), filter_path(filter), method: :delete = table_link_to 'times', t('filters.index.delete'), settings_filter_path(filter), method: :delete
= link_to t('filters.new.title'), new_filter_path, class: 'button' = link_to t('filters.new.title'), new_settings_filter_path, class: 'button'

View File

@ -1,7 +1,7 @@
- content_for :page_title do - content_for :page_title do
= t('filters.new.title') = t('filters.new.title')
= simple_form_for @filter, url: filters_path do |f| = simple_form_for @filter, url: settings_filters_path do |f|
= render 'fields', f: f = render 'fields', f: f
.actions .actions

View File

@ -1,5 +0,0 @@
%tr
%td= group_categories.created_at
%td= group_categories.text
%td
= table_link_to 'trash', t('group_categories.delete'), settings_group_categories_path(group_categories), method: :delete

View File

@ -1,8 +0,0 @@
%tr
%td= promotion.timeline_id
%td= promotion.status_id
%td= promotion.expires_at
%td= promotion.position
%td
= table_link_to 'pencil', t('promotions.edit'), edit_settings_promotion_path(promotion)
= table_link_to 'trash', t('promotions.delete'), settings_promotion_path(promotion), method: :delete, data: { confirm: t('settings.promotions.are_you_sure') }

View File

@ -9,7 +9,7 @@ SimpleNavigation::Configuration.run do |navigation|
end end
n.item :preferences, safe_join([fa_icon('cog fw'), t('settings.preferences')]), settings_preferences_url, highlights_on: %r{/settings/preferences|/settings/notifications} n.item :preferences, safe_join([fa_icon('cog fw'), t('settings.preferences')]), settings_preferences_url, highlights_on: %r{/settings/preferences|/settings/notifications}
n.item :filters, safe_join([fa_icon('filter fw'), t('filters.index.title')]), filters_path, highlights_on: %r{/filters} n.item :filters, safe_join([fa_icon('filter fw'), t('filters.index.title')]), settings_filters_path, highlights_on: %r{/filters}
n.item :security, safe_join([fa_icon('lock fw'), t('settings.account')]), edit_user_registration_url do |s| n.item :security, safe_join([fa_icon('lock fw'), t('settings.account')]), edit_user_registration_url do |s|
s.item :password, safe_join([fa_icon('lock fw'), t('settings.account_settings')]), edit_user_registration_url, highlights_on: %r{/auth/edit|/settings/delete} s.item :password, safe_join([fa_icon('lock fw'), t('settings.account_settings')]), edit_user_registration_url, highlights_on: %r{/auth/edit|/settings/delete}
@ -43,10 +43,10 @@ SimpleNavigation::Configuration.run do |navigation|
s.item :sidekiq, safe_join([fa_icon('diamond fw'), 'Sidekiq']), sidekiq_url, link_html: { target: 'sidekiq' }, if: -> { current_user.admin? } s.item :sidekiq, safe_join([fa_icon('diamond fw'), 'Sidekiq']), sidekiq_url, link_html: { target: 'sidekiq' }, if: -> { current_user.admin? }
s.item :pghero, safe_join([fa_icon('database fw'), 'PgHero']), pghero_url, link_html: { target: 'pghero' }, if: -> { current_user.admin? } s.item :pghero, safe_join([fa_icon('database fw'), 'PgHero']), pghero_url, link_html: { target: 'pghero' }, if: -> { current_user.admin? }
s.item :moderation, safe_join([fa_icon('id-card-o fw'), t('verifications.moderation.title')]), settings_verifications_moderation_url, if: -> { current_user.admin? } s.item :moderation, safe_join([fa_icon('id-card-o fw'), t('verifications.moderation.title')]), settings_verifications_moderation_url, if: -> { current_user.admin? }
s.item :promotions, safe_join([fa_icon('star fw'), t('promotions.title')]), settings_promotions_url, if: -> { current_user.admin? } s.item :promotions, safe_join([fa_icon('star fw'), t('promotions.title')]), admin_promotions_url, if: -> { current_user.admin? }
s.item :monthly_funding, safe_join([fa_icon('money fw'), t('monthly_funding.title')]), settings_expenses_url, if: -> { current_user.admin? } s.item :monthly_funding, safe_join([fa_icon('money fw'), t('monthly_funding.title')]), admin_expenses_url, if: -> { current_user.admin? }
s.item :group_categories, safe_join([fa_icon('users fw'), t('group_categories.title')]), settings_group_categories_url, if: -> { current_user.admin? } s.item :group_categories, safe_join([fa_icon('users fw'), t('group_categories.title')]), admin_group_categories_url, if: -> { current_user.admin? }
s.item :trending_hashtags, safe_join([fa_icon('hashtag fw'), 'Trending Hashtags']), settings_trending_hashtags_url, if: -> { current_user.admin? } s.item :trending_hashtags, safe_join([fa_icon('hashtag fw'), 'Trending Hashtags']), admin_trending_hashtags_url, if: -> { current_user.admin? }
end end
n.item :logout, safe_join([fa_icon('sign-out fw'), t('auth.logout')]), destroy_user_session_url, link_html: { 'data-method' => 'delete' } n.item :logout, safe_join([fa_icon('sign-out fw'), t('auth.logout')]), destroy_user_session_url, link_html: { 'data-method' => 'delete' }

View File

@ -37,8 +37,6 @@ Rails.application.routes.draw do
confirmations: 'auth/confirmations', confirmations: 'auth/confirmations',
} }
get '/authorize_follow', to: redirect { |_, request| "/authorize_interaction?#{request.params.to_query}" }
namespace :settings do namespace :settings do
resource :profile, only: [:show, :update] resource :profile, only: [:show, :update]
resource :preferences, only: [:show, :update] resource :preferences, only: [:show, :update]
@ -50,11 +48,6 @@ Rails.application.routes.draw do
post '/btcpay-notification', to: 'upgrade#btcpay_notification', as: :btcpay_notification post '/btcpay-notification', to: 'upgrade#btcpay_notification', as: :btcpay_notification
end end
resources :promotions, only: [:index, :new, :create, :edit, :update, :destroy]
resources :expenses, only: [:index, :new, :create, :edit, :update, :destroy]
resources :group_categories, only: [:index, :new, :create, :edit, :update, :destroy]
resources :trending_hashtags, only: [:index, :new, :create, :edit, :update, :destroy]
namespace :verifications do namespace :verifications do
get :moderation, to: 'moderation#index', as: :moderation get :moderation, to: 'moderation#index', as: :moderation
get 'moderation/:id/approve', to: 'moderation#approve', as: :approve get 'moderation/:id/approve', to: 'moderation#approve', as: :approve
@ -87,14 +80,13 @@ Rails.application.routes.draw do
resources :sessions, only: [:destroy] resources :sessions, only: [:destroy]
resources :scheduled_statuses, only: [:index, :destroy] resources :scheduled_statuses, only: [:index, :destroy]
resources :filters, except: [:show]
end end
resources :media, only: [:show] do resources :media, only: [:show] do
get :player get :player
end end
resources :filters, except: [:show]
get '/media_proxy/:id/(*any)', to: 'media_proxy#show', as: :media_proxy get '/media_proxy/:id/(*any)', to: 'media_proxy#show', as: :media_proxy
namespace :admin do namespace :admin do
@ -105,6 +97,10 @@ Rails.application.routes.draw do
resources :action_logs, only: [:index] resources :action_logs, only: [:index]
resources :warning_presets, except: [:new] resources :warning_presets, except: [:new]
resource :settings, only: [:edit, :update] resource :settings, only: [:edit, :update]
resources :promotions, only: [:index, :new, :create, :edit, :update, :destroy]
resources :expenses, only: [:index, :new, :create, :edit, :update, :destroy]
resources :group_categories, only: [:index, :new, :create, :edit, :update, :destroy]
resources :trending_hashtags, only: [:index, :new, :create, :edit, :update, :destroy]
resources :reports, only: [:index, :show] do resources :reports, only: [:index, :show] do
member do member do