Commit 13599a60 authored by Kaspar Vollenweider's avatar Kaspar Vollenweider 👻 Committed by Kaspar
Browse files

concern for automatic controller create, update, destroy notices

parent b4a3e292
class ClientsController < ApplicationController
include NestedAttributes
include ContactAttributes
include MakeNotice
before_action :set_client, only: [:show, :edit, :update, :destroy]
......@@ -24,7 +25,7 @@ class ClientsController < ApplicationController
@client.user = current_user
authorize @client
if @client.save
redirect_to @client, notice: t('client_created')
redirect_to @client, make_notice
else
render :new
end
......@@ -32,7 +33,7 @@ class ClientsController < ApplicationController
def update
if @client.update(client_params)
redirect_to @client, notice: t('client_updated')
redirect_to @client, make_notice
else
render :edit
end
......@@ -40,7 +41,7 @@ class ClientsController < ApplicationController
def destroy
@client.destroy
redirect_to clients_url, notice: t('client_destroyed')
redirect_to clients_url, make_notice
end
private
......
class ProfilesController < ApplicationController
include ContactAttributes
include MakeNotice
before_action :set_profile, only: [:show, :edit, :update]
......@@ -16,7 +17,7 @@ class ProfilesController < ApplicationController
def create
@profile = Profile.new(profile_params)
if @profile.save
redirect_to @profile, notice: t('profile_created')
redirect_to @profile, make_notice
else
render :new
end
......@@ -25,7 +26,7 @@ class ProfilesController < ApplicationController
def update
if @profile.update(profile_params)
redirect_to @profile, notice: t('profile_updated')
redirect_to @profile, make_notice
else
render :edit unless @profile.update(profile_params)
end
......
......@@ -2,6 +2,7 @@ class VolunteerApplicationsController < ApplicationController
include NestedAttributes
include ContactAttributes
include VolunteerAttributes
skip_before_action :authenticate_user!
def new
......
......@@ -2,6 +2,8 @@ class VolunteersController < ApplicationController
include NestedAttributes
include ContactAttributes
include VolunteerAttributes
include MakeNotice
before_action :set_volunteer, only: [:show, :edit, :update, :destroy]
def index
......@@ -25,7 +27,7 @@ class VolunteersController < ApplicationController
@volunteer.registrar = current_user
authorize @volunteer
if @volunteer.save
redirect_to @volunteer, notice: t('volunteer_created')
redirect_to @volunteer, make_notice
else
render :new
end
......@@ -38,13 +40,13 @@ class VolunteersController < ApplicationController
redirect_to volunteers_path,
notice: t('invite_sent', email: @volunteer.contact.contact_emails.first.body)
else
redirect_to @volunteer, notice: t('volunteer_updated')
redirect_to @volunteer, make_notice
end
end
def destroy
@volunteer.destroy
redirect_to volunteers_url, notice: t('volunteer_destroyed')
redirect_to volunteers_url, make_notice
end
private
......
......@@ -191,9 +191,6 @@ de:
back: Zurück
change_my_password: Ihr Passwort ändern
change_password: Ihr Passwort ändern
client_created: KlientIn wurde erfolgreich erstellt.
client_destroyed: KlientIn wurde erfolgreich gelöscht.
client_updated: KlientIn wurde erfolgreich aktualisiert.
clients: Klienten
contact_info: Kontakt Informationen
contacts:
......@@ -216,9 +213,6 @@ de:
- :month
- :year
department_confirm_destroy: Sind Sie sicher das Sie den Standort löschen wollen?
department_created: Der Standort wurde erfolgreich erstellt.
department_destroyed: Der Standort wurde erfolgreich gelöscht.
department_updated: Der Standort wurde erfolgreich geändert.
departments: Standorte
devise:
confirmations:
......@@ -346,8 +340,6 @@ de:
other_request: Sonstige Anforderungen an den Freiwilligen
password_reset_instructions: Ich möchte mein Passwort zurücksetzen
personal_background: Persönlicher Hintergrund
profile_created: Profil wurde erfolgreich erstellt.
profile_updated: Profil wurde erfolgreich aktualisiert.
region: &id-regions
canton: Kanton
city: Stadt
......@@ -473,10 +465,7 @@ de:
users: Benutzer
voluntary_platform: Freiwilligen Plattform
volunteer_application: Freiwillige/n Bewerbung
volunteer_created: Freiwillige wurde erfolgreich erstellt.
volunteer_destroyed: Freiwillige wurde erfolgreich gelöscht.
volunteer_request: Anforderungen an den Freiwilligen
volunteer_updated: Freiwillige wurde erfolgreich aktualisiert.
volunteers: Freiwillige
wanna_apply: Möchten Sie sich als Freiwillige/n bewerben?
weekdays:
......
......@@ -60,9 +60,6 @@ en:
back: Back
change_my_password: Change my password
change_password: Change your password
client_created: Client was successfully created.
client_destroyed: Client was successfully deleted.
client_updated: Client was successfully updated.
clients: Clients
contact_info: Contact information
contacts:
......@@ -74,9 +71,9 @@ en:
create_user: Create user
crud:
c_action:
create: '%{model} wurde erfolgreich erstellt.'
update: '%{model} wurde erfolgreich geändert.'
destroy: '%{model} wurde erfolgreich gelöscht.'
create: '%{model} was successfully created.'
update: '%{model} was successfully updated.'
destroy: '%{model} was successfully deleted.'
title:
add: 'Add %{model}'
date:
......@@ -84,9 +81,6 @@ en:
- :day
- :month
- :year
department_created: Department was successfully created.
department_destroyed: Department was successfully deleted.
department_updated: Department was successfully updated.
departments: Departments
devise:
confirmations:
......@@ -219,8 +213,6 @@ en:
other_request: Other requests for volunteers
password_reset_instructions: I want to reset my password
personal_background: Personal background
profile_created: Profile was successfully created.
profile_updated: Profile was successfully updated.
region: &id-regions
canton: Canton
city: City
......@@ -328,10 +320,7 @@ en:
users: Users
voluntary_platform: Voluntaries Platform
volunteer_application: Volunteer Application
volunteer_created: Volunteer was successfully created.
volunteer_destroyed: Volunteer was successfully deleted.
volunteer_request: Request for volunteers
volunteer_updated: Volunteer was successfully updated.
volunteers: Volunteers
wanna_apply: Do you want to apply as a volunteer?
weekdays:
......
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