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 +0,0 @@
class Settings::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
end
end

View File

@@ -0,0 +1,63 @@
# frozen_string_literal: true
class Settings::FiltersController < Settings::BaseController
include Authorization
layout 'admin'
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
end
def new
@filter = current_account.custom_filters.build
end
def create
@filter = current_account.custom_filters.build(resource_params)
if @filter.save
redirect_to settings_filters_path
else
render action: :new
end
end
def edit; end
def update
if @filter.update(resource_params)
redirect_to settings_filters_path
else
render action: :edit
end
end
def destroy
@filter.destroy
redirect_to settings_filters_path
end
private
def set_filters
@filters = current_account.custom_filters
end
def set_filter
@filter = current_account.custom_filters.find(params[:id])
end
def resource_params
params.require(:custom_filter).permit(:phrase, :expires_in, :irreversible, :whole_word, context: [])
end
def set_body_classes
@body_classes = 'admin'
end
end

View File

@@ -1,40 +0,0 @@
class Settings::GroupCategoriesController < Admin::BaseController
before_action :set_category, except: [:index, :new, :create]
def index
@categories = GroupCategories.all
end
def new
@category = GroupCategories.new
end
def create
@category = GroupCategories.new(resource_params)
if @category.save
log_action :create, @category
redirect_to settings_group_categories_path, notice: I18n.t('promotions.created_msg')
else
render :new
end
end
def destroy
@category.destroy!
log_action :destroy, @category
flash[:notice] = I18n.t('promotions.destroyed_msg')
redirect_to settings_group_categories_path
end
private
def set_category
@category = GroupCategories.find(params[:id])
end
def resource_params
params.permit(:text)
end
end

View File

@@ -1,56 +0,0 @@
class Settings::PromotionsController < Admin::BaseController
before_action :set_promotion, except: [:index, :new, :create]
def index
@promotions = Promotion.all
end
def new
@promotion = Promotion.new
end
def create
@promotion = Promotion.new(resource_params)
if @promotion.save
log_action :create, @promotion
redirect_to settings_promotions_path, notice: I18n.t('promotions.created_msg')
else
render :new
end
end
def edit
end
def update
if @promotion.update(resource_params)
log_action :update, @promotion
flash[:notice] = I18n.t('promotions.updated_msg')
else
flash[:alert] = I18n.t('promotions.update_failed_msg')
end
redirect_to settings_promotions_path
end
def destroy
@promotion.destroy!
log_action :destroy, @promotion
flash[:notice] = I18n.t('promotions.destroyed_msg')
redirect_to settings_promotions_path
end
private
def set_promotion
@promotion = Promotion.find(params[:id])
end
def set_filter_params
@filter_params = filter_params.to_hash.symbolize_keys
end
def resource_params
params.require(:promotion).permit(:expires_at, :status_id, :timeline_id, :position)
end
end

View File

@@ -1,10 +0,0 @@
class Settings::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
end
end