Exclude tasks from groups when changing attributes.
This commit is contained in:
parent
6b62fc90d8
commit
c52e482743
2 changed files with 8 additions and 1 deletions
|
@ -18,6 +18,7 @@ class Task < ActiveRecord::Base
|
|||
validates_numericality_of :duration, :required_users, :only_integer => true, :greater_than => 0
|
||||
validates_length_of :description, maximum: 250
|
||||
|
||||
before_save :exclude_from_periodic_task_group
|
||||
after_save :update_ordergroup_stats
|
||||
|
||||
# Find all tasks, for which the current user should be responsible
|
||||
|
@ -105,5 +106,11 @@ class Task < ActiveRecord::Base
|
|||
def update_ordergroup_stats(user_ids = self.user_ids)
|
||||
Ordergroup.joins(:users).where(users: {id: user_ids}).each(&:update_stats!)
|
||||
end
|
||||
|
||||
def exclude_from_periodic_task_group
|
||||
if changed? and not new_record?
|
||||
self.periodic_task_group = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -26,6 +26,6 @@
|
|||
= f.input :done
|
||||
.form-actions
|
||||
= f.submit class: 'btn btn-primary'
|
||||
- unless @task.id
|
||||
- if @task.new_record?
|
||||
= f.submit 'Wöchentliche Aufgabe erstellen', name: 'periodic', class: 'btn'
|
||||
= link_to t('ui.or_cancel'), :back
|
||||
|
|
Loading…
Reference in a new issue