Cleaning up code
This commit is contained in:
parent
3cbbad9328
commit
34114bcdea
@ -1,5 +1,6 @@
|
||||
# Resume of all events over a period of time
|
||||
# A digest of all events over a period of time
|
||||
class DigestsController < ApplicationController
|
||||
has_scope :moderated, default: nil, allow_blank: true
|
||||
has_scope :region, :locality, :tag
|
||||
has_scope :period, allow_blank: true,
|
||||
type: :hash, using: [:year, :week],
|
||||
@ -22,6 +23,6 @@ class DigestsController < ApplicationController
|
||||
|
||||
def set_events
|
||||
@week ||= Time.zone.today + 7.days
|
||||
@events = apply_scopes Event.moderated
|
||||
@events = apply_scopes Event
|
||||
end
|
||||
end
|
||||
|
@ -30,8 +30,8 @@ class Event < ActiveRecord::Base
|
||||
after_update EventCallbacks
|
||||
after_destroy EventCallbacks
|
||||
|
||||
scope :moderated, -> { where moderated: true }
|
||||
scope :unmoderated, -> { where moderated: false }
|
||||
scope :moderated, ->(*) { where moderated: true }
|
||||
scope :unmoderated, ->(*) { where moderated: false }
|
||||
scope :last_year, -> { where '? <= end_time', 1.year.ago }
|
||||
scope :past, -> { where 'start_time <= ?', Time.zone.now }
|
||||
scope :future, -> { where '? <= end_time', Time.zone.now }
|
||||
|
@ -14,16 +14,17 @@
|
||||
\=====
|
||||
|
||||
- @events.sort_by(&:start_time).each do |event|
|
||||
- @event = event
|
||||
\## [#{event.city}] [#{event.title}](#{event_url event}) - #{display_date}
|
||||
- lines = strip_tags(@event.description).split(/\r\n/).reject(&:blank?)
|
||||
[#{event.city}] [#{event.title}](#{event_url event}) - #{display_date event}
|
||||
\-----
|
||||
|
||||
- lines = strip_tags(event.description).split(/\r\n/).reject(&:blank?)
|
||||
- lines[0..2].each do |p|
|
||||
= p
|
||||
\
|
||||
* #{[@event.place_name, event.full_address].compact.join ', '}
|
||||
* #{Event.human_attribute_name :url}: #{link_to @event.url, @event.url}
|
||||
* #{[event.place_name, event.full_address].compact.join ', '}
|
||||
* #{Event.human_attribute_name :url}: #{link_to event.url, event.url}
|
||||
* #{Event.human_attribute_name :tags}:
|
||||
#{@event.tags.split.collect { |tag| "[#{tag}](#{tag_url tag})" }.join ', '}
|
||||
#{event.tags.split.collect { |tag| "[#{tag}](#{tag_url tag})" }.join ', '}
|
||||
\
|
||||
|
||||
%h1= title
|
||||
|
Loading…
Reference in New Issue
Block a user