summaryrefslogtreecommitdiff
path: root/users
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-11-22 17:31:18 +0100
committerAzul <azul@leap.se>2012-11-22 17:31:18 +0100
commit33c124aa67788d5c64906f7b3e21ad383577b2a8 (patch)
treeda36967527c8edf6034e90c05acd956fa402ecbd /users
parentddd53a0841cb2af091e1ed3a6e69e9fc52977c08 (diff)
basic user edit form and actions
Diffstat (limited to 'users')
-rw-r--r--users/app/controllers/users_controller.rb10
-rw-r--r--users/app/views/sessions/_nav.html.haml2
-rw-r--r--users/app/views/users/_form.html.haml8
-rw-r--r--users/app/views/users/edit.html.haml3
-rw-r--r--users/app/views/users/new.html.haml8
-rw-r--r--users/config/routes.rb2
6 files changed, 24 insertions, 9 deletions
diff --git a/users/app/controllers/users_controller.rb b/users/app/controllers/users_controller.rb
index 82d2eac..46ecc32 100644
--- a/users/app/controllers/users_controller.rb
+++ b/users/app/controllers/users_controller.rb
@@ -15,4 +15,14 @@ class UsersController < ApplicationController
@user = e.document
respond_with(@user, :location => new_user_path)
end
+
+ def edit
+ @user = current_user
+ end
+
+ def update
+ @user = current_user
+ @user.update!(params[:user])
+ respond_with(@user, :location => edit_user_path(@user))
+ end
end
diff --git a/users/app/views/sessions/_nav.html.haml b/users/app/views/sessions/_nav.html.haml
index b738504..dab865e 100644
--- a/users/app/views/sessions/_nav.html.haml
+++ b/users/app/views/sessions/_nav.html.haml
@@ -1,6 +1,6 @@
- if logged_in?
%li
- = 'logged in as ' + current_user.login
+ = link_to current_user.login, edit_user_path(current_user)
%li
= link_to t(:logout), logout_path
- if admin?
diff --git a/users/app/views/users/_form.html.haml b/users/app/views/users/_form.html.haml
new file mode 100644
index 0000000..8914241
--- /dev/null
+++ b/users/app/views/users/_form.html.haml
@@ -0,0 +1,8 @@
+= simple_form_for @user, :validate => true, :html => {:class => 'form-horizontal'} do |f|
+ %legend
+ = @user.new_record? ? t(:signup_message) : t(:edit_settings)
+ = f.input :login, :input_html => { :id => :srp_username }
+ = f.input :password, :required => true, :validate => true, :input_html => { :id => :srp_password }
+ = f.input :password_confirmation, :required => true, :input_html => { :id => :srp_password_confirmation }
+ = f.button :submit, :class => 'btn-primary'
+ = link_to t(:cancel), root_url, :class => :btn
diff --git a/users/app/views/users/edit.html.haml b/users/app/views/users/edit.html.haml
new file mode 100644
index 0000000..8298443
--- /dev/null
+++ b/users/app/views/users/edit.html.haml
@@ -0,0 +1,3 @@
+.span8.offset2
+ %h2=t :settings
+ = render 'form'
diff --git a/users/app/views/users/new.html.haml b/users/app/views/users/new.html.haml
index be14c52..c1c4208 100644
--- a/users/app/views/users/new.html.haml
+++ b/users/app/views/users/new.html.haml
@@ -1,9 +1,3 @@
.span8.offset2
%h2=t :signup
- = simple_form_for @user, :validate => true, :html => {:class => 'form-horizontal'} do |f|
- %legend=t :signup_message
- = f.input :login, :input_html => { :id => :srp_username }
- = f.input :password, :required => true, :validate => true, :input_html => { :id => :srp_password }
- = f.input :password_confirmation, :required => true, :input_html => { :id => :srp_password_confirmation }
- = f.button :submit, :value => t(:signup), :class => 'btn-primary'
- = link_to t(:cancel), root_url, :class => :btn
+ = render 'form'
diff --git a/users/config/routes.rb b/users/config/routes.rb
index 522c40c..1d144b4 100644
--- a/users/config/routes.rb
+++ b/users/config/routes.rb
@@ -5,6 +5,6 @@ Rails.application.routes.draw do
resources :sessions, :only => [:new, :create, :update, :destroy]
get "signup" => "users#new", :as => "signup"
- resources :users, :only => [:new, :create]
+ resources :users
end