Commit 0865a285 authored by Kaspar Vollenweider's avatar Kaspar Vollenweider

Merge branch '462-suport-morgen-2019-02-21' into 'develop'

Resolve "Suport morgen 2019-02-21"

See merge request !929
parents 46c37b2c b45bf750
Pipeline #39335 passed with stage
in 38 minutes and 35 seconds
image: git.panter.ch:5001/panter/gitlab-ci-docker-images/ruby-and-rails:ruby-2.4.5-node-8-imgmgk-chrome
image: git.panter.ch:5001/panter/gitlab-ci-docker-images/ruby-and-rails:ruby-2.4.5-node8-chrome-imagemagick
stages:
- test
......
@import 'bootstrap_overwrites';
// Margin utility classes
.m-b-10 {
margin-bottom: 10px;
}
.m-b-20 {
margin-bottom: 20px;
}
.m-b-30 {
margin-bottom: 30px;
}
.m-t-10 {
margin-top: 10px;
}
.m-t-20 {
margin-top: 20px;
}
.m-t-30 {
margin-top: 30px;
}
.m-t-80 {
margin-top: 80px;
}
.m-l-10 {
margin-left: 10px;
}
.m-l-20 {
margin-left: 20px;
}
.m-l-30 {
margin-left: 30px;
}
.m-r-10 {
margin-right: 10px;
}
.m-r-20 {
margin-right: 20px;
}
// Padding utility classes
.m-r-30 {
margin-right: 30px;
}
.p-b-10 {
padding-bottom: 10px;
}
.p-b-20 {
padding-bottom: 20px;
}
.p-b-30 {
padding-bottom: 30px;
}
.p-t-10 {
padding-top: 10px;
}
.p-t-20 {
padding-top: 20px;
}
.p-t-30 {
padding-top: 30px;
}
.p-l-10 {
padding-left: 10px;
}
.p-l-20 {
padding-left: 20px;
}
.p-l-30 {
padding-left: 30px;
}
.p-r-10 {
padding-right: 10px;
}
.p-r-20 {
padding-right: 20px;
}
.p-r-30 {
padding-right: 30px;
}
.text-bigger-1 {
font-size: 110%;
}
.text-bigger-2 {
font-size: 120%;
}
.text-bigger-3 {
font-size: 130%;
}
.text-smaller-1 {
font-size: 90%;
}
.text-smaller-2 {
font-size: 80%;
}
.text-smaller-3 {
font-size: 70%;
// Generates utility classes for margin and padding
//
// .m-t-10 => margin-top: 10px;
// .m-r-10 => margin-right: 10px;
// .m-b-10 => margin-bottom: 10px;
// .m-l-10 => margin-left: 10px;
// .p-t-10 => padding-top: 10px;
//
// .m-x-20 => margin-left: 20px; margin-right: 20px;
// .m-y-30 => margin-top: 30px; margin-bottom: 30px;
//
// .p-50 => padding: 50px;
// types:
$utility_types: (
m: 'margin',
p: 'padding'
);
// sides:
$utility_sides: (
t: 'top',
r: 'right',
b: 'bottom',
l: 'left'
);
// sizes:
$utility_withs: (
0: 0,
10: 10px,
20: 20px,
30: 30px,
40: 40px,
50: 50px,
60: 60px,
70: 70px,
80: 80px
);
@each $type_key, $type_value in $utility_types {
@each $width_key, $width_value in $utility_withs {
.#{$type_key}-#{$width_key} {
#{$type_value}: $width_value;
}
@each $side_key, $side_value in $utility_sides {
@if $side_key == r or $side_key == l {
.#{$type_key}-#{$side_key}-#{$width_key},
.#{$type_key}-x-#{$width_key} {
#{$type_value}-#{$side_value}: $width_value;
}
}
@if $side_key == t or $side_key == b {
.#{$type_key}-#{$side_key}-#{$width_key},
.#{$type_key}-y-#{$width_key} {
#{$type_value}-#{$side_value}: $width_value;
}
}
}
}
}
h1.small {
......
......@@ -143,6 +143,12 @@ class AssignmentsController < ApplicationController
authorize :assignment, :hours_and_feedbacks_submitted?
end
def reactivate
state = @assignment.reactivate! ? 'success' : 'failure'
redirect_back fallback_location: edit_assignment_path(@assignment),
notice: t("assignments.notices.reactivation.#{state}")
end
private
def create_update_redirect
......
......@@ -102,6 +102,12 @@ class GroupAssignmentsController < ApplicationController
authorize :group_assignment, :hours_and_feedbacks_submitted?
end
def reactivate
state = @group_assignment.reactivate! ? 'success' : 'failure'
redirect_back fallback_location: edit_group_assignment_path(@group_assignment),
notice: t("group_assignments.notices.reactivation.#{state}")
end
private
def handle_period_end
......
......@@ -5,7 +5,7 @@ class UsersController < ApplicationController
authorize User
@q = User.distinct.ransack(params[:q])
@q.sorts = ['created_at desc'] if @q.sorts.empty?
@users = @q.result
@users = @q.result.paginate(page: params[:page])
respond_to do |format|
format.html
format.xlsx do
......
class VolunteersController < ApplicationController
before_action :set_volunteer, only: [:show, :edit, :update, :terminate, :account, :update_bank_details]
before_action :set_volunteer, only: [:show, :edit, :update, :terminate, :account, :update_bank_details, :reactivate]
def index
authorize Volunteer
......@@ -119,6 +118,11 @@ class VolunteersController < ApplicationController
end
end
def reactivate
state = @volunteer.reactivate! ? 'success' : 'failure'
redirect_to edit_volunteer_path(@volunteer), notice: t("volunteers.notices.reactivation.#{state}")
end
private
def not_resigned
......
......@@ -26,8 +26,12 @@ module AcceptanceAttributes
private
def record_acceptance_change
return unless new_record? || will_save_change_to_acceptance?
return unless new_record? || will_save_change_to_attribute?(:acceptance)
# reactivated volunteers shouldn't look resigned, because having resigned_at date
if will_save_change_to_attribute?(:acceptance, from: 'resigned', to: 'accepted')
self.resigned_at = nil
end
self["#{acceptance}_at".to_sym] = Time.zone.now
end
end
......@@ -70,7 +70,21 @@ module GroupAssignmentAndAssignmentCommon
end
def terminated?
termination_verifiable? && termination_verified_by.present?
ended? && termination_verified_by.present?
end
def reactivatable?
terminated? && volunteer.accepted?
end
def reactivate!
update!(period_end: nil, termination_verified_at: nil, termination_submitted_at: nil, termination_verified_by: nil,
termination_submitted_by: nil, period_end_set_by: nil)
if assignment?
assignment_log.delete
elsif group_assignment?
group_assignment_logs.last.delete
end
end
private
......
......@@ -103,7 +103,6 @@ class User < ApplicationRecord
has_and_belongs_to_many :department
# Roles definition
SUPERADMIN = 'superadmin'.freeze
SOCIAL_WORKER = 'social_worker'.freeze
......
......@@ -526,6 +526,18 @@ class Volunteer < ApplicationRecord
end
end
def reactivate!
update!(acceptance: 'accepted')
return true if external?
if user.present? && (user.sign_in_count.zero? || !user.invitation_accepted?)
user.invite!
else
self.user = User.invite!(email: contact.primary_email, role: 'volunteer')
end
save
end
private
def kinds_done_ids
......
......@@ -18,6 +18,11 @@ class AssignmentPolicy < ApplicationPolicy
user.involved_authorities.include?(record.client))
end
def reactivate?
record.class.name == 'Assignment' && record.reactivatable? &&
superadmin_or_department_manager_creation_or_volunteer_related?
end
# controller action policies
alias_method :index?, :superadmin_or_department_manager?
alias_method :terminated_index?, :superadmin_or_department_manager?
......
......@@ -5,6 +5,11 @@ class GroupAssignmentPolicy < ApplicationPolicy
end
end
def reactivate?
record.class.name == 'GroupAssignment' && record.reactivatable? &&
superadmin_or_departments_offer_or_volunteer_related?
end
alias_method :show?,
:superadmin_or_department_manager_or_volunteer_related?
......
......@@ -35,6 +35,11 @@ class VolunteerPolicy < ApplicationPolicy
user_owns_record?
end
def reactivate?
record.class.name == 'Volunteer' && record.resigned? &&
superadmin_or_departments_record_or_assignable_to_department?
end
# controller action policies
alias_method :index?, :superadmin_or_department_manager?
alias_method :search?, :superadmin_or_department_manager?
......@@ -47,6 +52,7 @@ class VolunteerPolicy < ApplicationPolicy
alias_method :update?, :volunteer_managing_or_volunteers_profile?
alias_method :update_bank_details?, :volunteer_managing_or_volunteers_profile?
alias_method :account?, :superadmin?
alias_method :reactivate?, :reactivate?
# supplementary policies
alias_method :superadmin_privileges?, :superadmin?
......
......@@ -16,6 +16,8 @@ table.table.table-striped.assignment-logs-table
- if policy(assignment.assignment).show? && assignment.assignment.pdf.exists?
= button_link icon_span(:download), assignment_path(assignment.assignment, format: :pdf),
title: 'Herunterladen'
- if policy(assignment.assignment).reactivate?
= button_link icon_span(:edit), edit_assignment_path(assignment.assignment)
td= link_to_if(policy(Client).show?, assignment.client.contact.full_name, assignment.client)
td= l(assignment.period_start) if assignment.period_start
td= l(assignment.period_end) if assignment.period_end
......
= simple_form_for(@assignment) do |f|
= simple_error_notice f
.row
.col-xs-12
= f.button :submit
- if policy(@assignment).reactivate?
h3.m-t-30= t('.reactivate.title')
p== t('.reactivate.hint')
= link_to t('.reactivate.button'), reactivate_assignment_path(@assignment), class: 'btn btn-default m-t-10',
data: { confirm: t('.reactivate.confirm') }
hr.m-y-30
.row
.col-xs-12.col-md-6
- if action_new?
......
......@@ -2,6 +2,13 @@
= simple_error_notice f
= f.button :submit
- if policy(@group_assignment).reactivate?
h3.m-t-30= t('.reactivate.title')
p== t('.reactivate.hint')
= link_to t('.reactivate.button'), reactivate_group_assignment_path(@group_assignment), class: 'btn btn-default m-t-10',
data: { confirm: t('.reactivate.confirm') }
hr.m-y-30
dl.dl-horizontal.m-t-30
dt Freiwillige/r:
dd= link_to @group_assignment.volunteer.contact.full_name, edit_volunteer_path(@group_assignment.volunteer), target: '_blank'
......
......@@ -11,8 +11,11 @@ table.table.table-striped.group-assignments-table
tbody
- group_assignment_logs.each do |group_assignment|
tr
td= link_to_if(policy(group_assignment.group_offer).show?,
td.index-action-cell.hidden-print
= link_to_if(policy(group_assignment.group_offer).show?,
group_assignment.group_offer.title, group_offer_path(group_assignment.group_offer))
- if policy(group_assignment.group_assignment).reactivate?
= button_link icon_span(:edit), edit_group_assignment_path(group_assignment.group_assignment)
td= t_attr(group_assignment.responsible ? :responsible : :member, GroupAssignment)
td= l(group_assignment.period_start) if group_assignment.period_start
td= l(group_assignment.period_end) if group_assignment.period_end
......
- top_nav ||= false
- unless top_nav
= bootstrap_paginate(@users)
nav.navbar.section-navigation class=('section-navigation-top' if top_nav)
hr
- if top_nav
ul.list-unstyled
li.li-search-form
= search_form_for @q do |f|
= f.search_field :full_name_cont, class: 'search-field',
data: { autocomplete: search_users_path }, autofocus: true,
placeholder: 'Nach Benutzer/innen Name oder E-Mail suchen'
= f.submit 'Suchen', class: 'search-submit'
ul.list-inline
li= clear_filter_button
= list_filter_dropdown(:role, User::ROLES)
li= button_link t_title(:new), new_user_path, dimension: 'sm'
li= button_link icon_span(:xlsx), url_for(format: :xlsx, q: search_parameters), dimension: 'sm'
hr
- if top_nav
= bootstrap_paginate(@users)
h1 Benutzer/innen
nav.navbar.section-navigation
hr
ul.list-unstyled
li.li-search-form
= search_form_for @q do |f|
= f.search_field :full_name_cont, class: 'search-field',
data: { autocomplete: search_users_path }, autofocus: true,
placeholder: 'Nach Benutzer/innen Name oder E-Mail suchen'
= f.submit 'Suchen', class: 'search-submit'
ul.list-inline
li= clear_filter_button
= list_filter_dropdown(:role, User::ROLES)
li= button_link t_title(:new), new_user_path, dimension: 'sm'
li= button_link icon_span(:xlsx), url_for(format: :xlsx, q: search_parameters), dimension: 'sm'
hr
= render 'index_nav', top_nav: true
table.table.table-striped
thead
......@@ -25,4 +11,4 @@ table.table.table-striped
tbody
= render @users
= form_navigation_btn :new
= render 'index_nav'
= simple_error_notice f
- if policy(volunteer).reactivate?
h3.m-t-30= t('.reactivate.title')
p== t('.reactivate.hint')
= link_to t('.reactivate.button'), reactivate_volunteer_path(volunteer), class: 'btn btn-default m-t-10',
data: { confirm: t('.reactivate.confirm') }
hr.m-y-30
- if current_user && policy(volunteer).update_acceptance?
.row
.col-xs-12.col-md-4
......
This diff is collapsed.
......@@ -42,6 +42,10 @@ Rails.application.routes.draw do
end
end
concern :reactivate do
get :reactivate, on: :member
end
# Resource and other Routes
#
......@@ -52,7 +56,7 @@ Rails.application.routes.draw do
end
end
resources :assignments, except: [:destroy], concerns: [:submit_feedback, :termination_actions] do
resources :assignments, except: [:destroy], concerns: [:submit_feedback, :termination_actions, :reactivate] do
get :volunteer_search, on: :collection
get :client_search, on: :collection
end
......@@ -68,7 +72,7 @@ Rails.application.routes.draw do
end
resources :group_assignments, only: [:show, :create, :edit, :update],
concerns: [:submit_feedback, :termination_actions] do
concerns: [:submit_feedback, :termination_actions, :reactivate] do
put :set_end_today, on: :member
end
......@@ -111,17 +115,17 @@ Rails.application.routes.draw do
get :thanks, on: :collection
end
resources :volunteers, except: [:destroy], concerns: :search do
resources :volunteers, except: [:destroy], concerns: [:search, :reactivate] do
put :terminate, on: :member
put :account, on: :member
get :find_client, on: :member, to: 'assignments#find_client'
get :seeking_clients, on: :collection
patch :update_bank_details, on: :member
resources :assignments, except: [:destroy], concerns: [:assignment_feedbacks, :hours_resources]
resources :assignments, except: [:destroy], concerns: [:assignment_feedbacks, :hours_resources, :reactivate]
resources :billing_expenses, only: [:index]
resources :certificates
resources :group_assignments, only: [:show, :edit, :update], concerns: :hours_resources
resources :group_assignments, only: [:show, :edit, :update], concerns: [:hours_resources, :reactivate]
resources :group_offers, except: [:destroy], concerns: :assignment_feedbacks
resources :hours
resources :journals, except: [:show]
......
......@@ -2,7 +2,7 @@ require 'test_helper'
class AssignmentPolicyTest < PolicyAssertions::Test
test 'superadmin_can_use_all_actions' do
assert_permit(create(:user), Assignment, *actions_list, 'show_comments?')
assert_permit(create(:user), Assignment, *actions_list(except: [:reactivate]), 'show_comments?')
end
test 'department_manager_has_limited_access' do
......
......@@ -2,7 +2,7 @@ require 'test_helper'
class GroupAssignmentPolicyTest < PolicyAssertions::Test
test 'superadmin_can_use_all_actions' do
assert_permit(create(:user), GroupAssignment, *actions_list, 'show_comments?')
assert_permit(create(:user), GroupAssignment, *actions_list(except: [:reactivate]), 'show_comments?')
end
test 'department_manager without department has read-only access' do
......@@ -59,6 +59,7 @@ class GroupAssignmentPolicyTest < PolicyAssertions::Test
end
private
def index_actions
actions_list(:terminated_index, :hours_and_feedbacks_submitted)
end
......
......@@ -3,7 +3,7 @@ require 'test_helper'
class VolunteerPolicyTest < PolicyAssertions::Test
test 'superadmin_can_use_all_actions' do
assert_permit(create(:user), Volunteer,
'superadmin_privileges?', 'show_comments?', *actions_list)
'superadmin_privileges?', 'show_comments?', *actions_list(except: [:reactivate]))
end
test 'department_manager has full access to volunteers in their departments' do
......
......@@ -115,7 +115,7 @@ class UsersTest < ApplicationSystemTestCase
assert page.has_link? social_worker.full_name
assert page.has_link? user_volunteer.full_name
within '.section-navigation' do
within '.section-navigation-top' do
click_link 'Rolle'
click_link 'Superadmin'
end
......@@ -127,7 +127,7 @@ class UsersTest < ApplicationSystemTestCase
refute page.has_link? user_volunteer.full_name
end
within '.section-navigation' do
within '.section-navigation-top' do
click_link 'Rolle: Superadmin'
click_link 'Freiwillige/r'
end
......
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