effective_events 0.21.2 → 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: 42c8639a33d8247e332a53ef4c05381e7bab279c8ad935acf137bf51442efd1c
4
- data.tar.gz: f6884ad2f0eca97360818679f50a0b5c12b24372e05c59635870aa5b13baceca
3
+ metadata.gz: 2ffd423f757ef4a0b0135bc467e8c98c46c340013b6afb6b360b9ac7c9d31dd0
4
+ data.tar.gz: 8f922c163d69b87d29d01544dbcc183004642a5828a0dd82f83a734cc13997db
5
5
  SHA512:
6
- metadata.gz: a51681eb17f796a836916eaac24ad937f2aaa907ae12f1e79019ececf54f00b0fbdf0e642db420c66a7d38c231261c0b43f897a4084cb28ce07b0935d823045b
7
- data.tar.gz: 0eaeb3437ef7e5106362051cd864a7a3f0b35602f543328af1adc30dccac734b04822146068c319dd7f9bd9f6a1ed1ee2779f2ae5cf8346490dec146df646795
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
@@ -83,6 +83,8 @@ module Effective
83
83
 
84
84
  scope :sorted, -> { order(start_at: :desc) }
85
85
 
86
+ scope :for_sitemap, -> { published }
87
+
86
88
  scope :deep, -> {
87
89
  base = includes(:event_registrants, :event_tickets, :rich_texts)
88
90
  base = base.includes(:pg_search_document) if defined?(PgSearch)
@@ -145,6 +147,7 @@ module Effective
145
147
  validates :delayed_payment, inclusion: { in: [false], message: "cannot be used for external registration events" }, if: -> { external_registration? }
146
148
  validates :delayed_payment_date, presence: true, if: -> { delayed_payment? }
147
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" }
148
151
 
149
152
  validate(if: -> { start_at && end_at }) do
150
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.2'.freeze
2
+ VERSION = '0.22.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_events
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.2
4
+ version: 0.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-18 00:00:00.000000000 Z
11
+ date: 2024-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails