Commit 4d8f3b31 authored by Chrysanthi Lagodimou's avatar Chrysanthi Lagodimou
Browse files

rename group assignment date attributes

parent ede3565c
......@@ -6,7 +6,7 @@ module GroupAssignmentsAttributes
{
group_assignments_attributes:
[
:id, :volunteer_id, :group_offer_id, :responsible, :start_date, :end_date, :_destroy
:id, :volunteer_id, :group_offer_id, :responsible, :period_start, :period_end, :_destroy
]
}
end
......
......@@ -31,7 +31,7 @@ class Assignment < ApplicationRecord
scope :no_end, (-> { where(period_end: nil) })
scope :has_end, (-> { where.not(period_end: nil) })
scope :ended, (-> { where('period_end < ?', Time.zone.today) })
scope :ended, (-> { where('assignments.period_end < ?', Time.zone.today) })
scope :end_before, ->(date) { where('period_end < ?', date) }
scope :end_after, ->(date) { where('period_end > ?', date) }
scope :end_within, ->(date_range) { where(period_end: date_range) }
......
......@@ -8,13 +8,14 @@ class GroupAssignment < ApplicationRecord
def save_group_assignment_logs
group_assignment_logs.create!(group_offer_id: group_offer_id, volunteer_id: volunteer_id,
group_assignment_id: id, title: group_offer.title, start_date: start_date_before_last_save,
end_date: end_date_before_last_save, responsible: responsible)
group_assignment_id: id, title: group_offer.title,
period_start: period_start_before_last_save, period_end: period_end_before_last_save,
responsible: responsible)
end
private
def dates_updated?
saved_change_to_start_date? || saved_change_to_end_date?
saved_change_to_period_start? || saved_change_to_period_end?
end
end
......@@ -9,9 +9,9 @@
.col-xs-12.col-md-2
= f.input :responsible
.col-xs-12.col-md-3
= f.input :start_date, include_blank: true
= f.input :period_start, include_blank: true
.col-xs-12.col-md-3
= f.input :end_date, include_blank: true
= f.input :period_end, include_blank: true
.col-xs-12.col-md-2
br
= link_to_remove_association t('.remove_volunteer'), f, class: 'btn btn-danger'
......@@ -78,9 +78,9 @@ h1= @group_offer.title
.col-xs-12.col-md-3
= group_assignment.responsible ? t_attr(:responsible, GroupAssignment) : t_attr(:member, GroupAssignment)
.col-xs-12.col-md-3
= l(group_assignment.start_date) if group_assignment.start_date
= l(group_assignment.period_start) if group_assignment.period_start
.col-xs-12.col-md-3
= l(group_assignment.end_date) if group_assignment.end_date
= l(group_assignment.period_end) if group_assignment.period_end
- unless params[:format] == 'pdf'
= form_navigation_btn :edit
......
......@@ -3,8 +3,8 @@ table.table.table-striped
tr
th= t_attr(:title, GroupOffer)
th= t_attr(:volunteer_role, GroupAssignment)
th= t_attr(:start_date, GroupAssignment)
th= t_attr(:end_date, GroupAssignment)
th= t_attr(:period_start, GroupAssignment)
th= t_attr(:period_end, GroupAssignment)
th colspan=(editable == 'yes' ? '6' : '2')
tbody
- group_assignments.each do |group_assignment|
......@@ -14,8 +14,8 @@ table.table.table-striped
td= t_attr(:responsible, GroupAssignment)
- else
td= t_attr(:member, GroupAssignment)
td= l(group_assignment.start_date) if group_assignment.start_date
td= l(group_assignment.end_date) if group_assignment.end_date
td= l(group_assignment.period_start) if group_assignment.period_start
td= l(group_assignment.period_end) if group_assignment.period_end
td= link_to t_action(:show), group_offer_path(group_assignment.group_offer)
td= link_to t('download'), group_offer_path(group_assignment.group_offer, format: :pdf)
- if editable == 'yes'
......
......@@ -278,10 +278,10 @@ de:
name: Name
user: User
group_assignment:
end_date: Enddatum
member: Mitglied in der Freiwilligengruppe
period_end: Enddatum
period_start: Anfangsdatum
responsible: Verantwortliche/r für die Freiwilligengruppe
start_date: Anfangsdatum
volunteer: Freiwillige
volunteer_role: Freiwillige Rolle
group_offer:
......
......@@ -4,8 +4,8 @@ class CreateGroupAssignments < ActiveRecord::Migration[5.1]
create_table :group_assignments do |t|
t.belongs_to :group_offer, index: true
t.belongs_to :volunteer, index: true
t.date :start_date
t.date :end_date
t.date :period_start
t.date :period_end
t.boolean :responsible, default: false
t.datetime :deleted_at, index: true
end
......
......@@ -5,8 +5,8 @@ class CreateGroupAssignmentLogs < ActiveRecord::Migration[5.1]
t.belongs_to :volunteer, index: true
t.belongs_to :group_assignment, index: true
t.string :title, index: true
t.date :start_date
t.date :end_date
t.date :period_start
t.date :period_end
t.boolean :responsible, default: false
t.datetime :deleted_at, index: true
end
......
......@@ -164,8 +164,8 @@ ActiveRecord::Schema.define(version: 20171011151358) do
t.bigint "volunteer_id"
t.bigint "group_assignment_id"
t.string "title"
t.date "start_date"
t.date "end_date"
t.date "period_start"
t.date "period_end"
t.boolean "responsible", default: false
t.datetime "deleted_at"
t.index ["deleted_at"], name: "index_group_assignment_logs_on_deleted_at"
......@@ -178,8 +178,8 @@ ActiveRecord::Schema.define(version: 20171011151358) do
create_table "group_assignments", force: :cascade do |t|
t.bigint "group_offer_id"
t.bigint "volunteer_id"
t.date "start_date"
t.date "end_date"
t.date "period_start"
t.date "period_end"
t.boolean "responsible", default: false
t.datetime "deleted_at"
t.index ["deleted_at"], name: "index_group_assignments_on_deleted_at"
......
......@@ -118,13 +118,13 @@ class GroupOffersTest < ApplicationSystemTestCase
assert page.has_link? group_offer.title
refute page.has_text? 'Group offers log'
group_offer.group_assignments.last.update(start_date: 7.months.ago, end_date: 2.months.ago)
group_offer.group_assignments.last.update(period_start: 7.months.ago, period_end: 2.months.ago)
visit volunteer_path(volunteer)
assert page.has_text? 'Group offers log'
assert page.has_link? group_offer.title, count: 2
group_offer.group_assignments.last.update(end_date: 3.months.ago)
group_offer.group_assignments.last.update(period_end: 3.months.ago)
visit volunteer_path(volunteer)
assert page.has_text? 'Group offers log'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment