Skip to content

Commit

Permalink
Deals pages improved
Browse files Browse the repository at this point in the history
  • Loading branch information
juanroldan1989 committed Mar 12, 2017
1 parent dfb291a commit c85b87f
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 31 deletions.
2 changes: 1 addition & 1 deletion app/controllers/deals_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Check combined deals including different events
class DealsController < ApplicationController

# filter's order is important
has_scope :by_type, as: :deal_type
has_scope :by_price, as: :price
has_scope :by_keywords, as: :keywords, type: :array
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ module ApplicationHelper

def deal_price_text(deal)
if deal.price.to_i > 0
"<b>#{deal.deal_type.camelize} deal for $#{deal.price}</b>".html_safe
"#{deal.deal_type.camelize} deal for $#{deal.price}".html_safe
else
"<b>#{deal.price_text.first}</b>".html_safe
"#{deal.price_text.first}".html_safe
end
end
end
8 changes: 4 additions & 4 deletions app/models/deal.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class Deal < ActiveRecord::Base

KEYWORDS = {
hotels_tours:
hotels:
%w( hotel tour accommodation house lodge bed breakfast hostel apart
pension posada inn),
beaches_fun:
beaches:
%w( beach fun seaside seashore shore coast seaboard water sand
party night club),
drinks_food:
drinks:
%w( drink food alcohol tipple bottle booze beer pizza bar eat cocktail
cook baking bake cuisine refreshment meal ration store meat)
}
Expand All @@ -20,7 +20,7 @@ class Deal < ActiveRecord::Base

scope :by_date, -> { order("created_at DESC") }
# scope :by_start_date, -> { order("created_at DESC") }
scope :by_price, -> { order("price ASC") }
scope :by_price, -> { order("price DESC") }
scope :by_price_higher_than, -> (price) { where("price >= ?", price) }
scope :by_price_lower_than , -> (price) { where("price <= ?", price) }
scope :by_type, -> (type) { where(deal_type: type) }
Expand Down
2 changes: 1 addition & 1 deletion app/services/event_finda/format_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class FormatEvent < Struct.new(:event)
def call
{
title: event["name"],
description: [event["description"]],
description: event["description"],
deal_type: "single",
price_text: [price_text],
price: price,
Expand Down
3 changes: 2 additions & 1 deletion app/views/deals/_deal.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<a href="/deals/<%= deal.slug %>" data-transition="slide">
<img src="<%= deal.image_urls.first %>" class="listing">
<h2><%= deal.title.html_safe %></h2>
<p><%= deal_price_text(deal) %></p>
<p><strong><%= deal_price_text(deal) %></strong></p>
<p><%= deal.description.first.html_safe %></p>
</a>
</li>
26 changes: 6 additions & 20 deletions app/views/deals/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,19 @@
<div data-role="page" data-title="Deals in Auckland">
<div role="main" class="ui-content jqm-content jqm-fullwidth">

<fieldset data-role="controlgroup" data-type="horizontal">
<input type="radio" name="price-radio" data-behavior="price-filter" id="price-radio-50" value="50">
<label for="price-radio-50">$50</label>
<input type="radio" name="price-radio" data-behavior="price-filter" id="price-radio-100" value="100">
<label for="price-radio-100">$100</label>
<input type="radio" name="price-radio" data-behavior="price-filter" id="price-radio-150" value="150">
<label for="price-radio-150">$150</label>
<input type="radio" name="price-radio" data-behavior="price-filter" id="price-radio-200" value="200">
<label for="price-radio-200">$200</label>
</fieldset>

<fieldset data-role="controlgroup">
<input type="checkbox" data-behavior="keywords-filter" id="keywords_1" data-value="hotels_tours">
<label for="keywords_1">Hotels & Tours</label>
<input type="checkbox" data-behavior="keywords-filter" id="keywords_2" data-value="beaches_fun">
<label for="keywords_2">Beaches & Fun</label>
<input type="checkbox" data-behavior="keywords-filter" id="keywords_3" data-value="drinks_food">
<label for="keywords_3">Drinks & Food</label>
</fieldset>
<%= render partial: "shared/filters", locals: { section: "deals" } %>

<br/>

<div id="loader"></div>

<ul id="results" data-role="listview" data-inset="false">
<ul id="deals" data-role="listview" data-inset="false">
<%= render partial: collection %>
</ul>

</div><!-- /content -->
</div><!-- /page -->

<!-- For JS filters -->
<div id="section">deals</div>
<!-- For JS filters -->
4 changes: 2 additions & 2 deletions app/views/deals/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
</h4>

<img src="<%= @deal.image_urls[0] %>" class="show">
<p><%= @deal.description[0] %></p>
<p><%= @deal.description[0].html_safe %></p>
<a href="<%= @deal.links[0] %>" class="ui-btn ui-icon-action ui-btn-icon-left ui-shadow ui-corner-all" target="blank">Check on website</a>

<% if @deal.is_combined? %>
<br/>

<img src="<%= @deal.image_urls[1] %>" class="show">
<p><%= @deal.description[1] %></p>
<p><%= @deal.description[1].html_safe %></p>
<a href="<%= @deal.links[1] %>" class="ui-btn ui-icon-action ui-btn-icon-left ui-shadow ui-corner-all" target="blank">Check on website</a>
<% end %>

Expand Down

0 comments on commit c85b87f

Please sign in to comment.