effective_events 0.21.3 → 0.22.1

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: af4ffee3a1a64a15a48d9e7ff3ce8eecd6b8f5759fccb0c886e9f943fd42f919
4
+ data.tar.gz: c184b3851caea22f826b685c4fc2a0db174f1b99a218f59deeb1edaad7a90694
5
5
  SHA512:
6
- metadata.gz: 4c5d4df026688410610707a911a9e1f3afddc2735eeca7bd4223d3afc00c2a763a4359f766406b30578062194fc1e291f70631fe00750ba305ab5eec72558a1b
7
- data.tar.gz: fbc9a5490824c926586f2178a47e321b93cea0b8bcb8935bd7fdcb7b10d500c6c18ad4d5f37f9ed6713f8699ecc50438ae76ca07cafef0fde47de767c9231ec0
6
+ metadata.gz: 729e826bfdbe9b0287a87b00f2168791c7b861feb2cbd10e678706ea83876d1bdd638f6e6e18c90b8795bf9058b65c8c2396dda7e47901bfe5962e4071678fe7
7
+ data.tar.gz: acf5fc1714ad5b37e9ebf9b0aa56dc3eaf83129059d54a5a9cf16da2edb4f2127cb35ca317d521e14fb171717ba2d95851fb7ea7b17aa1df6c81ec041dbf0caf
@@ -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
@@ -75,7 +75,7 @@ module Admin
75
75
  end
76
76
 
77
77
  collection do
78
- scope = Effective::EventRegistrant.deep.registered
78
+ scope = Effective::EventRegistrant.deep.all
79
79
 
80
80
  if attributes[:event_id].present?
81
81
  scope = scope.where(event: event)
@@ -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.1'.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.3
4
+ version: 0.22.1
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-29 00:00:00.000000000 Z
11
+ date: 2024-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails