Skip to content

Commit

Permalink
events cant be deleted after they started. Ref:#345
Browse files Browse the repository at this point in the history
  • Loading branch information
Usame Algan committed Jan 19, 2018
1 parent 305a831 commit d5aaa8c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def deadline_has_passed?
deadline < Date.current
end

def startdate_has_passed?
startdate < Date.current
end

def add_team(team)
teams << team
invalidate_schedule
Expand Down
2 changes: 1 addition & 1 deletion app/views/events/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<%= link_to t('.edit', default: t('helpers.links.edit')),
edit_event_path(@event), class: 'btn btn-default' %>
<% end %>
<% if can? :destroy, @event %>
<% if (can? :destroy, @event) && !@event.startdate_has_passed? %>
<%= link_to t('.destroy', default: t('helpers.links.destroy')),
event_path(@event),
method: 'delete',
Expand Down

0 comments on commit d5aaa8c

Please sign in to comment.