From c6bd65deaa26f806f6d52b13e5dc50bf48998f20 Mon Sep 17 00:00:00 2001 From: Henne Vogelsang Date: Tue, 9 Dec 2014 15:19:01 +0100 Subject: [PATCH] Fix Stellas review gripes --- app/assets/stylesheets/osem-fonts.css.scss | 16 +++-- .../conference_registrations_controller.rb | 2 +- app/controllers/tickets_controller.rb | 9 ++- .../conference_registrations/show.html.haml | 58 +++++++++---------- app/views/tickets/index.html.haml | 4 +- config/routes.rb | 8 +-- 6 files changed, 51 insertions(+), 46 deletions(-) diff --git a/app/assets/stylesheets/osem-fonts.css.scss b/app/assets/stylesheets/osem-fonts.css.scss index 50239f2a..c2ea6493 100644 --- a/app/assets/stylesheets/osem-fonts.css.scss +++ b/app/assets/stylesheets/osem-fonts.css.scss @@ -3,11 +3,11 @@ @font-face { font-family: "suse-icons"; - src:url("fonts/suse-icons.eot"); - src:url("fonts/suse-icons.eot?#iefix") format("embedded-opentype"), - url("fonts/suse-icons.woff") format("woff"), - url("fonts/suse-icons.ttf") format("truetype"), - url("fonts/suse-icons.svg#suse-icons") format("svg"); + src:font-url("suse-icons.eot"); + src:font-url("suse-icons.eot?#iefix") format("embedded-opentype"), + font-url("suse-icons.woff") format("woff"), + font-url("suse-icons.ttf") format("truetype"), + font-url("suse-icons.svg#suse-icons") format("svg"); font-weight: normal; font-style: normal; @@ -22,8 +22,7 @@ text-transform: none !important; speak: none; line-height: 1; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; + font-smoothing: antialiased; } /* We have to repeat this for every symbol that extends font awesome. So if @@ -38,8 +37,7 @@ text-transform: none !important; speak: none; line-height: 1; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; + font-smoothing: antialiased; } .fa-suse:before { diff --git a/app/controllers/conference_registrations_controller.rb b/app/controllers/conference_registrations_controller.rb index 15440f17..1d978ae1 100644 --- a/app/controllers/conference_registrations_controller.rb +++ b/app/controllers/conference_registrations_controller.rb @@ -11,7 +11,7 @@ class ConferenceRegistrationsController < ApplicationController def show @workshops = @registration.workshops @total_price = Ticket.total_price(@conference, current_user) - @tickets = current_user.ticket_purchases.where(conference_id: 1) + @tickets = current_user.ticket_purchases.where(conference_id: @conference.id) end def edit; end diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb index fc6cc55e..55c73fc0 100644 --- a/app/controllers/tickets_controller.rb +++ b/app/controllers/tickets_controller.rb @@ -1,8 +1,15 @@ class TicketsController < ApplicationController before_filter :authenticate_user! load_resource :conference, find_by: :short_title - load_resource :tickets, class: Ticket + load_resource :ticket, through: :conference authorize_resource :conference_registrations, class: Registration + before_filter :check_load_resource, only: :index def index; end + + def check_load_resource + if @tickets.empty? + redirect_to root_path, notice: "There are no tickets available for #{@conference.title}!" + end + end end diff --git a/app/views/conference_registrations/show.html.haml b/app/views/conference_registrations/show.html.haml index 70b6fcfd..7fbf8793 100644 --- a/app/views/conference_registrations/show.html.haml +++ b/app/views/conference_registrations/show.html.haml @@ -66,36 +66,36 @@ - @workshops.each do |workshop| %li = link_to workshop.title, conference_proposal_path(@conference.short_title, workshop.id) - .row - .col-md-12 - %h4 - %span.fa-stack - %i.fa.fa-square-o.fa-stack-2x - %i.fa.fa-ticket.fa-stack-1x - Tickets - -if @tickets.any? - = "(#{@total_price} #{@tickets.first.price.symbol})" - %ul - - @tickets.each do |ticket| + - if @conference.tickets.any? + .row + .col-md-12 + %h4 + %span.fa-stack + %i.fa.fa-square-o.fa-stack-2x + %i.fa.fa-ticket.fa-stack-1x + Tickets + -if @tickets.any? + = "(#{@total_price} #{@tickets.first.price.symbol})" + %ul + - @tickets.each do |ticket| + %li + = ticket.quantity + = ticket.title + = word_pluralize(ticket.quantity, 'Ticket') + for + = humanized_money ticket.price + = ticket.price.symbol + = link_to conference_ticket_purchase_path(@conference.short_title, ticket.id), method: :delete, + id: "ticket-#{ticket.id}-delete", + class: 'btn btn-danger btn-xs', + data: { confirm: "Do you really want to delete the #{ticket.title} ticket for #{@conference.title}?" } do + %i.fa.fa-trash-o %li - = ticket.quantity - = ticket.title - = word_pluralize(ticket.quantity, 'Ticket') - for - = humanized_money ticket.price - = ticket.price.symbol - = link_to conference_ticket_purchase_path(@conference.short_title, ticket.id), method: :delete, - id: "ticket-#{ticket.id}-delete", - class: 'btn btn-danger btn-xs', - data: { confirm: "Do you really want to delete the #{ticket.title} ticket for #{@conference.title}?" } do - %i.fa.fa-trash-o - - %li - - if @tickets.any? - = link_to 'Buy more tickets', conference_tickets_path(@conference.short_title) - - else - You haven't bought any tickets. - = link_to 'Please buy some tickets to support us!', conference_tickets_path(@conference.short_title) + - if @tickets.any? + = link_to 'Buy more tickets', conference_tickets_path(@conference.short_title) + - else + You haven't bought any tickets. + = link_to 'Please buy some tickets to support us!', conference_tickets_path(@conference.short_title) .row .col-md-12 diff --git a/app/views/tickets/index.html.haml b/app/views/tickets/index.html.haml index 685d91d6..5dec92d7 100644 --- a/app/views/tickets/index.html.haml +++ b/app/views/tickets/index.html.haml @@ -18,8 +18,8 @@ %th Price %th Total %tbody - - @conference.tickets.each do |ticket| - = render partial: 'ticket', f: f, locals: {ticket: ticket} + - @conference.tickets.each do |ticket| + = render partial: 'ticket', f: f, locals: {ticket: ticket} %tr %td %td diff --git a/config/routes.rb b/config/routes.rb index 4e39d25f..f794c169 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -58,10 +58,10 @@ Osem::Application.routes.draw do resources :emails, only: [:show, :update, :index] resources :sponsorship_levels, except: [:show] do - member do - patch :up - patch :down - end + member do + patch :up + patch :down + end end resources :questions do