Fixed new user invite.

This commit is contained in:
benni 2012-08-06 12:00:40 +02:00
parent fc8418bc8e
commit 6f7682d6a0
16 changed files with 59 additions and 91 deletions

View file

@ -2,7 +2,7 @@
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
protect_from_forgery protect_from_forgery
before_filter :select_foodcoop, :authenticate, :store_controller, :items_per_page before_filter :select_foodcoop, :authenticate, :store_controller, :items_per_page, :set_redirect_to
after_filter :remove_controller after_filter :remove_controller
helper_method :current_user helper_method :current_user
@ -90,12 +90,7 @@ class ApplicationController < ActionController::Base
def authenticate_membership_or_admin def authenticate_membership_or_admin
@group = Group.find(params[:id]) @group = Group.find(params[:id])
unless @group.member?(@current_user) or @current_user.role_admin? unless @group.member?(@current_user) or @current_user.role_admin?
flash[:error] = "Diese Aktion ist nur für Mitglieder der Gruppe erlaubt!" redirect_to root_path, alert: "Diese Aktion ist nur für Mitglieder der Gruppe erlaubt!"
if request.xml_http_request?
render(:update) {|page| page.redirect_to root_path }
else
redirect_to root_path
end
end end
end end
@ -145,4 +140,16 @@ class ApplicationController < ActionController::Base
@per_page = 20 @per_page = 20
end end
end end
def set_redirect_to
session[:redirect_to] = params[:redirect_to] if params[:redirect_to]
end
def back_or_default_path(default = root_path)
if session[:redirect_to].present?
default = session[:redirect_to]
session[:redirect_to] = nil
end
default
end
end end

View file

@ -5,22 +5,14 @@ class InvitesController < ApplicationController
def new def new
@invite = Invite.new(:user => @current_user, :group => @group) @invite = Invite.new(:user => @current_user, :group => @group)
render :update do |page|
page.replace_html :edit_box, :partial => "new"
page.show :edit_box
end
end end
def create def create
@invite = Invite.new(params[:invite]) @invite = Invite.new(params[:invite])
render :update do |page|
if @invite.save if @invite.save
page.replace_html :edit_box, :partial => "success" redirect_to back_or_default_path, notice: "Benutzerin wurde erfolgreich eingeladen."
else else
page.replace_html :edit_box, :partial => "new" render action: :new
end
end end
end end
end end

View file

@ -1,9 +1,8 @@
# encoding: utf-8
class LoginController < ApplicationController class LoginController < ApplicationController
skip_before_filter :authenticate # no authentication since this is the login page skip_before_filter :authenticate # no authentication since this is the login page
before_filter :validate_token, :only => [:password, :update_password] before_filter :validate_token, :only => [:password, :update_password]
verify :method => :post, :only => [:reset_password], :redirect_to => { :action => 'forgot_password' }
# Display the form to enter an email address requesting a token to set a new password. # Display the form to enter an email address requesting a token to set a new password.
def forgot_password def forgot_password
end end
@ -56,8 +55,7 @@ class LoginController < ApplicationController
if @user.save if @user.save
Membership.new(:user => @user, :group => @invite.group).save! Membership.new(:user => @user, :group => @invite.group).save!
@invite.destroy @invite.destroy
flash[:notice] = "Herzlichen Glückwunsch, Dein Account wurde erstellt. Du kannst Dich nun einloggen." redirect_to login_url, notice: "Herzlichen Glückwunsch, Dein Account wurde erstellt. Du kannst Dich nun einloggen."
render :action => 'login'
end end
end end
else else

View file

@ -1,3 +1,4 @@
# encoding: utf-8
# ActionMailer class that handles all emails for the FoodSoft. # ActionMailer class that handles all emails for the FoodSoft.
class Mailer < ActionMailer::Base class Mailer < ActionMailer::Base

View file

@ -1,3 +1,7 @@
%p
Neue Mitglieder kannst du
= link_to "hier", new_invite_path(id: @ordergroup.id)
einladen.
= simple_form_for [:admin, @ordergroup] do |f| = simple_form_for [:admin, @ordergroup] do |f|
= render :layout => 'shared/group_form_fields', :locals => {:f => f} do = render :layout => 'shared/group_form_fields', :locals => {:f => f} do
= f.input :contact_person = f.input :contact_person

View file

@ -1,3 +1,7 @@
%p
Neue Mitglieder kannst du
= link_to "hier", new_invite_path(id: @workgroup.id)
einladen.
= simple_form_for [:admin, @workgroup] do |f| = simple_form_for [:admin, @workgroup] do |f|
= render :layout => 'shared/group_form_fields', :locals => {:f => f} do = render :layout => 'shared/group_form_fields', :locals => {:f => f} do
%h3 Zugriff auf .. %h3 Zugriff auf ..

View file

@ -1,5 +1,9 @@
- title "Gruppe bearbeiten" - title "Gruppe bearbeiten"
%p
Neue Mitglieder kannst du
= link_to "hier", new_invite_path(id: @workgroup.id)
einladen.
= simple_form_for [:foodcoop, @workgroup] do |f| = simple_form_for [:foodcoop, @workgroup] do |f|
= render :partial => 'shared/group_form_fields', :locals => {:f => f} = render :partial => 'shared/group_form_fields', :locals => {:f => f}
= f.submit = f.submit

View file

