trusty-festivity-extension 2.4.6 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/{traf-internalpage-bg-pattern.svg → skins/traf/traf-internalpage-bg-pattern.svg} +0 -0
  3. data/app/assets/images/{traf-internalpage-bg.svg → skins/traf/traf-internalpage-bg.svg} +0 -0
  4. data/app/assets/javascripts/modal.js +5 -4
  5. data/app/assets/stylesheets/rad_social/rad_screen.scss +154 -0
  6. data/app/assets/stylesheets/{traf-stylesheets → skins/traf}/contexts/_traf.scss +2 -2
  7. data/app/assets/stylesheets/{traf-stylesheets → skins/traf}/library/_general-mixins.scss +0 -0
  8. data/app/assets/stylesheets/{traf-stylesheets → skins/traf}/library/_icons.scss +0 -0
  9. data/app/assets/stylesheets/{traf-stylesheets → skins/traf}/library/_variables.scss +0 -0
  10. data/app/assets/stylesheets/skins/traf/skin.scss +36 -0
  11. data/app/assets/stylesheets/traf.scss +10 -5
  12. data/app/controllers/concerns/festivity_custom_page.rb +12 -0
  13. data/app/controllers/concerns/festivity_search_caching.rb +11 -0
  14. data/app/controllers/concerns/festivity_sql_builder.rb +25 -0
  15. data/app/controllers/festivity_events_controller.rb +4 -18
  16. data/app/controllers/festivity_location_areas_controller.rb +1 -3
  17. data/app/controllers/festivity_locations_controller.rb +2 -4
  18. data/app/controllers/festivity_markets_controller.rb +67 -0
  19. data/app/controllers/search_controller.rb +1 -2
  20. data/app/helpers/festivity_events_helper.rb +26 -1
  21. data/app/models/concerns/festivity_artist_methods.rb +28 -0
  22. data/app/models/festivity_event_list.rb +21 -15
  23. data/app/models/festivity_event_page.rb +3 -21
  24. data/app/models/festivity_market_list.rb +76 -0
  25. data/app/models/festivity_market_list/festivity_market_detail.rb +24 -0
  26. data/app/models/festivity_market_page.rb +7 -0
  27. data/app/views/admin/pages/_festivity_base_fields.html.haml +30 -7
  28. data/app/views/festivity_events/_filters.html.haml +1 -1
  29. data/app/views/festivity_events/show.html.haml +6 -4
  30. data/app/views/festivity_markets/_filters.html.haml +46 -0
  31. data/app/views/festivity_markets/_market.html.haml +40 -0
  32. data/app/views/festivity_markets/_market_filters.html.haml +0 -0
  33. data/app/views/festivity_markets/_market_list.html.haml +5 -0
  34. data/app/views/festivity_markets/index.html.haml +15 -0
  35. data/app/views/festivity_markets/show.html.haml +63 -0
  36. data/app/views/navigation/_subnav.html.haml +2 -1
  37. data/app/views/social/_share_modal.html.haml +10 -0
  38. data/config/routes.rb +1 -0
  39. data/db/content/layouts/base.html +178 -128
  40. data/db/migrate/201603212551012359_add_hide_from_subnav_to_pages.rb +9 -0
  41. data/db/migrate/201604025593337427_fix_typo_in_market_start.rb +13 -0
  42. data/db/migrate/201604031236563245_add_market_details_view.rb +22 -0
  43. data/db/migrate/201604031638542262_change_market_dates_to_datetime.rb +21 -0
  44. data/lib/festivity/engine.rb +1 -1
  45. data/lib/festivity/extensions/page_extensions.rb +8 -0
  46. data/lib/festivity/extensions/site_extensions.rb +5 -1
  47. data/lib/trusty-festivity-extension.rb +1 -1
  48. metadata +28 -8
@@ -1,6 +1,5 @@
1
1
  class SearchController < ApplicationController
