Make approved events confirmable
This commit is contained in:
parent
8c94bb3a87
commit
0296af92db
|
@ -40,6 +40,18 @@ module Public
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def confirm
|
||||||
|
@event = current_user.events.approved.find(params[:id])
|
||||||
|
|
||||||
|
if @event.confirm!
|
||||||
|
flash[:notice] = I18n.t('views.events.successfully_confirmed', event_type: @event.event_type.name.mb_chars.downcase)
|
||||||
|
else
|
||||||
|
flash[:alert] = I18n.t('views.events.error_on_confirmation', event_type: @event.event_type.name.mb_chars.downcase)
|
||||||
|
end
|
||||||
|
|
||||||
|
after_save_redirect
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def event_params
|
def event_params
|
||||||
|
|
|
@ -5,10 +5,11 @@ module Proposable
|
||||||
has_one :proposition, as: :proposable, dependent: :destroy
|
has_one :proposition, as: :proposable, dependent: :destroy
|
||||||
has_one :proposer, through: :proposition
|
has_one :proposer, through: :proposition
|
||||||
delegate :email, to: :proposer, prefix: true
|
delegate :email, to: :proposer, prefix: true
|
||||||
scope :confirmed, -> { joins(:proposition).where.not(propositions: {confirmed_at: nil}) }
|
delegate :confirm!, to: :proposition
|
||||||
|
scope :confirmed, -> { where.not(propositions: {confirmed_at: nil}) }
|
||||||
|
|
||||||
Proposition.defined_enums["status"].keys.each do |status|
|
Proposition.defined_enums["status"].keys.each do |status|
|
||||||
scope status.to_sym, -> { joins(:proposition).where(propositions: {status: Proposition.defined_enums["status"][status]}) }
|
scope status.to_sym, -> { where(propositions: {status: Proposition.defined_enums["status"][status]}) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,10 @@ class Proposition < ActiveRecord::Base
|
||||||
after_create :send_creation_notification
|
after_create :send_creation_notification
|
||||||
before_destroy :send_withdrawal_notification
|
before_destroy :send_withdrawal_notification
|
||||||
|
|
||||||
|
def confirm!
|
||||||
|
update(confirmed_at: Time.now)
|
||||||
|
end
|
||||||
|
|
||||||
def send_creation_notification
|
def send_creation_notification
|
||||||
PropositionMailer.new_proposition_notification(self).deliver_later
|
PropositionMailer.new_proposition_notification(self).deliver_later
|
||||||
end
|
end
|
||||||
|
|
|
@ -289,6 +289,8 @@ bg:
|
||||||
edit_event: "Редактиране на %{event_type} %{title}"
|
edit_event: "Редактиране на %{event_type} %{title}"
|
||||||
event_successfully_created: "Предложението Ви за %{event_type} беше създадено успешно"
|
event_successfully_created: "Предложението Ви за %{event_type} беше създадено успешно"
|
||||||
event_successfully_updated: "Предложението Ви за %{event_type} беше обновено успешно"
|
event_successfully_updated: "Предложението Ви за %{event_type} беше обновено успешно"
|
||||||
|
successfully_confirmed: "Предложението Ви за %{event_type} беше потвърдено успешно"
|
||||||
|
error_on_confirmation: "Възникна грешка при потвърждението на предложението Ви за %{event_type}"
|
||||||
no_events: "Все още не сте предложили събитие"
|
no_events: "Все още не сте предложили събитие"
|
||||||
submit_event: "Предлагане на %{event_type}"
|
submit_event: "Предлагане на %{event_type}"
|
||||||
navigation:
|
navigation:
|
||||||
|
|
|
@ -282,6 +282,8 @@ en:
|
||||||
edit_event: Editing %{event_type} %{title}
|
edit_event: Editing %{event_type} %{title}
|
||||||
event_successfully_created: Your %{event_type} submission was successfully created
|
event_successfully_created: Your %{event_type} submission was successfully created
|
||||||
event_successfully_updated: Your %{event_type} submission was successfully updated
|
event_successfully_updated: Your %{event_type} submission was successfully updated
|
||||||
|
successfully_confirmed: Your %{event_type} submission was successfully confirmed
|
||||||
|
error_on_confirmation: There was an error during the confirmation of your %{event_type} submission
|
||||||
no_events: You are yet to submit an event
|
no_events: You are yet to submit an event
|
||||||
submit_event: Submit a %{event_type}
|
submit_event: Submit a %{event_type}
|
||||||
navigation:
|
navigation:
|
||||||
|
|
|
@ -4,7 +4,11 @@ Rails.application.routes.draw do
|
||||||
scope module: :public do
|
scope module: :public do
|
||||||
root to: 'home#index'
|
root to: 'home#index'
|
||||||
resource :personal_profile, path: 'profile'
|
resource :personal_profile, path: 'profile'
|
||||||
resources :events
|
resources :events do
|
||||||
|
member do
|
||||||
|
get :confirm
|
||||||
|
end
|
||||||
|
end
|
||||||
resources :volunteerships, only: [:index, :destroy]
|
resources :volunteerships, only: [:index, :destroy]
|
||||||
resources :volunteer_teams, only: [] do
|
resources :volunteer_teams, only: [] do
|
||||||
resource :volunteership, only: :create
|
resource :volunteership, only: :create
|
||||||
|
|
Loading…
Reference in New Issue