Skip to content
This repository has been archived by the owner on Mar 12, 2019. It is now read-only.

Commit

Permalink
Merge branch 'master' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Pellet committed Jul 25, 2013
2 parents e98adab + 7451d2b commit 1d98b56
Show file tree
Hide file tree
Showing 38 changed files with 381 additions and 55 deletions.
8 changes: 7 additions & 1 deletion app/admin/attendees.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
column :email_address
column :state
column :round
column :gender
column :age
column :profession
column :tweet_idea
column :scholarship
column :student
default_actions
end

Expand All @@ -17,7 +23,7 @@

controller do
def permitted_params
params.permit(:attendee => [:email_address, :round, :first_name, :last_name])
params.permit(:attendee => [:email_address, :round, :first_name, :last_name, :gender, :age, :profession, :tweet_idea, :scholarship, :student])
end
end

Expand Down
Binary file added app/assets/images/icons/mastercard.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/icons/visa.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/select.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions app/assets/javascripts/payments.js

This file was deleted.

28 changes: 28 additions & 0 deletions app/assets/javascripts/payments.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class PaymentStudentHandler
constructor : ->
@$studentSelect = $('#student_amount')
@$trData = $('#tr_data')
@trDataNormal = $('#tr_data_normal').val()
@trDataStudent = $('#tr_data_student').val()

bindChanges : ->
@$studentSelect.off('change')
@$studentSelect.on 'change', =>
@updateTrData()

isStudent : ->
return JSON.parse(@$studentSelect.val())

updateTrData : ->
if @isStudent()
@$trData.val(@trDataStudent)
@$studentSelect.after('<p class="student-helper-message">Students must present photo ID.</p>')
else
@$trData.val(@trDataNormal)
$('.student-helper-message').remove()


$ ->
if $('#student_amount').length > 0
psh = new PaymentStudentHandler()
psh.bindChanges()
15 changes: 14 additions & 1 deletion app/assets/javascripts/ui_events.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,23 @@ class @UiEvents
$(document).off 'click', '.flash'
$(document).on 'click', '.flash', (e) ->
$(this).hide()

@resizeUI: ->
$('.header, .main').css('min-height', $(window).height())
$(window).resize -> $('.header, .main').css('min-height', $(window).height())

$(document).ready ->
UiEvents.init()


if $('#new_attendee').length
$('#attendee_tweet_idea').on 'keyup', (e) ->
count = 140 - $(this).val().length

$('#char_count').html(count)

if count < 10
$('#char_count').addClass('limit')
else
$('#char_count').removeClass('limit')

113 changes: 110 additions & 3 deletions app/assets/stylesheets/modules/_form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
}

