effective_events 0.21.3 → 0.22.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbe445b12eeae75aaa1e672a4f9e052e2b99d9216462dcd9bfc1a0f4bc27e7ca
4
- data.tar.gz: 6e7c8f3e438c8893cfa56d5a12a85bfbc2a06f353336bb1d5a6ed4ae763396d7
3
+ metadata.gz: 2ffd423f757ef4a0b0135bc467e8c98c46c340013b6afb6b360b9ac7c9d31dd0
4
+ data.tar.gz: 8f922c163d69b87d29d01544dbcc183004642a5828a0dd82f83a734cc13997db
5
5
  SHA512:
6
- metadata.gz: 4c5d4df026688410610707a911a9e1f3afddc2735eeca7bd4223d3afc00c2a763a4359f766406b30578062194fc1e291f70631fe00750ba305ab5eec72558a1b
7
- data.tar.gz: fbc9a5490824c926586f2178a47e321b93cea0b8bcb8935bd7fdcb7b10d500c6c18ad4d5f37f9ed6713f8699ecc50438ae76ca07cafef0fde47de767c9231ec0
6
+ metadata.gz: ed5b26cf2b8439c5758f3239bcf0ad2fc1de166aa56e5983837c2c5e627e8ce50dd676b08b99675ebafc7eceaf88bb03cf2fd5e17c5912214250d1a2f8223423
7
+ data.tar.gz: 683aff5ed150fb225e481d5c45701e7651e1691f0ac7d9cac0f54387f4b437f481ef707ced4f6b4adc696fc2423e153820e0d1c5e82b8f8c7e7ed44d662c7f0a
@@ -0,0 +1,3 @@
1
+ .effective-event-past {
2
+ margin-bottom: 1rem;
3
+ }
@@ -8,13 +8,19 @@ module Effective
8
8
  }
9
9
 
10
10
  def index
11
- if event_category.present?
11
+ EffectiveResources.authorize!(self, :index, Effective::Event)
12
+
13
+ # Page Title
14
+ if event_category.blank?
15
+ @page_title = "Upcoming #{EffectiveResources.ets(Effective::Event)}"
16
+ elsif event_category == 'past'
17
+ @page_title = "Past #{EffectiveResources.ets(Effective::Event)}"
18
+ elsif event_category.present?
12
19
  @page_title = event_category
13
20
  @event_category = event_category
14
21
  else
15
- @page_title ||= view_context.events_name_label
22
+ @page_title = view_context.events_name_label
16
23
  end
17
- EffectiveResources.authorize!(self, :index, Effective::Event)
18
24
 
19
25
  # Sometimes we just display a Datatable for the events
20
26
  @datatable = EffectiveResources.best('EffectiveEventsDatatable').new
@@ -57,7 +63,7 @@ module Effective
57
63
 
58
64
  def event_category
59
65
  return nil unless params[:category].present?
60
- EffectiveEvents.categories.find { |category| category.parameterize == params[:category] }
66
+ (Array(EffectiveEvents.categories) + ['past']).find { |category| category.parameterize == params[:category] }
61
67
  end
62
68
 
63
69
  def search_params
@@ -147,6 +147,7 @@ module Effective
147
147
  validates :delayed_payment, inclusion: { in: [false], message: "cannot be used for external registration events" }, if: -> { external_registration? }
148
148
  validates :delayed_payment_date, presence: true, if: -> { delayed_payment? }
149
149
  validates :delayed_payment_date, absence: true, unless: -> { delayed_payment? }
150
+ validates :slug, exclusion: { in: Array(EffectiveEvents.categories) + ['past'], message: "must not match a category name or past" }
150
151
 
151
152
  validate(if: -> { start_at && end_at }) do
152
153
  errors.add(:end_at, 'must be after start date') unless start_at < end_at
@@ -16,7 +16,7 @@ module Effective
16
16
 
17
17
  # Base collection to search.
18
18
  def collection
19
- Event.events(user: current_user, unpublished: unpublished).upcoming
19
+ Event.events(user: current_user, unpublished: unpublished)
20
20
  end
21
21
 
22
22
  def per_page
@@ -55,13 +55,16 @@ module Effective
55
55
  events = collection()
56
56
  raise('expected an ActiveRecord collection') unless events.kind_of?(ActiveRecord::Relation)
57
57
 
58
+ # Filter by upcoming or past
59
+ events = (category == 'past') ? events.past : events.upcoming
60
+
58
61
  # Filter by term
59
62
  if term.present?
60
63
  events = Effective::Resource.new(events).search_any(term)
61
64
  end
62
65
 
63
66
  # Filter by category
64
- if category.present?
67
+ if category.present? && category != 'past'
65
68
  events = events.where(category: category)
66
69
  end
67
70
 
@@ -1,6 +1,7 @@
1
1
  .effective-event-sidebar
2
2
  %ul.nav.flex-column{role: 'navigation'}
3
- = nav_link_to('All Events', effective_events.events_path, class: "effective-event-all")
3
+ = nav_link_to("Upcoming #{ets(Effective::Event)}", effective_events.events_path, class: "effective-event-all")
4
+ = nav_link_to("Past #{ets(Effective::Event)}", effective_events.events_path + '/past', class: "effective-event-past")
4
5
 
5
6
  - EffectiveEvents.categories.each do |category|
6
7
  = nav_link_to(category, effective_events.events_path + '/' + category.parameterize, class: "effective-event-#{category.parameterize}")
data/config/routes.rb CHANGED
@@ -10,7 +10,7 @@ EffectiveEvents::Engine.routes.draw do
10
10
 
11
11
  # Event Category routes
12
12
  match 'events/:category', to: 'events#index', via: :get, constraints: lambda { |req|
13
- EffectiveEvents.categories.map(&:parameterize).include?(req.params['category'])
13
+ (EffectiveEvents.categories.map(&:parameterize) + ['past']).include?(req.params['category'])
14
14
  }
15
15
 
16
16
  match "events/:category/:id", to: 'events#show', via: :get, constraints: lambda { |req|
@@ -1,3 +1,3 @@
1
1
  module EffectiveEvents
2
- VERSION = '0.21.3'.freeze
2
+ VERSION = '0.22.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_events
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.3
4
+ version: 0.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect