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

finalizing assigning email only thru input field

parent bf8a3d7f
Pipeline #15385 failed with stage
in 27 minutes and 22 seconds
......@@ -82,9 +82,11 @@ class VolunteersController < ApplicationController
def account
@volunteer.contact.assign_attributes(validate_email_format: true,
primary_email: @volunteer.import.store['haupt_person']['email'])
primary_email: volunteer_params[:contact_attributes][:primary_email])
if @volunteer.save
invite_volunteer_user
redirect_back(fallback_location: volunteer_path(@volunteer),
notice: 'Freiwillige/r erhält eine Accountaktivierungs-Email.')
elsif @volunteer.contact.errors.messages[:primary_email].any?
redirect_to @volunteer, notice: {
message: 'Die Mailadresse ist scheinbar nicht gültig',
......
......@@ -20,4 +20,16 @@ class Import < ApplicationRecord
def self.find_by_hauptperson(hauptperson_id)
with_deleted.find_by('store @> ?', { haupt_person: { pk_Hauptperson: hauptperson_id } }.to_json)
end
def volunteer?
importable_type == 'Volunteer'
end
def email
@email ||= store['haupt_person']['email'] if volunteer?
end
def email_valid?
@email_valid ||= email.match(Devise.email_regexp) if volunteer? && email.present?
end
end
......@@ -4,14 +4,19 @@ p.text-warning Dieses Freiwilligenprofil wurde von Access importiert.
p.text-warning Ein Useraccount wurde bereits erstellt.
- elsif volunteer.user.blank? && volunteer.accepted?
h3.small User Account erstellen
- if volunteer.import.store['haupt_person']['email'].present?
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'
- if volunteer.import.email_valid?
p Für die Emailadresse #{mail_to "#{volunteer.import.email}", volunteer.import.email} einen Account erstellen
- elsif volunteer.import.email.present?
p.text-danger Scheinbar ist die importierte Mailadresse nicht gültig.
- else
= simple_form_for(volunteer, url: account_volunteer_path(volunteer)) do |f|
= f.simple_fields_for(:contact) |c|
p.text-warning Es wird eine gültige Emailadresse des Freiwilligen benötigt, um einen Useraccount zu erstellen.
p Bitte stellen Sie sicher das die importierte Mailadresse des Freiwilligen korrekt ist.
= simple_form_for(volunteer, url: account_volunteer_path(volunteer), method: :put) do |f|
.row
= f.simple_fields_for(:contact) do |c|
.form-group.col-xs-12.col-md-4
= c.label :primary_email
= c.input_field :primary_email, value: volunteer.import.email_valid? ? volunteer.import.email : '',
class: 'form-control'
= f.button :submit, value: 'Account mit angegebener Email erstellen'
......@@ -14,8 +14,13 @@ tr
td = volunteer.expectations
td = volunteer.interests
- if policy(Volunteer).show_acceptance?
td.button-acceptance = link_to t(".acceptance.#{volunteer.acceptance}"), '#',
class: "btn btn-xs btn-acceptance-#{volunteer.acceptance}"
td.button-acceptance.index-action-cell
= link_to t(".acceptance.#{volunteer.acceptance}"), '#',
class: "btn btn-xs btn-acceptance-#{volunteer.acceptance}"
- if !volunteer.external && volunteer.user.blank?
span Kein Login
- if volunteer.import.present?
span Importiert
td = volunteer.external? ? t_attr(:external) : t_attr(:internal)
td
- if volunteer.self_applicant?
......
......@@ -39,7 +39,7 @@ nav.navbar.section-navigation
- if policy(Volunteer).superadmin_privileges?
- if @volunteer.import.present?
= render 'import_acount_invite', volunteer: @volunteer
= render 'import_account_invite', volunteer: @volunteer
h2.small= t('checklist')
......
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