Refactoring of invitations.

This commit is contained in:
Benjamin Meichsner 2009-02-02 00:09:50 +01:00
parent d75c206db5
commit aa47a24fda
3 changed files with 41 additions and 35 deletions

View file

@ -102,31 +102,27 @@ class LoginController < ApplicationController
def invite
@invite = Invite.find_by_token(params[:id])
if (@invite.nil? || @invite.expires_at < Time.now)
flash[:error] = _("Your invitation is invalid or has expired, sorry!")
flash[:error] = "Deine Einladung ist nicht (mehr) gültig."
render :action => 'login'
elsif @invite.group.nil?
flash[:error] = _("The group you are invited to join doesn't exist any more!")
flash[:error] = "Die Gruppe, in die Du eingeladen wurdest, existiert leider nicht mehr."
render :action => 'login'
elsif (request.post?)
User.transaction do
@user = User.new(params[:user])
@user.email = @invite.email
@user.set_password({:required => true}, params[:user][:password], params[:user][:password_confirmation])
if (@user.errors.empty? && @user.save)
if @user.save
Membership.new(:user => @user, :group => @invite.group).save!
for setting in User::setting_keys.keys
@user.settings[setting] = (params[:user][:settings] && params[:user][:settings][setting] == '1' ? '1' : nil)
end
@invite.destroy
flash[:notice] = _("Congratulations, your account has been created successfully. You can log in now.")
render(:action => 'login')
flash[:notice] = "Herzlichen Glückwunsch, Dein Account wurde erstellt. Du kannst Dich nun einloggen."
render :action => 'login'
end
end
else
@user = User.new(:email => @invite.email)
end
rescue
flash[:error] = _("An error has occured. Please try again.")
flash[:error] = "Ein Fehler ist aufgetreten. Bitte erneut versuchen."
end
end

View file

@ -1,47 +1,54 @@
%h1=_ 'Invitation'
- title "Einladung in die #{APP_CONFIG[:name]}"
%p
=_ 'You are invited to join:'
Du bist eingeladen worden in der Foodcoop
%b= @invite.group.name
%p=_ 'If you accept the invitation and want to join the foodcoop please fill out the form.'
mitzumachen.
%p
Wenn Du mitmachen möchtest, dann fülle bitte dieses Formular aus.
%p
Deine Daten werden selbstverständlich nicht an Dritte, aus was auch immer für
Gründen, weitergeben. Du kannst auch entscheiden, wieviel deiner persönlichen
Daten für alle einsehbar sein sollen. 'Alle' bedeutet hier alle Foodcoop-Mitglieder.
Die Administratoren haben aber jederzeit Zugriff auf deine Daten.
.edit_form{:style => "width:25em"}
- form_for(:user, @user) do |u|
- form_for @user, :url => {:action => 'invite'} do |form|
- if flash[:error]
%p= flash[:error]
= error_messages_for('user')
= form.error_messages
%p
%label{:for => 'nick'}=_ 'Nickname (for log in)'
Benutzerinnenname (für das Anmelden in der Foodsoft)
%br/
= u.text_field 'nick', :maxlength => 25
= form.text_field :nick, :maxlength => 25
%p
%label{:for => 'first_name'}=_ 'First name'
Vorname
%br/
= u.text_field 'first_name', :maxlength => 50, :size => 25
= form.text_field :first_name, :maxlength => 50, :size => 25
%p
%label{:for => 'last_name'}=_ 'Last name'
Nachname
%br/
= u.text_field 'last_name'
= form.text_field :last_name
%p
%label{:for => 'phone'}=_ 'Phone'
Telefon
%br/
= u.text_field 'phone'
= form.text_field :phone
%p
%label{:for => 'address'}=_ 'Address'
Adresse
%br/
= u.text_field 'address'
= form.text_field :address
%p
%label{:for => 'password'}=_ 'Password'
Passwort
%br/
= password_field_tag 'user[password]'
= form.password_field :password
%p
%label{:for => 'password_confirmation'}=_ 'Passwort confirmation'
bitte Passwort wiederholen
%br/
= password_field_tag 'user[password_confirmation]'
= form.password_field :password_confirmation
%h3=_ 'Settings'
%h3 Einstellungen
- for setting in User::setting_keys.keys
%p
= check_box_tag "user[settings][#{setting}]", '1', @user.settings[setting] == '1' || @user.settings_default(setting)
%label{:for => "user[settings][#{setting}]"}= User::setting_keys[setting]
= check_box_tag "user[setting_attributes][#{setting}]", '1', @user.settings[setting] == '1' || @user.settings_default(setting)
%label{:for => "user[setting_attributes][#{setting}]"}= User::setting_keys[setting]
= submit_tag _('Send')
= javascript_tag("$('user_login').focus()")
= submit_tag "Absenden"
= javascript_tag("$('user_nick').focus()")

View file

@ -126,3 +126,6 @@ de:
article:
price: Nettopreis
gross_price: Bruttopreis
user:
password: Passwort
first_name: Vorname