Various small fixes for the participant UI

This commit is contained in:
Henne Vogelsang 2014-12-05 16:04:34 +01:00
parent b6abe96279
commit d13efa5f52
31 changed files with 287 additions and 279 deletions

View file

@ -105,7 +105,14 @@ class Ability
# Abilities for everyone, even guests (not logged in users)
def guest
# can view conferences
can [:index, :show, :schedule], Conference
can [:index], Conference
can [:show], Conference do |conference|
conference.splashpage && conference.splashpage.public == true
end
can [:schedule], Conference do |conference|
conference.call_for_paper && conference.call_for_paper.schedule_public
end
# can view confirmed Events
can :show, Event do |event|
event.state == 'confirmed'

View file

@ -13,11 +13,18 @@ class TicketPurchase < ActiveRecord::Base
scope: :ticket_id,
message: 'already bought this ticket!'
delegate :title, to: :ticket
delegate :description, to: :ticket
delegate :price, to: :ticket
delegate :price_cents, to: :ticket
delegate :price_currency, to: :ticket
def self.purchase(conference, user, purchases)
errors = []
ActiveRecord::Base.transaction do
conference.tickets.each do |ticket|
quantity = purchases[ticket.id.to_s].to_i
# if the user bought the ticket, just update the quantity
if ticket.bought?(user)
purchase = update_quantity(conference, quantity, ticket, user)
else

View file

@ -4,6 +4,7 @@ class Track < ActiveRecord::Base
has_many :events
before_create :generate_guid
validates :name, presence: true
private

View file

@ -59,13 +59,17 @@ class User < ActiveRecord::Base
self.subscriptions.find_by(conference_id: conference.id).present?
end
# Returns the ticket purchased ticket
# Returns the purchased ticket
# ====Returns
# * +TicketUser::ActiveRecord_Relation+ -> user
def ticket(id)
ticket_purchases.where(ticket_id: id).first
end
def supports? conference
ticket_purchases.find_by(conference_id: conference.id).present?
end
def self.for_ichain_username(username, attributes)
user = find_by(username: username)

View file

@ -17,7 +17,7 @@ class Venue < ActiveRecord::Base
after_update :send_mail_notification
def address
"#{conference.venue.street}, #{conference.venue.postalcode} #{conference.venue.city}, #{conference.venue.country}"
"#{street}, #{city}, #{country_name}"
end
def country_name