2
- no_login_required
3
- trusty_layout 'base'
2
+ include Concerns::FestivityCustomPage
4
3
 
5
4
  def show
6
5
  query = params[:q].to_s
@@ -9,4 +9,29 @@ module FestivityEventsHelper
9
9
  performances.map {|perf| "<li>#{perf.start_date.strftime('%A, %B %d')}, #{perf.start_date.strftime('%I:%M %p').downcase} - #{perf.end_date.strftime('%I:%M %p').downcase}</li>" }.join("")
10
10
  end
11
11
 
12
- end
12
+ def social_share_message(production)
13
+ "Check out #{production.title} for #{fest_hashtag} @ #{production.locations.first.title}!"
14
+ end
15
+
16
+ def social_share_email_subject(production)
17
+ "Check out #{production.title}"
18
+ end
19
+
20
+ def social_share_email_message(production)
21
+ "I thought you might be interested in seeing #{production.title}."
22
+ end
23
+
24
+ def shared_production_url
25
+ "#{event_url}?cid=CDSocial"
26
+ end
27
+
28
+ def fest_hashtag
29
+ if @event.site_id == 3
30
+ "#TRAF"
31
+ elsif @event.site_id == 2
32
+ "#PGHkids"
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -0,0 +1,28 @@
1
+ module Concerns
2
+ module FestivityArtistMethods
3
+
4
+ include ActiveSupport::Concern
5
+
6
+ def has_social?
7
+ (has_twitter? or has_facebook? or has_homepage? or has_instagram?)
8
+ end
9
+
10
+ def has_twitter?
11
+ !self.artist_twitter.empty?
12
+ end
13
+
14
+ def has_facebook?
15
+ !self.artist_facebook.empty?
16
+ end
17
+
18
+ def has_instagram?
19
+ !self.artist_instagram.empty?
20
+ end
21
+
22
+ def has_homepage?
23
+ !self.artist_homepage.empty?
24
+ end
25
+
26
+
27
+ end
28
+ end
@@ -1,5 +1,7 @@
1
1
  class FestivityEventList
2
2
 
3
+ include Concerns::FestivitySqlBuilder
4
+
3
5
  attr_reader :events
4
6
 
5
7
  def initialize(event_performances)
@@ -27,11 +29,18 @@ class FestivityEventList
27
29
  )
28
30
  end
29
31
 
30
- def self.find_by_location(location_id)
32
+ def self.find_by_location(location_id, site)
33
+ begin
34
+ where_clause = parse_criteria(dates: collect_festival_dates(site).join(","), filter_type: site.festivity_filter_type)
35
+ rescue ActiveRecord::RecordNotFound
36
+ return FestivityEventList.new([])
37
+ end
38
+
31
39
  FestivityEventList.new(
32
40
  FestivityEventList::FestivityEventPerformance.
33
41
  includes(:assets).
34
42
  joins(:festivity_categories).
43
+ where(where_clause).
35
44
  where(location_id: location_id).
36
45
  group("performance_id").
37
46
  order("featured_item DESC, start_date ASC").
@@ -53,6 +62,16 @@ class FestivityEventList
53
62
  )
54
63
  end
55
64
 
65
+ def self.collect_festival_dates(site)
66
+ festival_dates = site.festival_datetimes
67
+ if site.date_during_festival?(Time.now)
68
+ festival_dates = festival_dates.select{ |date| date.datetime == Time.now }
69
+ end
70
+
71
+ festival_dates.map{ |date| date.to_s }
72
+
73
+ end
74
+
56
75
  private
57
76
 
58
77
  # Return a list of unique event ids that match the provided dates
@@ -63,6 +82,7 @@ class FestivityEventList
63
82
  # Create a condition for start and end date between midnight and 11:59pm
64
83
  # for each date passed in and return the SQL condition
65
84
  def self.datetime_criteria(datetimes_string, filter_type)
85
+
66
86
  date_queries = datetimes_string.split(',').map do |date_string|
