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
@amount = Redis.current.get("monthly_funding_amount") || 0
end
def create
Redis.current.set("monthly_funding_amount", params[:amount])
redirect_to settings_expenses_path
redirect_to admin_expenses_path
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]
def index
@ -14,7 +14,7 @@ class Settings::GroupCategoriesController < Admin::BaseController
if @category.save
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
render :new
end
@ -24,7 +24,7 @@ class Settings::GroupCategoriesController < Admin::BaseController
@category.destroy!
log_action :destroy, @category
flash[:notice] = I18n.t('promotions.destroyed_msg')
redirect_to settings_group_categories_path
redirect_to admin_group_categories_path
end
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]
def index
@ -14,7 +14,7 @@ class Settings::PromotionsController < Admin::BaseController
if @promotion.save
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
render :new
end
@ -30,14 +30,14 @@ class Settings::PromotionsController < Admin::BaseController
else
flash[:alert] = I18n.t('promotions.update_failed_msg')
end
redirect_to settings_promotions_path
redirect_to admin_promotions_path
end
def destroy
@promotion.destroy!
log_action :destroy, @promotion
flash[:notice] = I18n.t('promotions.destroyed_msg')
redirect_to settings_promotions_path
redirect_to admin_promotions_path
end
private

View File

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

View File

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

View File

@ -1,6 +1,6 @@
- content_for :page_title do
= 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
= 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
= 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
.input.string.optional
= 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
= 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
.fields-group

View File

@ -13,4 +13,4 @@
%tbody
= 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
= 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
.fields-group

View File

@ -1,6 +1,6 @@
- content_for :page_title do
= '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
= submit_tag "Submit"

View File

@ -1,7 +1,7 @@
- content_for :page_title do
= 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
.actions

View File

@ -14,7 +14,7 @@
%td= filter.phrase
%td= filter.context.map { |context| I18n.t("filters.contexts.#{context}") }.join(', ')
%td
= table_link_to 'pencil', t('filters.edit.title'), edit_filter_path(filter)
= table_link_to 'times', t('filters.index.delete'), filter_path(filter), method: :delete
= table_link_to 'pencil', t('filters.edit.title'), edit_settings_filter_path(filter)
= 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
= 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
.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
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|
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 :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 :promotions, safe_join([fa_icon('star fw'), t('promotions.title')]), settings_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 :group_categories, safe_join([fa_icon('users fw'), t('group_categories.title')]), settings_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 :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')]), admin_expenses_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']), admin_trending_hashtags_url, if: -> { current_user.admin? }
end
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',
}
get '/authorize_follow', to: redirect { |_, request| "/authorize_interaction?#{request.params.to_query}" }
namespace :settings do
resource :profile, 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
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
get :moderation, to: 'moderation#index', as: :moderation
get 'moderation/:id/approve', to: 'moderation#approve', as: :approve
@ -87,14 +80,13 @@ Rails.application.routes.draw do
resources :sessions, only: [:destroy]
resources :scheduled_statuses, only: [:index, :destroy]
resources :filters, except: [:show]
end
resources :media, only: [:show] do
get :player
end
resources :filters, except: [:show]
get '/media_proxy/:id/(*any)', to: 'media_proxy#show', as: :media_proxy
namespace :admin do
@ -105,6 +97,10 @@ Rails.application.routes.draw do
resources :action_logs, only: [:index]
resources :warning_presets, except: [:new]
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
member do