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:
11
app/controllers/admin/expenses_controller.rb
Normal file
11
app/controllers/admin/expenses_controller.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
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 admin_expenses_path
|
||||
end
|
||||
|
||||
end
|
||||
40
app/controllers/admin/group_categories_controller.rb
Normal file
40
app/controllers/admin/group_categories_controller.rb
Normal file
@@ -0,0 +1,40 @@
|
||||
class Admin::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 admin_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 admin_group_categories_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_category
|
||||
@category = GroupCategories.find(params[:id])
|
||||
end
|
||||
|
||||
def resource_params
|
||||
params.permit(:text)
|
||||
end
|
||||
|
||||
end
|
||||
56
app/controllers/admin/promotions_controller.rb
Normal file
56
app/controllers/admin/promotions_controller.rb
Normal file
@@ -0,0 +1,56 @@
|
||||
class Admin::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 admin_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 admin_promotions_path
|
||||
end
|
||||
|
||||
def destroy
|
||||
@promotion.destroy!
|
||||
log_action :destroy, @promotion
|
||||
flash[:notice] = I18n.t('promotions.destroyed_msg')
|
||||
redirect_to admin_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
|
||||
10
app/controllers/admin/trending_hashtags_controller.rb
Normal file
10
app/controllers/admin/trending_hashtags_controller.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
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 admin_trending_hashtags_path
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user