67
87
  start_date = Chronic.parse(URI.decode(date_string)).utc
68
88
  end_date = start_date.advance(advance_by(filter_type))
@@ -77,11 +97,6 @@ class FestivityEventList
77
97
  date_queries.join(" OR ")
78
98
  end
79
99
 
80
- def self.advance_by(filter_type)
81
- advance_by_hash = {minutes: 59}
82
- advance_by_hash[:hours] = 23 if filter_type == "date"
83
- advance_by_hash
84
- end
85
100
 
86
101
  # The order of querying, depending on what is passed:
87
102
  # - If dates are passed, we search both start and end date between midnight and 11:59pm of that date.
@@ -100,15 +115,6 @@ class FestivityEventList
100
115
  where_clause
101
116
  end
102
117
 
103
- def self.parse_categories(category_ids)
104
- grouped_ids = FestivityCategory.find(category_ids).group_by {|category| category.festivity_category_type}
105
- category_clauses = grouped_ids.map do |categories|
106
- "page_id IN (SELECT page_id FROM festivity_page_categories WHERE festivity_category_id IN (#{categories[1].map {|category| category.id}.join(",")}))"
107
- end
108
- "(#{category_clauses.join(" AND ")})"
109
-
110
- end
111
-
112
118
 
113
119
  end
114
120
 
@@ -3,6 +3,8 @@ class FestivityEventPage < FestivityBasePage
3
3
  has_many :festivity_page_categories, foreign_key: :page_id
4
4
  has_many :festivity_categories, through: :festivity_page_categories
5
5
 
6
+ include Concerns::FestivityArtistMethods
7
+
6
8
  def festivity_performances=(performances)
7
9
  performances.each do |performance|
8
10
  performance_id = performance.delete(:performance_id)
@@ -26,26 +28,6 @@ class FestivityEventPage < FestivityBasePage
26
28
  !self.buy_url.empty?
27
29
  end
28
30
 
29
- def has_social?
30
- (has_twitter? or has_facebook? or has_homepage? or has_instagram?)
31
- end
32
-
33
- def has_twitter?
34
- !self.artist_twitter.empty?
35
- end
36
-
37
- def has_facebook?
38
- !self.artist_facebook.empty?
39
- end
40
-
41
- def has_instagram?
42
- !self.artist_instagram.empty?
43
- end
44
-
45
- def has_homepage?
46
- !self.artist_homepage.empty?
47
- end
48
-
49
31
  def event_locations
50
32
  # Return array of unique locations
51
33
  self.performances.
@@ -54,4 +36,4 @@ class FestivityEventPage < FestivityBasePage
54
36
  end
55
37
 
56
38
 
