Skip to content

Commit

Permalink
Merge pull request rubycentral#63 from rubycentral/10-guidelines-alwa…
Browse files Browse the repository at this point in the history
…ys-visible

#10 Guidelines should be visible
  • Loading branch information
LouisaBarrett committed Dec 16, 2015
2 parents 3c8fc7d + 0a5d9b5 commit f57746b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 8 additions & 0 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Event < ActiveRecord::Base
validates :slug, presence: true, uniqueness: true

before_validation :generate_slug
before_save :update_closes_at_if_manually_closed


def valid_proposal_tags
Expand Down Expand Up @@ -122,6 +123,13 @@ def cfp_closes
def conference_date(conference_day)
start_date + (conference_day - 1).days
end

private
def update_closes_at_if_manually_closed
if changes.key?(:state) && changes[:state] == ['open', 'closed']
self.closes_at = DateTime.now
end
end
end

# == Schema Information
Expand Down
10 changes: 4 additions & 6 deletions app/views/events/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
.col-md-1
.share.pull-right= event.tweet_button
.col-md-8
- if event.past_open? || event.open?
.markdown
= markdown(event.guidelines)
- elsif event.closes_at?
%p
Closed at
.markdown
- if event.closed?
Closed on
%strong= event.closes_at(:long_with_zone)
= markdown(event.guidelines)
.col-md-4
- if event.open?
%p= link_to 'Submit a proposal', new_proposal_path(slug: event.slug), class: 'btn btn-primary'
Expand Down

0 comments on commit f57746b

Please sign in to comment.