Commit 35fdcd00 authored by Kaspar Vollenweider's avatar Kaspar Vollenweider 👻 Committed by Kaspar
Browse files

record who filled the volunteer, if the volunteer didn't self apply

parent 2f50976c
......@@ -24,6 +24,7 @@ class VolunteersController < ApplicationController
@volunteer = Volunteer.new(volunteer_params)
@volunteer.schedules << Schedule.build
@volunteer.build_contact
@volunteer.registrar = current_user
authorize @volunteer
if @volunteer.save
redirect_to @volunteer, notice: t('volunteer_created')
......
......@@ -54,6 +54,10 @@ class User < ApplicationRecord
email
end
def full_name
"#{profile.contact.first_name} #{profile.contact.last_name}"
end
def self.role_collection
ROLES_FOR_USER_CREATE.map(&:to_sym)
end
......
class Volunteer < ApplicationRecord
include AssociatableFields
include GenderCollection
include FullName
has_one :contact, as: :contactable
accepts_nested_attributes_for :contact
......@@ -19,6 +20,9 @@ class Volunteer < ApplicationRecord
STATES = [REGISTERED] + STATES_FOR_REVIEWED
belongs_to :user, optional: true
belongs_to :registrar, optional: true,
class_name: 'User', foreign_key: 'registrar_id'
has_attached_file :avatar, styles: { thumb: '100x100#' }
validates :state, inclusion: { in: STATES }
......
......@@ -19,6 +19,10 @@ tr
td
- if volunteer.contact.contact_emails.any?
= link_to volunteer.contact.contact_emails.first.body
- if volunteer.registrar.present?
= volunteer.registrar.full_name
- else
= 'Selbstanmelder'
td = link_to t_action(:show), volunteer
td = link_to t_action(:edit), edit_volunteer_path(volunteer)
td = link_to t_action(:destroy), volunteer, data: { confirm: t_confirm_delete(volunteer) }, method: :delete
......@@ -127,6 +127,7 @@ de:
woman: Frau
working_percent: Stellenprozent
zip: Postleitzahl
registrar: Registrator
errors:
models:
profile:
......
......@@ -5,6 +5,7 @@ class AddMissingFieldsToVolunteers < ActiveRecord::Migration[5.1]
t.text :volunteer_experience_desc
t.string :region_specific
t.remove :skills
t.bigint :registrar_id
end
change_table :contacts do |t|
......
......@@ -174,7 +174,6 @@ ActiveRecord::Schema.define(version: 20170627103507) do
t.boolean "experience"
t.text "expectations"
t.text "strengths"
t.text "skills"
t.text "interests"
t.string "state", default: "registered"
t.string "duration"
......@@ -202,10 +201,10 @@ ActiveRecord::Schema.define(version: 20170627103507) do
t.bigint "user_id"
t.string "rejection_type"
t.text "rejection_text"
t.boolean "active"
t.string "working_percent"
t.text "volunteer_experience_desc"
t.string "region_specific"
t.bigint "registrar_id"
t.index ["deleted_at"], name: "index_volunteers_on_deleted_at"
t.index ["user_id"], name: "index_volunteers_on_user_id"
end
......
Supports Markdown
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