57
- end
39
+ end
@@ -0,0 +1,76 @@
1
+ class FestivityMarketList
2
+
3
+ include Concerns::FestivitySqlBuilder
4
+
5
+ attr_reader :markets
6
+
7
+
8
+ def initialize(market_details)
9
+ @markets = market_details
10
+ end
11
+
12
+ def self.search(criteria, order_by)
13
+ begin
14
+ where_clause = parse_criteria(criteria)
15
+ rescue ActiveRecord::RecordNotFound
16
+ return FestivityMarketList.new([])
17
+ end
18
+
19
+ # where in market ids
20
+ FestivityMarketList.new(
21
+ FestivityMarketList::FestivityMarketDetail.
22
+ includes(:assets).
23
+ joins(:festivity_categories).
24
+ where(where_clause).
25
+ order("#{order_by} ASC").
26
+ preload(:festivity_categories)
27
+ )
28
+ end
29
+
30
+
31
+ private
32
+
33
+
34
+ # Return a list of unique market ids that match the provided dates
35
+ def self.market_ids_for_datetimes(datetimes, filter_type)
36
+ FestivityMarketList::FestivityMarketDetail.where(datetime_criteria(datetimes, filter_type)).map {|e| e.market_id}.uniq
37
+ end
38
+
39
+ # Create a condition for start and end date between midnight and 11:59pm
40
+ # for each date passed in and return the SQL condition
41
+ def self.datetime_criteria(datetimes_string, filter_type)
42
+
43
+ date_queries = datetimes_string.split(',').map do |date_string|
44
+ start_date = Chronic.parse(URI.decode(date_string)).utc
45
+ end_date = start_date.advance(advance_by(filter_type))
46
+ <<-SQL
47
+ (
48
+ (start_date <= '#{start_date}' AND end_date >= '#{end_date}')
49
+ OR
50
+ (end_date >= '#{start_date}' AND start_date <= '#{end_date}')
51
+ )
52
+ SQL
53
+ end
54
+ date_queries.join(" OR ")
55
+ end
56
+
57
+
58
+ # The order of querying, depending on what is passed:
59
+ # - If dates are passed, we search both start and end date between midnight and 11:59pm of that date.
60
+ # That query returns any matching market ids.
61
+ # - The market ids returned, if any, are added to the where clause for the next query
62
+ # - Any category ids passed are added to the where clause as well.
63
+
64
+ def self.parse_criteria(criteria)
65
+ if criteria[:dates]
66
+ market_ids = market_ids_for_datetimes(criteria[:dates], criteria[:filter_type])
67
+ raise ActiveRecord::RecordNotFound unless market_ids.any?
68
+ end
69
+
70
+ where_clause = "site_id = #{ Page.current_site.id}"
71
+ where_clause += " AND market_id IN (#{market_ids.join(",")})" if market_ids.present?
72
+ where_clause += " AND #{parse_categories(criteria[:categories].split(","))}" if criteria[:categories]
73
+ where_clause
74
+ end
75
+
76
+ end
@@ -0,0 +1,24 @@
1
+ class FestivityMarketList::FestivityMarketDetail < ActiveRecord::Base
2
+ self.table_name = 'festivity_market_details'
3
+ after_initialize :readonly!
4
+
5
+ has_many :festivity_page_categories, foreign_key: :page_id, primary_key: :market_id
6
+ has_many :festivity_categories, through: :festivity_page_categories
7
+ has_many :page_attachments, primary_key: :market_id, foreign_key: :page_id
8
+ has_many :assets, through: :page_attachments
9
+
10
+
11
+ def id
12
+ market_id
13
+ end
14
+
15
+ def categories
16
+ festivity_categories
17
+ end
18
+
19
+ def image
20
+ image = assets.select { |asset| asset.title == "featured_image" }.first if assets.size > 0
21
+ image.thumbnail(:normal) unless image.nil?
22
+ end
23
+
24
+ end
@@ -1,3 +1,10 @@
1
1
  class FestivityMarketPage < FestivityBasePage
2
2
 
3
+ include Concerns::FestivityArtistMethods
4
+ has_many :festivity_categories, through: :festivity_page_categories
5
+
6
+ def area
7
+ FestivityLocationAreaPage.find(area_id)
8
+ end
9
+
3
10
  end
@@ -7,6 +7,10 @@
7
7
  %label{for: "page_short_description"}
8
8
  Short Description
9
9
  = self.text_area( :page, :short_description, class: "textbox festivity-control", rows: 4)
10
+ %p.festivity-third
11
+ %label{for: "page_featured_item"}
12
+ Do Not Show In Sub-Navigation
13
+ = self.check_box( :page, :hide_from_subnav, class: "textbox festivity-control")
10
14
 
11
15
  - if @page.is_a?(FestivityBasePage) && @page.id
12
16
 
@@ -17,8 +21,9 @@
17
21
  - if @page.status_id == Status[:published].id
18
22
  %p.festivity-full
19
23
  View page:
