Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ft event find insights 129622087 #191

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added app/assets/images/Facebook_icon.jpg
Loading
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/Twitter_image.jpg
Loading
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/facebook_image.jpg
Loading
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/friend-source.jpg
Loading
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/google_image.jpg
Loading
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/question-mark.jpg
Loading
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/search_image.jpg
Loading
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/television_image.jpg
Loading
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/television_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions app/assets/stylesheets/application.css.scss.erb
Original file line number Diff line number Diff line change
Expand Up @@ -381,3 +381,14 @@ td, th {
text-align: center;
padding: 10px;
}

input[type=text].modal-text {
height: 1.8rem;
}

.modal-radio[type="radio"]:not(:checked),
.modal-radio[type="radio"]:checked {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checked and not(:checked) are mutually exclusive. No need to specify the two... this could easily be .modal-radio[type="radio"]

left: 2px;
position: relative;
opacity: 1;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can try to leverage more on SCSS syntax for better performance in .scss files

11 changes: 10 additions & 1 deletion app/controllers/bookings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def create
tickets = []
ticket_params.each do |ticket_type_id, quantity|
quantity.to_i.times do
user = UserTicket.new(ticket_type_id: ticket_type_id, booking: @booking)
user = UserTicket.new(ticket_type_id: ticket_type_id, booking: @booking,
event_source: source_params)
tickets << user
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is way too much going on in this controller action which can be moved to the model... ( lean controllers fat models )

end
Expand Down Expand Up @@ -104,6 +105,14 @@ def ticket_params
params.require(:tickets_quantity)
end

def source_params
params.permit(:event_source, :other)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the need for params.permit... here, given that the returned is later manipulated to give the required params[:event_source] ?

if params[:event_source] == "Other"
params[:event_source] = params[:other] unless params[:other].blank?
end
params[:event_source]
end

def set_event
@event = Event.find(params[:event_id])
end
Expand Down
4 changes: 4 additions & 0 deletions app/views/bookings/partials/_all_bookings.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<th data-field="amount">Amount</th>
<th data-field="ticket">Number of Tickets</th>
<th>TicketID</th>
<th>Event Source</th>

</tr>
</thead>
<tbody>
Expand All @@ -23,6 +25,8 @@
<td><%= number_to_currency booking.amount %></td>
<td><%= booking.user_tickets_count %></td>
<td><%= booking.uniq_id %></td>
<% event_source = booking.user_tickets.first.event_source %>
<td class="<%= event_source %>"><%= event_source %></td>
</tr>
<% end %>
</tbody>
Expand Down
38 changes: 37 additions & 1 deletion app/views/events/_ticket_purchase_modal.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,44 @@
<div class="modal" id="purchase_ticket_modal">
<div class="modal-content row">
Buy tickets
<%= form_for @booking, url: event_bookings_path(@event) do |f| %>
<%#= f.text_field :ticket_type %>
<div class="col l12 m12">
<h6>How did you find this event?</h6>
<hr>
<div class="col l2 m4">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NITPICK: Indentation here can be better.

<%= image_tag "Twitter_image.jpg" %><br>
<%= label_tag "event_source", "Twitter" %>
<%= radio_button_tag("event_source", "Twitter", false, class: "modal-radio") %>
</div>
<div class="col l2 m4">
<%= image_tag "facebook_image.jpg" %><br>
<%= label_tag "event_source", "Facebook" %>
<%= radio_button_tag("event_source", "Facebook", false, class: "modal-radio") %>
</div>
<div class="col l2 m4">
<%= image_tag "google_image.jpg" %><br>
<%= label_tag "event_source", "Google" %>
<%= radio_button_tag("event_source", "Google", false, class: "modal-radio") %>
</div>
<div class="col l2 m4">
<%= image_tag "friend-source.jpg" %><br>
<%= label_tag "event_source", "Friend" %>
<%= radio_button_tag("event_source", "Friend", false, class: "modal-radio") %>
</div>
<div class="col l2 m4">
<%= image_tag "television_image.jpg" %><br>
<%= label_tag "event_source", "TV / Radio" %>
<%= radio_button_tag("event_source", "TV / Radio", false, class: "modal-radio") %>
</div>
<div class="col l2 m4">
<%= image_tag "question-mark.jpg" %><br>
<%= label_tag "event_source", "Other" %>
<%= radio_button_tag("event_source", "Other", false, class: "modal-radio") %>
<%= text_field_tag("other", "", class: "modal-text") %>
</div>
</div>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NITPICK: Indentation on this div block can be better.

<hr>
<!-- Buy tickets<br> -->
<%= f.fields_for :user_tickets do |attendee| %>
<%= render "user_ticket_fields", f: attendee %>
<% end %>
Expand Down
11 changes: 11 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
"https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.9.0/lodash.js",
"data-turbolinks-track" => false %>

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-84136841-1', 'auto');
ga('send', 'pageview');
</script>


<%= csrf_meta_tags %>
<% if @event && @event.id %>
<%
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20160926123059_add_event_source_to_user_ticket.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddEventSourceToUserTicket < ActiveRecord::Migration
def change
add_column :user_tickets, :event_source, :string
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160614215417) do
ActiveRecord::Schema.define(version: 20160926123059) do

