Fixed new user invite.
This commit is contained in:
parent
fc8418bc8e
commit
6f7682d6a0
16 changed files with 59 additions and 91 deletions
|
@ -2,7 +2,7 @@
|
|||
class ApplicationController < ActionController::Base
|
||||
|
||||
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
|
||||
|
||||
helper_method :current_user
|
||||
|
@ -90,12 +90,7 @@ class ApplicationController < ActionController::Base
|
|||
def authenticate_membership_or_admin
|
||||
@group = Group.find(params[:id])
|
||||
unless @group.member?(@current_user) or @current_user.role_admin?
|
||||
flash[:error] = "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
|
||||
redirect_to root_path, alert: "Diese Aktion ist nur für Mitglieder der Gruppe erlaubt!"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -145,4 +140,16 @@ class ApplicationController < ActionController::Base
|
|||
@per_page = 20
|
||||
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
|
||||
|
|
|
@ -5,22 +5,14 @@ class InvitesController < ApplicationController
|
|||
|
||||
def new
|
||||
@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
|
||||
|
||||
def create
|
||||
@invite = Invite.new(params[:invite])
|
||||
|
||||
render :update do |page|
|
||||
if @invite.save
|
||||
page.replace_html :edit_box, :partial => "success"
|
||||
else
|
||||
page.replace_html :edit_box, :partial => "new"
|
||||
end
|
||||
if @invite.save
|
||||
redirect_to back_or_default_path, notice: "Benutzerin wurde erfolgreich eingeladen."
|
||||
else
|
||||
render action: :new
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
# encoding: utf-8
|
||||
class LoginController < ApplicationController
|
||||
skip_before_filter :authenticate # no authentication since this is the login page
|
||||
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.
|
||||
def forgot_password
|
||||
end
|
||||
|
@ -56,8 +55,7 @@ class LoginController < ApplicationController
|
|||
if @user.save
|
||||
Membership.new(:user => @user, :group => @invite.group).save!
|
||||
@invite.destroy
|
||||
flash[:notice] = "Herzlichen Glückwunsch, Dein Account wurde erstellt. Du kannst Dich nun einloggen."
|
||||
render :action => 'login'
|
||||
redirect_to login_url, notice: "Herzlichen Glückwunsch, Dein Account wurde erstellt. Du kannst Dich nun einloggen."
|
||||
end
|
||||
end
|
||||
else
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# encoding: utf-8
|
||||
# ActionMailer class that handles all emails for the FoodSoft.
|
||||
class Mailer < ActionMailer::Base
|
||||
|
||||
|
|
|
@ -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|
|
||||
= render :layout => 'shared/group_form_fields', :locals => {:f => f} do
|
||||
= f.input :contact_person
|
||||
|
|
|
@ -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|
|
||||
= render :layout => 'shared/group_form_fields', :locals => {:f => f} do
|
||||
%h3 Zugriff auf ..
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
- 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|
|
||||
= render :partial => 'shared/group_form_fields', :locals => {:f => f}
|
||||
= f.submit
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
- for membership in Membership.find_all_by_user_id(@user.id)
|
||||
%p
|
||||
= membership.group.name
|
||||
= link_to "Neue Mitglieder einladen", new_invite_path(id: membership.group_id)
|
||||
- if membership.group.type != 'Ordergroup'
|
||||
= link_to "Mitgliedschaft beenden", cancel_membership_path(membership_id: membership),
|
||||
confirm: "Bist Du sicher, dass Du Deine Mitgliedschaft beenden willst?", method: :post
|
||||
|
|
|
@ -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')"
|
|
@ -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)
|
10
app/views/invites/new.html.haml
Normal file
10
app/views/invites/new.html.haml
Normal 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
|
|
@ -3,7 +3,7 @@
|
|||
%head
|
||||
%meta{"http-equiv" => "content-type", :content => "text/html;charset=UTF-8"}
|
||||
%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'
|
||||
= yield(:head)
|
||||
%body
|
||||
|
|
|
@ -12,41 +12,7 @@
|
|||
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, :url => {:action => 'invite'} do |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"
|
||||
= simple_form_for @user, url: {action: 'invite'} do |form|
|
||||
= render partial: 'shared/user_form_fields', locals: {f: form}
|
||||
= submit_tag "Absenden"
|
||||
= javascript_tag("$('user_nick').focus()")
|
|
@ -280,6 +280,10 @@ de:
|
|||
amount: 'Betrag'
|
||||
phone: "Telefon"
|
||||
user_tokens: 'Mitglieder'
|
||||
user:
|
||||
nick: "Benutzerinnenname"
|
||||
first_name: "Vorname"
|
||||
last_name: "Nachname"
|
||||
workgroup:
|
||||
weekly_task: 'Monatlichen Job definieren?'
|
||||
weekday: 'Wochentag'
|
||||
|
|
|
@ -98,7 +98,7 @@ option {
|
|||
|
||||
#login {
|
||||
margin: auto;
|
||||
width: 27em;
|
||||
width: 35em;
|
||||
font-size: 1.2em; }
|
||||
|
||||
#login #meta {
|
||||
|
|
|
@ -107,7 +107,7 @@ option
|
|||
// ********************************* loginpage
|
||||
#login
|
||||
:margin auto
|
||||
:width 27em
|
||||
:width 35em
|
||||
:font-size 1.2em
|
||||
|
||||
#login #meta
|
||||
|
|
Loading…
Reference in a new issue