20
- = link_to "http://#{@page.site.base_domain}#{event_path(@page)}" do
21
- = "http://#{@page.site.base_domain}#{event_path(@page)}"
24
+ - path = @page.is_a?(FestivityMarketPage) ? market_path(@page) : event_path(@page)
25
+ = link_to "http://#{@page.site.base_domain}#{path}" do
26
+ = "http://#{@page.site.base_domain}#{path}"
22
27
  %p.festivity-full
23
28
  %label{for: "page_short_description"}
24
29
  Short Description
@@ -35,10 +40,11 @@
35
40
  %label{for: "page_featured_item"}
36
41
  Featured
37
42
  = self.check_box( :page, :featured_item, class: "textbox festivity-control")
38
- %p.festivity-third
39
- %label{for: "page_buy_url"}
40
- Buy Tickets URL
41
- = self.text_field( :page, :buy_url, class: "textbox festivity-control")
43
+ - if @page.is_a?(FestivityEventPage)
44
+ %p.festivity-third
45
+ %label{for: "page_buy_url"}
46
+ Buy Tickets URL
47
+ = self.text_field( :page, :buy_url, class: "textbox festivity-control")
42
48
 
43
49
  .festivity-div.festivity-title
44
50
  %h4
@@ -66,7 +72,24 @@
66
72
  %span{class: "fa fa-wrench fa-lg", aria: {hidden: "true"}}
67
73
  Performances
68
74
  = render partial: "admin/pages/partials/performances", locals: {performances: @page.festivity_performances, page_id: @page.id}
69
-
75
+ - if @page.is_a?(FestivityMarketPage)
76
+ - areas = FestivityLocationAreaPage.where(site_id: @page.site.id)
77
+ %p.festivity-third
78
+ %label{for: "page_market_start_date"}
79
+ Start Date
80
+ = self.text_field :page, :market_start_date, :class=> "date_field textbox date festivity-control", :value => (@page.market_start_date ? format_date(@page.market_start_date) : nil)
81
+ %p.festivity-third
82
+ %label{for: "page_market_end_date"}
83
+ End Date
84
+ = self.text_field :page, :market_end_date, :class=> "date_field textbox date festivity-control", :value => (@page.market_end_date ? format_date(@page.market_end_date) : nil)
85
+ %p.festivity-third
86
+ %label{for: "page_booth_number"}
87
+ Booth Number
88
+ = self.text_field(:page, :booth_number, class: "textbox festivity-control")
89
+ %p.festivity-third
90
+ %label{for: "page_booth_number"}
91
+ Area
92
+ = self.select :page, :area_id, options_from_collection_for_select(areas, "id", "title", @page.area_id), :class=> "textbox festivity-control"
70
93
 
71
94
  .festivity-div.festivity-title
72
95
  %h4
@@ -20,7 +20,7 @@
20
20
  %label{for: datetime.to_s}
21
21
  %input.input-checkbox{type: "checkbox", id: datetime.to_s, value: datetime.to_s, checked: checked, data: {filter: "Date", sort: datetime.to_s}}
22
22
  = datetime.display
23
- - current_site.festivity_active_category_types.each do |type|
23
+ - current_site.festivity_active_category_types_for("FestivityEventPage").each do |type|
24
24
  .filter-type.toggler-root
25
25
  %h4.filter-category.toggler-trigger{aria: {expanded: "false", controls: 'filters-list'}}
26
26
  %span.category-text
@@ -1,3 +1,5 @@
1
+ = javascript_include_tag "modal"
2
+
1
3
  %header.page-header
2
4
  %h1.page-title
3
5
  = @event.title
@@ -33,10 +35,10 @@
33
35
  %li
34
36
  %a{target: "_blank", href: "#{@event.locations.first.festivity_directions_url}"}
35
37
  Get Directions
36
- -# TODO: Get the modal working.
37
- -#%li
38
- -# %a{href: "#", data: {toggle:"modal", target:"#share-modal"}}
39
- -# Share This
38
+ %li
39
+ %a.modal-link{href: "#"}
40
+ Share This
41
+ = render partial: 'social/share_modal', locals: {event_page: @event, url: shared_production_url}
40
42
 
