admin for promotions
This commit is contained in:
parent
daf5eeb905
commit
d853beebb7
56
app/controllers/settings/promotions_controller.rb
Normal file
56
app/controllers/settings/promotions_controller.rb
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
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
|
8
app/views/settings/promotions/_promotion.html.haml
Normal file
8
app/views/settings/promotions/_promotion.html.haml
Normal 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_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') }
|
14
app/views/settings/promotions/edit.html.haml
Normal file
14
app/views/settings/promotions/edit.html.haml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
- content_for :page_title do
|
||||||
|
= t('promotions.title')
|
||||||
|
|
||||||
|
= simple_form_for @promotion, url: settings_promotion_path(@promotion) do |f|
|
||||||
|
= render 'shared/error_messages', object: @promotion
|
||||||
|
|
||||||
|
.fields-group
|
||||||
|
= f.input :timeline_id, wrapper: :with_label, label: t('promotions.timeline_id')
|
||||||
|
= f.input :status_id, wrapper: :with_label, label: t('promotions.status_id')
|
||||||
|
= f.input :expires_at, as: :string, wrapper: :with_label, label: t('promotions.expires_at')
|
||||||
|
= f.input :position, wrapper: :with_label, label: t('promotions.position')
|
||||||
|
|
||||||
|
.actions
|
||||||
|
= f.button :button, t('generic.save_changes'), type: :submit
|
16
app/views/settings/promotions/index.html.haml
Normal file
16
app/views/settings/promotions/index.html.haml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
- content_for :page_title do
|
||||||
|
= t('promotions.title')
|
||||||
|
|
||||||
|
.table-wrapper
|
||||||
|
%table.table
|
||||||
|
%thead
|
||||||
|
%tr
|
||||||
|
%th= t('promotions.timeline_id')
|
||||||
|
%th= t('promotions.status_id')
|
||||||
|
%th= t('promotions.expires_at')
|
||||||
|
%th= t('promotions.position')
|
||||||
|
%th
|
||||||
|
%tbody
|
||||||
|
= render @promotions
|
||||||
|
|
||||||
|
= link_to t('promotions.create'), new_settings_promotion_path, class: 'button'
|
14
app/views/settings/promotions/new.html.haml
Normal file
14
app/views/settings/promotions/new.html.haml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
- content_for :page_title do
|
||||||
|
= t('.title')
|
||||||
|
|
||||||
|
= simple_form_for @promotion, url: settings_promotions_path do |f|
|
||||||
|
= render 'shared/error_messages', object: @promotion
|
||||||
|
|
||||||
|
.fields-group
|
||||||
|
= f.input :timeline_id, wrapper: :with_label, label: t('promotions.timeline_id')
|
||||||
|
= f.input :status_id, wrapper: :with_label, label: t('promotions.status_id')
|
||||||
|
= f.input :expires_at, as: :string, wrapper: :with_label, label: t('promotions.expires_at')
|
||||||
|
= f.input :position, wrapper: :with_label, label: t('promotions.position')
|
||||||
|
|
||||||
|
.actions
|
||||||
|
= f.button :button, t('.create'), type: :submit
|
@ -70,6 +70,8 @@ en:
|
|||||||
moderator: Mod
|
moderator: Mod
|
||||||
unavailable: Profile unavailable
|
unavailable: Profile unavailable
|
||||||
unfollow: Unfollow
|
unfollow: Unfollow
|
||||||
|
promotions:
|
||||||
|
title: Promotions
|
||||||
admin:
|
admin:
|
||||||
account_actions:
|
account_actions:
|
||||||
action: Perform action
|
action: Perform action
|
||||||
|
@ -55,6 +55,7 @@ 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? }
|
||||||
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' }
|
||||||
|
@ -89,6 +89,8 @@ 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]
|
||||||
|
|
||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user