%buttons {
clear: both;
margin: 1.5em 0 0;
padding: 1.5em 0 0;
border-top: 2px dotted #ddd;
Expand All @@ -41,21 +42,65 @@


form {
ol {
clear: both;
margin: 0 -1em;
}

li {
position: relative;
clear: both;
margin: 0 0 1em;
padding: 0 1em;
@extend .clearfix;

&.half-width {
float: left;
clear: none;
width: 50%;
@include box-sizing(border-box);

@media screen and (max-width: $breakpoint-small) {
float: none;
clear: both;
width: auto;
}
}
}
}

input, textarea, select { font-size: $font-size; }
input, textarea, select {
font-size: $font-size;
font-family: $font-family;
}

input[type='text'], input[type='email'], textarea {
input[type='text'], input[type='email'], input[type='number'], textarea {
@extend %input;
}

textarea {
height: auto;
line-height: 1.5em;
min-height: $padding * 2;
max-height: $padding * 8;
resize: vertical;
}

label, dt {
@extend %label;
}

.student-helper-message {
margin: .75em 0 0;
background: lightgoldenrodyellow;
border: 1px solid palegoldenrod;
color: dimgrey;
padding: .25em .75em;
font-size: .75em;
font-weight: bold;
border-radius: 2px;
}

label.error {
background: lightgoldenrodyellow;
color: lighten($black, 15%);
Expand All @@ -66,7 +111,56 @@ label.error {
legend {
color: #888;
font-weight: 700;
margin: 0 0 1em;
margin: 0 1em 1em;
}

select {
display: block;
width: 100%;
height: $padding;
border: 2px solid #ddd;
background: whitesmoke;

@media screen and (-webkit-min-device-pixel-ratio: 1) {
padding: 0 .5em;
border-radius: 2px;
background: whitesmoke image-url('select.png') no-repeat right;
-webkit-background-size: 1.5em;
background-size: 1.5em;
-webkit-background-clip: padding;
background-clip: padding-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
-webkit-appearance: none;
}
}

.credit-cards {
float: right;

.credit-card {
float: left;
margin-left: .25em;
}
}

.checkbox_field {
line-height: 1.35em;

input[type='checkbox'] {
float: left;
width: 1em;
height: 1em;
margin: .2em 0;
padding: 0;
}

label {
font-size: .95em;
text-transform: none;
font-weight: normal;
margin-left: 1.5em;
}
}

#buttons {
Expand All @@ -75,3 +169,16 @@ legend {
input, a { margin-right: .5em; }
}


#attendee_tweet_idea { padding-bottom: 1.5em; }

.char-count {
position: absolute;
bottom: 0;
right: 1em;
margin: .5em;
line-height: 1em;
color: #888;

&.limit { color: hsl(0, 100%, 65%); }
}
4 changes: 3 additions & 1 deletion app/assets/stylesheets/modules/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ html {
}

.main {
overflow-x: hidden;
overflow-y: scroll;
width: (100% / 3 * 2);
}

Expand Down Expand Up @@ -165,7 +167,7 @@ html {
height: 16em;

li {

label {
white-space: nowrap;
position: absolute;
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/api/v1/attendees_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def attendee_statistics
def created_attendees
[].tap do |collection|
supplied_attendees.each do |attendee_params|
collection << Attendee.create(attendee_params.slice("email_address", "first_name", "last_name"))
collection << Attendee.create(attendee_params.slice("email_address", "first_name", "last_name", "gender", "age",
"profession", "tweet_idea", "scholarship"))
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/attendees_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def create
private

def attendee_params
params.require(:attendee).permit(:first_name, :last_name, :email_address)
params.require(:attendee).permit(:first_name, :last_name, :email_address, :gender, :age, :profession, :tweet_idea, :scholarship)
end

end
2 changes: 1 addition & 1 deletion app/controllers/email_links_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def confirm
def decline
begin
attendee.decline!
attendee.emails.create(event: 'decline').deliver
attendee.emails.create(event: 'decline_from_user').deliver
rescue StateMachine::InvalidTransition
end
redirect_to '/', notice: message("decline")
Expand Down
14 changes: 9 additions & 5 deletions app/controllers/payments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ class PaymentsController < ApplicationController
before_action :verify_attendee, only: :new

def new
render :new, locals: { attendee: attendee, tr_data: tr_data }
@attendee = attendee
@tr_data = tr_data
@tr_data_student = tr_data(true)
render :new
end

def confirm
Expand Down Expand Up @@ -31,6 +34,7 @@ def attendee_payment_created
attendee.update_attributes first_name: result.transaction.customer_details.first_name,
last_name: result.transaction.customer_details.last_name
attendee.pay!
attendee.update_student_attribute(result.transaction.amount)
attendee.emails.create(event: 'pay').deliver
end
end
Expand All @@ -42,11 +46,11 @@ def result
@result ||= Braintree::TransparentRedirect.confirm(request.query_string)
end

def tr_data
def tr_data(student = false)
Braintree::TransparentRedirect.transaction_data(
redirect_url: confirm_payment_url,
transaction: { type: "sale",
amount: amount,
amount: amount(student),
customer: { email: attendee.email_address },
custom_fields: { attendee_pay_token: params[:token] },
options: { submit_for_settlement: true }})
Expand All @@ -64,7 +68,7 @@ def pay_token
session[:pay_token] ||= params[:token]
end

def amount
TICKET.price_in_dollars
def amount(student)
student ? TICKET.price_in_dollars_for_student : TICKET.price_in_dollars
end
end
18 changes: 17 additions & 1 deletion app/models/attendee.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class Attendee < ActiveRecord::Base
GENDERS = %w(M F)

has_many :emails, dependent: :destroy
has_many :payments, dependent: :destroy

Expand All @@ -7,7 +9,10 @@ class Attendee < ActiveRecord::Base
presence: true,
uniqueness: true,
format: { with: /\A[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}\z/i }
validates :first_name, :last_name, presence: true

validates :first_name, :last_name, :gender, :age, :profession, :tweet_idea, presence: true
validates :gender, inclusion: { in: GENDERS }, presence: true
validates :age, inclusion: { in: 5..150 }, presence: true

before_create :build_tokens

Expand Down Expand Up @@ -60,6 +65,17 @@ def full_name
"#{first_name} #{last_name}"
end

def update_student_attribute(amount)
case amount.to_i
when TICKET.price_in_dollars
update_column(:student, false)
when TICKET.price_in_dollars_for_student
update_column(:student, true)
else
raise 'Invalid amount'
end
end

private

def build_tokens
Expand Down
2 changes: 1 addition & 1 deletion app/models/email_content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def content
private

def recognised_events
%w(register invite provide_complimentary_ticket revoke_invitation pay decline remind confirm)
%w(register invite provide_complimentary_ticket revoke_invitation pay decline decline_from_user remind confirm)
end

def render_html
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/attendee_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class AttendeeSerializer < ActiveModel::Serializer
attributes :id, :email_address, :state, :round, :first_name, :last_name
attributes :id, :email_address, :state, :round, :first_name, :last_name, :gender, :age, :profession, :tweet_idea, :scholarship
end
1 change: 1 addition & 0 deletions app/views/attendees/create.js.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- if @attendee.valid?
$('body').append("<div class='flash flash-notice'>Thanks for registering!</div>");
$('#new_attendee #inputs input').val('');
$("#new_attendee #inputs textarea").val('');
- else
$('body').append("<div class='flash flash-error'>#{@attendee.errors.full_messages.join(', ')}</div>");
2 changes: 1 addition & 1 deletion app/views/emails/_confirm.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%strong{style: 'font-size: 1.5em;'}= "We'll see you there."

%p Thanks for confirming your attendence at TEDxBrisbane 2013.
%p Thanks for confirming your attendance at TEDxBrisbane 2013. We're pretty excited that we're going to be seeing you soon.

= render 'emails/email_footer'
10 changes: 8 additions & 2 deletions app/views/emails/_decline.html.haml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
You have declined your invitation to TEDxBrisbane 2013.
%p= "Hi #{attendee.first_name},"

= render 'emails/email_footer'
%p Sorry.

%p We are unable to offer you a place at this year's event due to space limitations at the venue.

%p= "We do so wish you could join us but you will be able to watch the live stream on the day at #{email_anchor('www.tedxbrisbane.com', 'http://www.tedxbrisbane.com')}"

%p We've also placed you on the waiting list and if a ticket becomes available, we will check in again and see if you are still keen to come along.

0 comments on commit 1d98b56

Please sign in to comment.