Verified Commit b1a41cd9 authored by Kaspar Vollenweider's avatar Kaspar Vollenweider 👻
Browse files

button_and_action

parent bd261eda
Pipeline #15313 failed with stage
in 24 minutes and 51 seconds
......@@ -120,6 +120,27 @@
font-size: 70%;
}
h1.small {
font-size: floor(($font-size-base * 2.1))
}
h2.small {
font-size: floor(($font-size-base * 1.8))
}
h3.small {
font-size: floor(($font-size-base * 1.5))
}
h4.small {
font-size: floor(($font-size-base * 1.4))
}
h5.small {
font-size: floor(($font-size-base * 1.3))
}
@mixin a4 {
background: $white;
height: $a4-long-side;
......
@import 'utility';
@import 'bootstrap_custom';
@import 'utility';
@import 'bootstrap-datepicker3';
@import "font-awesome";
@import 'jquery-ui/core';
......
......@@ -4,7 +4,7 @@ class VolunteersController < ApplicationController
include ContactAttributes
include VolunteerAttributes
before_action :set_volunteer, only: [:show, :edit, :update, :terminate]
before_action :set_volunteer, only: [:show, :edit, :update, :terminate, :account]
def index
authorize Volunteer
......@@ -80,6 +80,22 @@ class VolunteersController < ApplicationController
@seeking_clients = @q.result.paginate(page: params[:page])
end
def account
@volunteer.contact.assign_attributes(validate_email_format: true,
primary_email: @volunteer.import.store['haupt_person']['email'])
if @volunteer.save
invite_volunteer_user
elsif @volunteer.contact.errors.messages[:primary_email].any?
redirect_to @volunteer, notice: {
message: 'Die Mailadresse ist scheinbar nicht gültig',
model_message: 'Für einen Useraccount wird eine gültige Email benötigt.',
action_link: { text: 'Mailadresse konfigurieren', path: edit_volunteer_path(@volunteer) }
}
else
redirect_to @volunteer, notice: 'Account erstellen fehlgeschlagen!'
end
end
private
def not_resigned
......
class Contact < ApplicationRecord
attr_accessor :validate_email_format
before_save :update_full_name, if: :full_name_changed?, unless: :department?
belongs_to :contactable, polymorphic: true, optional: true
......@@ -6,6 +8,9 @@ class Contact < ApplicationRecord
validates :last_name, presence: true, if: :validate_last_name?
validates :first_name, presence: true, if: :validate_first_name?
validates :primary_email, presence: true, if: :needs_primary_email?
validates :primary_email, format: { with: Devise.email_regexp }, if: :validate_email_format
validates :primary_phone, presence: true, if: :needs_primary_phone?
validates :street, :postal_code, :city, presence: true, if: :needs_address?
......
......@@ -21,6 +21,7 @@ class VolunteerPolicy < ApplicationPolicy
alias_method :show?, :volunteer_managing_or_volunteers_profile?
alias_method :edit?, :volunteer_managing_or_volunteers_profile?
alias_method :update?, :volunteer_managing_or_volunteers_profile?
alias_method :account?, :superadmin?
# supplementary policies
alias_method :superadmin_privileges?, :superadmin?
......
......@@ -38,7 +38,22 @@ nav.navbar.section-navigation
li= form_navigation_btn :back, with_row: false unless current_user.volunteer?
- if policy(Volunteer).superadmin_privileges?
h3= t('checklist')
- if @volunteer.accepted? && @volunteer.import.present?
- if @volunteer.user.present?
h2.small Importiert
p.text-warning Dieses Freiwilligenprofil wurde von Access importiert. Ein Useraccount wurde bereits erstellt.
- if @volunteer.user.blank? && @volunteer.import.store['haupt_person']['email'].present?
h2.small Import
p.text-warning Dieses Freiwilligenprofil wurde von Access importiert.
h3 User Account erstellen
p
'Für die Emailadresse
= mail_to "#{@volunteer.import.store['haupt_person']['email']}", @volunteer.import.store['haupt_person']['email']
= ' einen '
= link_to "Account erstellen",
account_volunteer_path(@volunteer), method: :put, class: 'btn btn-default btn-xs'
h2.small= t('checklist')
.table-responsive
table.table.table-no-border-top
tbody
......
......@@ -97,6 +97,7 @@ Rails.application.routes.draw do
resources :volunteers, except: [:destroy], concerns: :search do
put :terminate, on: :member
put :account, on: :member
get :find_client, on: :member, to: 'assignments#find_client'
get :seeking_clients, on: :collection
......
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