41
43
  %aside.secondary-content
42
44
  - if @event.can_buy?
@@ -0,0 +1,46 @@
1
+ - current_date = FestivityDatetimePresenter.new current_site.festival_datetimes.first.datetime - 1.day
2
+ %section.filters-wrapper
3
+ %h3.title Filters
4
+ %form.filters{:action => "#"}
5
+ .filter-type.toggler-root
6
+ %h4.filter-category.toggler-trigger{aria: {expanded: "false", controls: 'filters-list'}}
7
+ %span.category-text
8
+ Dates
9
+ %span.icon-chevron-down{:data => {'grunticon-embed' => true}}
10
+ %span.visually-hidden
11
+ Open/Close Filters
12
+ .toggler-content.filters-list{aria: {hidden: "true"}}
13
+ %ul.date-filters
14
+ - current_site.festival_datetimes.each do |datetime|
15
+ - checked = selected_dates.any? {|selected_date| selected_date == datetime}
16
+ %li
17
+ %label{for: datetime.to_s}
18
+ %input.input-checkbox{type: "checkbox", id: datetime.to_s, value: datetime.to_s, checked: checked, data: {filter: "Date", sort: datetime.to_s}}
19
+ = datetime.display
20
+ - current_site.festivity_active_category_types_for("FestivityMarketPage").each do |type|
21
+ .filter-type.toggler-root
22
+ %h4.filter-category.toggler-trigger{aria: {expanded: "false", controls: 'filters-list'}}
23
+ %span.category-text
24
+ = type.name
25
+ %span.icon-chevron-down{:data => {'grunticon-embed' => true}}
26
+ %span.visually-hidden
27
+ Open/Close Filters
28
+ .toggler-content.filters-list{aria: {hidden: "true"}}
29
+ %ul.category-filters
30
+ - type.parent_categories.each do |parent|
31
+ - checked = selected_categories.include? parent.id.to_s
32
+ %li
33
+ %label{for: parent.id}
34
+ %input.input-checkbox{type: "checkbox", id: parent.id, value: parent.id, data: {filter: type.name, sort: parent.name.downcase}, checked: checked}
35
+ = parent.name
36
+
37
+ - if parent.children.any?
38
+ %ul
39
+ - parent.children.each do |child|
40
+ - checked = selected_categories.include? child.id.to_s
41
+ %li
42
+ %label{for: child.id}
43
+ %input.input-checkbox{type: "checkbox", id: child.id, value: child.id, data: {filter: type.name, sort: child.name.downcase}, checked: checked}
44
+ = child.name
45
+ %a.cancel-filters Cancel
46
+ %a.submit-filters Filter
@@ -0,0 +1,40 @@
1
+ - show_dates ||= false
2
+
3
+ %article.event
4
+ - if market.image
5
+ .event-media
6
+ = image_tag market.image
7
+ - if market.featured_item
8
+ %span.is-featured
9
+ Featured Event!
10
+
11
+ .event-body
12
+ %h3.event-title
13
+ = link_to market_path(market.id) do
14
+ = market.market_title
15
+ - if market.header
16
+ %h4.event-subtitle
17
+ = market.header
18
+ - if market.sub_header
19
+ = market.sub_header
20
+
21
+ .event-location
22
+ = link_to area_path(id: market.area_slug) do
23
+ = market.area_title
24
+
25
+ - if show_dates
26
+ .event-date
27
+ %span.time
28
+ = market.start_date.strftime("%A, %B %d")
29
+ = " - "
30
+ = market.end_date.strftime("%A, %B %d")
31
+
32
+ .event-description
33
+ %p
34
+ %span.event-genre
35
+ = market.categories.first.name
36
+ = market.short_description
37
+ .event-tags-group
38
+ %ul.event-tags
39
+ %li
40
+ = link_to "Details", market_path(market.id)