create_table "attendees", force: :cascade do |t|
t.integer "user_id"
Expand Down Expand Up @@ -204,6 +204,7 @@
t.datetime "time_used"
t.integer "scanned_by"
t.boolean "transfered", default: false
t.string "event_source"
end

add_index "user_tickets", ["booking_id"], name: "index_user_tickets_on_booking_id"
Expand Down

Large diffs are not rendered by default.

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
3 changes: 3 additions & 0 deletions spec/factories/user_tickets.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FactoryGirl.define do
factory :user_ticket do
ticket_number "MyString"
event_source "Facebook"
booking_id 1
ticket_type_id 1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look into using Faker for getting random attributes here. I can see that it's already included into the project.

end
end
2 changes: 1 addition & 1 deletion spec/features/attending_events_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

scenario "User tries to attend past Event" do
visit events_path
find_link("Old Event").trigger("click")
click_link"Old Event"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space between click_link and "Old Event"

expect(page).not_to have_content "ATTEND THIS EVENT"
expect(page).to have_content "This event has ended"
end
Expand Down
3 changes: 3 additions & 0 deletions spec/features/grant_refund_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
amount: 20,
refund_requested: true
)
create :user_ticket
visit "/events/#{@event.id}/tickets-report"
expect(page).to have_content "Grant Refund"
end
Expand All @@ -36,6 +37,8 @@
amount: 20,
refund_requested: true
)
create :user_ticket
create :ticket_type
visit "/events/#{@event.id}/tickets-report"
click_link "Grant Refund"
expect(page).to have_content "Refund Paid"
Expand Down
19 changes: 19 additions & 0 deletions spec/features/tickets_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,23 @@
)
end
end

scenario "Event manger clicks to view Event Source" do
visit tickets_report_path(@event.id)
expect(page.current_path).to eq tickets_report_path(@event.id)
page_should_have_content(
["Tickets", "Grand Total", "SUMMARY", "ALL BOOKINGS", "ATTENDEES"]
)
click_link "All Bookings"
within "#bookings_table thead" do
page_should_have_content(
["Event Source"]
)
end
within "#bookings_table tbody" do
page_should_have_content(
["Facebook"]
)
end
end
end
6 changes: 3 additions & 3 deletions spec/features/updating_event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
fill_in "event[title]", with: "This is an edited Event"
fill_in "event[location]", with: "Obodo, Oyibo"
fill_in "event[venue]", with: "LAmity"
click_link "Next"
find_link("Next").trigger("click")

click_link "Preview"
click_button "Save"
find_link("Preview").trigger("click")
find_button("Save").trigger("click")
expect(page).to have_content "This is an edited Event"
expect(page).to have_content update_successful_message("event")
expect(page.current_path).to eq "/events/1"
Expand Down