Skip to content

Commit

Permalink
Todo display due date
Browse files Browse the repository at this point in the history
  • Loading branch information
ifournight committed Apr 7, 2017
1 parent 719ff16 commit 5da9bbc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/models/todo.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
class Todo < ApplicationRecord
belongs_to :creator, class_name: 'User', optional: true
belongs_to :project

validates :title, presence: true

def over_due?
unless deadline.nil?
return deadline < Time.zone.now
end

false
end
end
8 changes: 8 additions & 0 deletions app/views/todos/_todo.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
<%= render complete_todo, todo: todo, user: current_user%>
<% end %>
<span class='level-item'><%= todo.title %> </span>
<% unless todo.deadline.nil? %>
<% if todo.over_due? %>
<span class="tag is-danger is-primary"><%= todo.deadline.to_date %></span>
<% else %>
<span class="tag is-info is-primary"><%= todo.deadline.to_date %></span>
<% end %>
<% end %>
</span>
</div>
</div>
<% end %>

0 comments on commit 5da9bbc

Please sign in to comment.