Registration tickets to be set for registration period

Admin must create at least one registration ticket before creating registration period.
This commit is contained in:
siddhantbajaj 2017-08-12 01:27:16 +05:30
parent 22fc20468f
commit 157c270497
10 changed files with 27 additions and 5 deletions

View file

@ -123,7 +123,10 @@ class AdminAbility
can :manage, Commercial, commercialable_type: 'Conference',
commercialable_id: conf_ids
can :manage, Registration, conference_id: conf_ids
can :manage, RegistrationPeriod, conference_id: conf_ids
can :manage, RegistrationPeriod do |registration_period|
conference = registration_period.conference
conf_ids.include?(conference.id) && conference.tickets.for_registration.any?
end
can :manage, Booth, conference_id: conf_ids
can :manage, Question, conference_id: conf_ids
can :manage, Question do |question|

View file

@ -26,7 +26,11 @@ class Conference < ActiveRecord::Base
has_many :ticket_purchases, dependent: :destroy
has_many :payments, dependent: :destroy
has_many :supporters, through: :ticket_purchases, source: :user
has_many :tickets, dependent: :destroy
has_many :tickets, dependent: :destroy do
def for_registration
where(registration_ticket: true)
end
end
has_many :resources, dependent: :destroy
has_many :booths, dependent: :destroy

View file

@ -25,5 +25,12 @@
= link_to 'Delete', admin_conference_registration_period_path,
method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger'
- else
- if can? :create, @conference.build_registration_period
= link_to 'New Registration Period', new_admin_conference_registration_period_path, class: 'btn btn-primary'
- unless @conference.tickets.for_registration.empty?
- if can? :create, @conference.build_registration_period
= link_to 'New Registration Period', new_admin_conference_registration_period_path, class: 'btn btn-primary'
- else
.h3.text-left
No Registration Tickets!
%small
= link_to 'Create registration tickets', new_admin_conference_ticket_path
before creating the registration period.