@ -18,6 +18,7 @@
- for membership in Membership.find_all_by_user_id(@user.id) - for membership in Membership.find_all_by_user_id(@user.id)
%p %p
= membership.group.name = membership.group.name
= link_to "Neue Mitglieder einladen", new_invite_path(id: membership.group_id)
- if membership.group.type != 'Ordergroup' - if membership.group.type != 'Ordergroup'
= link_to "Mitgliedschaft beenden", cancel_membership_path(membership_id: membership), = link_to "Mitgliedschaft beenden", cancel_membership_path(membership_id: membership),
confirm: "Bist Du sicher, dass Du Deine Mitgliedschaft beenden willst?", method: :post confirm: "Bist Du sicher, dass Du Deine Mitgliedschaft beenden willst?", method: :post

View file

@ -1,16 +0,0 @@
%p
Hier kannst du eine Person in die Gruppe
%b=h @invite.group.name
einladen, die noch nicht Mitglied der Foodcoop ist.
.edit_form{:style => 'width:35em'}
- remote_form_for @invite do |form|
= form.error_messages :header_message => nil
= form.hidden_field :user_id
= form.hidden_field :group_id
%p
Email-Adresse:
= form.text_field :email, :size => 40, :maxlength => 128
%p
= submit_tag('Einladung abschicken')
oder
= link_to_function "Abbrechen", "Element.hide('edit_box')"

View file

@ -1,7 +0,0 @@
%p
%b= @invite.email
wurde erfolgreich eingeladen.
%p
= link_to_function "Schließen", "Element.hide('edit_box')"
oder
= remote_link_to "Weitere Person einladen", :url => new_invite_path(:id => @invite.group)

View file

@ -0,0 +1,10 @@
%p
Hier kannst du eine Person in die Gruppe
%b=h @invite.group.name
einladen, die noch nicht Mitglied der Foodcoop ist.
= simple_form_for @invite do |form|
= form.hidden_field :user_id
= form.hidden_field :group_id
= form.input :email
= form.submit "Einladung abschicken"
= link_to "oder zurück", :back

View file

@ -3,7 +3,7 @@
%head %head
%meta{"http-equiv" => "content-type", :content => "text/html;charset=UTF-8"} %meta{"http-equiv" => "content-type", :content => "text/html;charset=UTF-8"}
%title= "FoodSoft - " + (yield(:title) or controller.controller_name) %title= "FoodSoft - " + (yield(:title) or controller.controller_name)
= stylesheet_link_tag 'main', 'rails_messages', 'nav', :cache => "all_cached" = stylesheet_link_tag 'main', 'rails_messages', 'nav', 'simple_form', :cache => "login_cached"
= javascript_include_tag 'jquery.min' = javascript_include_tag 'jquery.min'
= yield(:head) = yield(:head)
%body %body

View file

@ -12,41 +12,7 @@
Gründen, weitergeben. Du kannst auch entscheiden, wieviel deiner persönlichen Gründen, weitergeben. Du kannst auch entscheiden, wieviel deiner persönlichen
Daten für alle einsehbar sein sollen. 'Alle' bedeutet hier alle Foodcoop-Mitglieder. Daten für alle einsehbar sein sollen. 'Alle' bedeutet hier alle Foodcoop-Mitglieder.
Die Administratoren haben aber jederzeit Zugriff auf deine Daten. Die Administratoren haben aber jederzeit Zugriff auf deine Daten.
.edit_form{:style => "width:25em"} = simple_form_for @user, url: {action: 'invite'} do |form|
- form_for @user, :url => {:action => 'invite'} do |form| = render partial: 'shared/user_form_fields', locals: {f: form}
- if flash[:error]
%p= flash[:error]
= form.error_messages
%p
Benutzerinnenname (für das Anmelden in der Foodsoft)
%br/
= form.text_field :nick, :maxlength => 25
%p
Vorname
%br/
= form.text_field :first_name, :maxlength => 50, :size => 25
%p
Nachname
%br/
= form.text_field :last_name
%p
Telefon
%br/
= form.text_field :phone
%p
Passwort
%br/
= form.password_field :password
%p
bitte Passwort wiederholen
%br/
= form.password_field :password_confirmation
%h3 Einstellungen
- for setting in User::setting_keys.keys
%p
= 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 "Absenden" = submit_tag "Absenden"
= javascript_tag("$('user_nick').focus()") = javascript_tag("$('user_nick').focus()")

View file

@ -280,6 +280,10 @@ de:
amount: 'Betrag' amount: 'Betrag'
phone: "Telefon" phone: "Telefon"
user_tokens: 'Mitglieder' user_tokens: 'Mitglieder'
user:
nick: "Benutzerinnenname"
first_name: "Vorname"
last_name: "Nachname"
workgroup: workgroup:
weekly_task: 'Monatlichen Job definieren?' weekly_task: 'Monatlichen Job definieren?'
weekday: 'Wochentag' weekday: 'Wochentag'

View file

@ -98,7 +98,7 @@ option {
#login { #login {
margin: auto; margin: auto;
width: 27em; width: 35em;
font-size: 1.2em; } font-size: 1.2em; }
#login #meta { #login #meta {

View file

@ -107,7 +107,7 @@ option
// ********************************* loginpage // ********************************* loginpage
#login #login
:margin auto :margin auto
:width 27em :width 35em
:font-size 1.2em :font-size 1.2em
#login #meta #login #meta