Commit 47d5777a authored by Jiri Strojil's avatar Jiri Strojil

Merge branch 'develop'

parents 80ce11c3 13b59eec
......@@ -44,7 +44,7 @@ Style/GuardClause:
MinBodyLength: 5
Metrics/LineLength:
Max: 100
Max: 140
Exclude:
- 'db/seeds.rb'
- 'app/policies/**/*'
......
......@@ -27,7 +27,6 @@ gem 'country_select'
gem 'devise'
gem 'devise-i18n'
gem 'devise_invitable'
gem 'font-awesome-sass'
gem 'i18n_data'
gem 'i18n_rails_helpers'
gem 'jbuilder'
......
......@@ -183,8 +183,6 @@ GEM
railties (>= 3.0.0)
ffaker (2.9.0)
ffi (1.9.25)
font-awesome-sass (5.3.1)
sassc (>= 1.11)
globalid (0.4.1)
activesupport (>= 4.2.0)
hashery (2.1.2)
......@@ -471,7 +469,6 @@ DEPENDENCIES
devise_invitable
factory_bot_rails
ffaker
font-awesome-sass
i18n_data
i18n_rails_helpers
i18n_yaml_sorter
......
......@@ -3,8 +3,6 @@
@import 'inplace_fields';
@import 'bootstrap-datepicker3';
@import 'font-awesome-sprockets';
@import 'font-awesome';
@import 'jquery-ui/core';
@import 'jquery-ui/autocomplete';
@import 'jquery-ui/theme';
......
class SemesterProcessesController < ApplicationController
before_action :set_semester_process, only: [:show, :edit, :update, :overdue]
before_action :set_semester_process, only: [:edit, :update, :overdue]
before_action :set_semester, only: [:new, :create]
include SemesterProcessHelper
def index
authorize SemesterProcess
@semester_processes = SemesterProcess.all.paginate(page: params[:page])
end
def show; end
def new
@semester_process = SemesterProcess.new(semester: @selected_semester, kind: :mail )
new_or_edit
......
......@@ -12,19 +12,19 @@ module NavigationAndButtonHelper
yes: { text: 'Ja', icon_type: 'ok' },
no: { text: 'Nein', icon_type: 'remove' },
journal: { text: 'Journal', icon_type: 'book' },
journal_new: { text: 'Neuen Journal eintrag erstellen', type: :fa, icon_type: :edit },
journal_new: { text: 'Neuen Journal eintrag erstellen', icon_type: :edit },
hours: { text: 'Stunden erfassen', icon_type: 'time' },
billing_expenses: { text: 'Spesen', icon_type: 'usd' },
assignment: { text: 'Begleitung', icon_type: 'user' },
certificate: { text: 'Nachweis', icon_type: 'education' },
xlsx: { text: 'Excel herunterladen', type: :fa, icon_type: 'file-excel-o' },
xlsx: { text: 'Excel herunterladen', icon_type: 'file' },
truthy: { text: 'true', icon_type: :ok, extra_class: 'text-success' },
falsy: { text: 'false', icon_type: :remove, extra_class: 'text-danger' }
}.freeze
def form_navigation_btn(action, cols: 12, with_row: true, md_cols: nil, with_col: false,
add_class: nil)
button = make_nav_button(action)
add_class: nil, custom_controller: nil)
button = make_nav_button(action, custom_controller: custom_controller)
button = bootstrap_col(cols, md_cols) { button } if with_col || with_row
button = boostrap_row(add_class) { button } if with_row
button
......@@ -58,10 +58,13 @@ module NavigationAndButtonHelper
end
end
def make_nav_button(action)
def make_nav_button(action, custom_controller: nil)
if action == :back
text = icon_span(:back)
action = :index
elsif custom_controller
text = icon_span(:back)
return button_link(text, controller: custom_controller, action: :index, id: nil)
else
text = t_title(action)
end
......
......@@ -20,6 +20,7 @@ class Hour < ApplicationRecord
scope :billable, (-> { where(billing_expense: nil) })
scope :billed, (-> { where.not(billing_expense: nil) })
scope :order_by_meeting_date, (-> { order(meeting_date: :asc) })
scope :semester, lambda { |date = nil|
return all if date.blank?
date = Time.zone.parse(date) unless date.is_a? Time
......@@ -33,7 +34,7 @@ class Hour < ApplicationRecord
}
scope :within_semester, lambda { |semester|
where(meeting_date: semester.begin...semester.end.advance(days: 1))
where(meeting_date: semester.begin...semester.end.advance(days: 1)).order_by_meeting_date
}
scope :since_last_submitted, lambda { |submitted_at|
......@@ -51,9 +52,9 @@ class Hour < ApplicationRecord
attr_reader :spv_mission_id
def spv_mission_id= id
spv_mission = SemesterProcessVolunteerMission.find(id)
self.hourable = spv_mission.mission.group_assignment? ? spv_mission.mission.group_offer : spv_mission.mission
def spv_mission_id=(id)
spv_mission = SemesterProcessVolunteerMission.find(id)
self.hourable = spv_mission.mission.group_assignment? ? spv_mission.mission.group_offer : spv_mission.mission
end
def assignment?
......
......@@ -5,7 +5,7 @@ class SemesterProcess < ApplicationRecord
belongs_to :reminder_mail_posted_by, -> { with_deleted }, class_name: 'User',
inverse_of: 'semester_process_reminder_mail_posted', optional: true
validates_uniqueness_of :semester
validates :semester, uniqueness: true
has_many :semester_process_volunteers, dependent: :destroy
accepts_nested_attributes_for :semester_process_volunteers, allow_destroy: true
......@@ -36,18 +36,18 @@ class SemesterProcess < ApplicationRecord
end
def subject
if self.kind.to_sym == :reminder
self.reminder_mail_subject_template
if kind.to_sym == :reminder
reminder_mail_subject_template
else
self.mail_subject_template
mail_subject_template
end
end
def body
if self.kind.to_sym == :reminder
self.reminder_mail_body_template
if kind.to_sym == :reminder
reminder_mail_body_template
else
self.mail_body_template
mail_body_template
end
end
......@@ -72,12 +72,12 @@ class SemesterProcess < ApplicationRecord
end
def build_semester_volunteers(volunteers, selected: nil, save_records: false, preselect: false)
volunteers = volunteers.select{ |volunteer| selected.include? volunteer.id } if selected && selected.any?
volunteers = volunteers.select { |volunteer| selected.include? volunteer.id } if selected && selected.any?
@new_semester_process_volunteers = []
@new_semester_process_volunteers = volunteers.to_a.map do |volunteer|
spv = SemesterProcessVolunteer.new(volunteer: volunteer, semester_process: self, selected: preselect)
spv.build_missions(semester)
spv.save if save_records && self.valid?
spv.save if save_records && valid?
spv
end
end
......
......@@ -19,7 +19,6 @@ class SemesterProcessMail < ApplicationRecord
:Einsatz,
:FeedbackLink,
:EmailAbsender,
:Semester,
:OnlinePlattformUrl
].freeze
......@@ -57,10 +56,6 @@ class SemesterProcessMail < ApplicationRecord
volunteer.contact.natural_name
end
def semester
"#{ I18n.l(semester_process.semester.begin)} - #{I18n.l(semester_process.semester.end)}"
end
def einsatz
''
end
......
......@@ -35,8 +35,18 @@ class SemesterProcessVolunteer < ApplicationRecord
joins(:semester_process).where(semester_process: semester).joins(:semester_process_mails).where("semester_process_mails.kind = 0")
}
scope :active_missions, lambda {
joins(:semester_process_volunteer_missions).includes(semester_process_volunteer_missions: [:assignment, :group_assignment])
.where("(semester_process_volunteer_missions.assignment_id IS NOT NULL AND
assignments.period_end IS NULL)
OR
(semester_process_volunteer_missions.group_assignment_id IS NOT NULL AND
group_assignments.period_end is NULL)")
.references(:assignments, :group_assignments)
}
scope :index, lambda { |semester = nil|
without_reminders(semester)
active_missions.without_reminders(semester)
}
scope :without_feedback, lambda {
......@@ -61,8 +71,10 @@ class SemesterProcessVolunteer < ApplicationRecord
end
def build_missions(semester)
new_missions = volunteer.assignments.active_between(semester.begin, semester.end) +
volunteer.group_assignments.active_between(semester.begin, semester.end)
# if you change this then also change it within active_semester_mission(semester)
prob = semester.end.advance(weeks: -4)
new_missions = volunteer.assignments.no_end.start_before(prob) +
volunteer.group_assignments.no_end.start_before(prob)
semester_process_volunteer_missions << new_missions.map do |mission|
SemesterProcessVolunteerMission.new(mission: mission)
......
......@@ -3,4 +3,14 @@ class SemesterProcessVolunteerMission < ApplicationRecord
delegate :volunteer, to: :semester_process_volunteer
belongs_to :semester_process_volunteer
scope :need_feedback, lambda {
includes(:assignment, :group_assignment)
.where("(semester_process_volunteer_missions.assignment_id IS NOT NULL AND
assignments.period_end IS NULL)
OR
(semester_process_volunteer_missions.group_assignment_id IS NOT NULL AND
group_assignments.period_end is NULL)")
.references(:assignments, :group_assignments)
}
end
......@@ -244,10 +244,9 @@ class Volunteer < ApplicationRecord
def self.active_semester_mission(semester)
volunteers = Volunteer.have_mission
prob = semester.end.advance(weeks: -4)
sem_start = semester.begin
vol_with_missions = volunteers.select do |v|
[v.assignments, v.group_assignments].detect do |mission|
mission.where("period_start < ?", prob).where("period_end > ? OR period_end IS NULL", sem_start).any?
mission.where("period_end IS NULL").where("period_start < ?", prob).any?
end
end
vol_with_missions
......
......@@ -8,9 +8,7 @@ class SemesterProcessPolicy < ApplicationPolicy
end
# Actions
alias_method :index?, :superadmin?
alias_method :new?, :superadmin?
alias_method :show?, :superadmin?
alias_method :edit?, :superadmin?
alias_method :create?, :superadmin?
alias_method :update?, :superadmin?
......
......@@ -21,8 +21,8 @@ nav.navbar.navbar-top.hidden-print
li= link_to 'Begleitungen', assignments_path
- if policy(GroupOffer).index?
li= link_to 'Gruppenangebote', group_offers_path
- if policy(SemesterProcess).index?
li= link_to 'Semester Prozesse', semester_process_volunteers_path
- if policy(SemesterProcessVolunteer).index?
li= link_to 'Semester Prozess', semester_process_volunteers_path
- if policy(ReminderMailing).index?
li = link_to 'Erinnerungs-Emails', reminder_mailings_path
- if policy(Event).index?
......
......@@ -2,7 +2,6 @@
h1 Spesenformulare erfassen
= simple_form_for @billing_expense do |f|
= hidden_field_tag 'selected_semester', @selected_billing_semester
ul.list-inline
......@@ -16,6 +15,7 @@ h1 Spesenformulare erfassen
thead
tr
th.limit-width= select_all_rows
th Halbjahres-Rapport
th Freiwillige/r
th= t_attr(:bank_details, Volunteer)
th Stunden
......@@ -26,7 +26,10 @@ h1 Spesenformulare erfassen
- @volunteers.each do |volunteer|
tr.table-row-selectable id=dom_id(volunteer)
td= check_box_tag 'selected_volunteers[]', volunteer.id,
@selected_volunteers.include?(volunteer.id.to_s), disabled: !volunteer.iban?
@selected_volunteers.include?(volunteer.id.to_s), disabled: !volunteer.iban?
td
- if volunteer.unsubmitted_semester_feedbacks?
span.label.label-danger Unbestätigt
td= link_to volunteer, edit_volunteer_path(volunteer)
td
- if volunteer.iban?
......
......@@ -9,29 +9,29 @@ html
}
html, body {
font-family: Arial,Helvetica Neue, Helvetica, sans-serif;
font-size: 10px;
font-size: 10pt;
line-height: 1.4
}
h1 {
font-size: 22px;
font-size: 22pt;
}
h2 {
font-size: 19px;
font-size: 19pt;
}
h3 {
font-size: 17px;
font-size: 17pt;
}
h4 {
font-size: 12px;
font-size: 12pt;
margin-bottom: 2px;
margin-top: 8px;
}
h5 {
font-size: 11px;
font-size: 11pt;
}
p {
font-size: 10px;
font-size: 10pt;
margin-top: 2px;
}
......@@ -39,6 +39,10 @@ html
border-color: #e63028;
}
footer p {
font-size: 9pt;
}
p .red {
background: none;
color: #e63028;
......
......@@ -8,7 +8,7 @@
.col-xs-12
p.text-danger Bestätigt am #{l(@semester_process_volunteer.commited_at.to_date)} durch #{profile_link(@semester_process_volunteer.commited_by)}
= f.simple_fields_for :semester_feedbacks, @semester_process_volunteer.semester_process_volunteer_missions do |spvm|
= f.simple_fields_for :semester_feedbacks, @semester_process_volunteer.semester_process_volunteer_missions.need_feedback do |spvm|
- mission = spvm.object.mission
h2.m-b-20.m-t-30 Einsatz #{mission.to_label}
......
nav.navbar.section-navigation
hr
ul.list-inline
li= button_link 'Neuen Semester Prozess erstellen', new_semester_process_path, dimension: 'sm'
hr
......@@ -2,4 +2,4 @@ h1= t_title(:edit)
= render 'form'
= form_navigation_btn :back
= form_navigation_btn :index, custom_controller: :semester_process_volunteers
h1= t_title(:index)
= render 'index_nav'
= bootstrap_paginate(@semester_processes)
.table-responsive
table.table.table-striped
thead
tr
th.hidden-print Aktionen
th= t_attr(:creator)
th= t_attr(:semester)
th= t_attr(:created_at)
tbody
- @semester_processes.each do |semester_process|
tr
td.index-action-cell.hidden-print
= link_to t_action(:show), semester_process
= link_to t_action(:edit), edit_semester_process_path(semester_process)
= link_to icon_span(:delete), semester_process_path(semester_process), confirm_deleting(semester_process)
td = semester_process.creator
td = semester_process.semester
td= l(semester_process.created_at)
= bootstrap_paginate(@semester_processes)
= render 'index_nav'
......@@ -2,4 +2,4 @@ h1= t_title(:new)
= render 'form'
= form_navigation_btn :back
= form_navigation_btn :index, custom_controller: :semester_process_volunteers
......@@ -2,4 +2,4 @@ h1 Erinnerung versenden
= render 'form'
= form_navigation_btn :back
= form_navigation_btn :index, custom_controller: :semester_process_volunteers
h1= t_title(:show)
p
strong User:
= @semester_process.creator
p
strong Semester start:
= @semester_process.period_start
p
strong Semester end:
= @semester_process.period_end
= form_navigation_btn :edit
= form_navigation_btn :back
......@@ -12,7 +12,7 @@ nav.navbar.section-navigation
- if policy(Volunteer).superadmin_privileges?
li= button_link t('seeking_clients'), seeking_clients_volunteers_url, dimension: 'sm'
= boolean_toggler_filter_dropdown(:intro_course, 'Einführungskurs', 'Besucht', 'Ausstehend')
li= button_link t_attr(:waive_alternative), url_for(format: :xlsx, q: search_parameters), dimension: 'sm'
li= button_link icon_span(:xlsx), url_for(format: :xlsx, q: search_parameters), dimension: 'sm'
hr
......@@ -30,4 +30,3 @@ nav.navbar.section-navigation
hr
= render 'columns', volunteers: @volunteers
......@@ -103,7 +103,7 @@ Rails.application.routes.draw do
put :mark_as_done, on: :member
put :update_notes, on: :member
end
resources :semester_processes, except: [:destroy] do
resources :semester_processes, except: [:destroy, :index, :show] do
get :overdue, on: :member
end
......
......@@ -6,6 +6,7 @@ class SemesterFeedbackTest < ApplicationSystemTestCase
@subject = create :semester_process
@spv = create(:semester_process_volunteer, :with_mission, :with_mail, volunteer: @volunteer,
semester_process: @subject)
@spv.reload
login_as @volunteer.user
visit review_semester_semester_process_volunteer_path(@spv)
end
......@@ -39,6 +40,15 @@ class SemesterFeedbackTest < ApplicationSystemTestCase
assert_not page.has_text? 'Sie haben einen ausstehenden Halbjahres-Rapport für dieses Semester.'
end
test 'volunteer hours should appear in asc order' do
create :hour, volunteer: @volunteer, meeting_date: @spv.semester.begin, hours: 1, hourable: @spv.missions.last
create :hour, volunteer: @volunteer, meeting_date: @spv.semester.end, hours: 2, hourable: @spv.missions.last
visit review_semester_semester_process_volunteer_path(@spv)
within 'tbody tr:last-child' do
assert page.has_text? I18n.l(@spv.semester.end)
end
end
test 'submit form should not display warning' do
visit root_path
assert page.has_text? 'Sie haben einen ausstehenden Halbjahres-Rapport für dieses Semester.'
......
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