summaryrefslogtreecommitdiff
path: root/users/app
diff options
context:
space:
mode:
Diffstat (limited to 'users/app')
-rw-r--r--users/app/controllers/users_controller.rb16
-rw-r--r--users/app/helpers/users_helper.rb3
-rw-r--r--users/app/models/user.rb2
-rw-r--r--users/app/views/users/_deactivate_account.html.haml6
-rw-r--r--users/app/views/users/_enable_account.html.haml6
-rw-r--r--users/app/views/users/edit.html.haml2
-rw-r--r--users/app/views/users/show.html.haml2
7 files changed, 33 insertions, 4 deletions
diff --git a/users/app/controllers/users_controller.rb b/users/app/controllers/users_controller.rb
index 38a69e3..189e7d4 100644
--- a/users/app/controllers/users_controller.rb
+++ b/users/app/controllers/users_controller.rb
@@ -1,10 +1,10 @@
class UsersController < ApplicationController
before_filter :authorize, :only => [:show, :edit, :destroy, :update]
- before_filter :fetch_user, :only => [:show, :edit, :update, :destroy]
+ before_filter :fetch_user, :only => [:show, :edit, :update, :destroy, :deactivate, :enable]
before_filter :authorize_self, :only => [:update]
before_filter :set_anchor, :only => [:edit, :update]
- before_filter :authorize_admin, :only => [:index]
+ before_filter :authorize_admin, :only => [:index, :deactivate, :enable]
respond_to :json, :html
@@ -41,6 +41,18 @@ class UsersController < ApplicationController
respond_with @user, :location => edit_user_path(@user, :anchor => @anchor)
end
+ def deactivate
+ @user.enabled = false
+ @user.save
+ respond_with @user
+ end
+
+ def enable
+ @user.enabled = true
+ @user.save
+ respond_with @user
+ end
+
def destroy
@user.destroy
redirect_to admin? ? users_path : root_path
diff --git a/users/app/helpers/users_helper.rb b/users/app/helpers/users_helper.rb
index 9feae62..f731aab 100644
--- a/users/app/helpers/users_helper.rb
+++ b/users/app/helpers/users_helper.rb
@@ -33,7 +33,8 @@ module UsersHelper
def user_field(field)
value = @user.send(field)
value = value.to_s(:long) if field.end_with? '_at'
- value || 'not set'
+ value = 'not set' if value.nil?
+ value
end
def wrapped(item, options = {})
diff --git a/users/app/models/user.rb b/users/app/models/user.rb
index 5c849f0..0cf37cf 100644
--- a/users/app/models/user.rb
+++ b/users/app/models/user.rb
@@ -11,6 +11,8 @@ class User < CouchRest::Model::Base
property :public_key, :accessible => true
+ property :enabled, TrueClass, :default => true
+
validates :login, :password_salt, :password_verifier,
:presence => true
diff --git a/users/app/views/users/_deactivate_account.html.haml b/users/app/views/users/_deactivate_account.html.haml
new file mode 100644
index 0000000..fec0afa
--- /dev/null
+++ b/users/app/views/users/_deactivate_account.html.haml
@@ -0,0 +1,6 @@
+%legend
+ =t :deactivate_account
+ %small=t :deactivate_description
+= link_to deactivate_user_path(@user), :method => :post, :class => "btn" do
+ %i.icon-remove.icon-white
+ =t :deactivate_account \ No newline at end of file
diff --git a/users/app/views/users/_enable_account.html.haml b/users/app/views/users/_enable_account.html.haml
new file mode 100644
index 0000000..5ecca48
--- /dev/null
+++ b/users/app/views/users/_enable_account.html.haml
@@ -0,0 +1,6 @@
+%legend
+ =t :enable_account
+ %small=t :enable_description
+= link_to enable_user_path(@user), :method => :post, :class => "btn" do
+ %i.icon-remove.icon-white
+ =t :enable_account \ No newline at end of file
diff --git a/users/app/views/users/edit.html.haml b/users/app/views/users/edit.html.haml
index 97bd48d..49b4f6c 100644
--- a/users/app/views/users/edit.html.haml
+++ b/users/app/views/users/edit.html.haml
@@ -3,6 +3,8 @@
- tabs = []
- content_for :account do
= user_form_with 'login_and_password_fields', :legend => :update_login_and_password if @user == current_user
+ = render 'deactivate_account' if @user != current_user and @user.enabled?
+ = render 'enable_account' if @user != current_user and !@user.enabled?
= render 'cancel_account'
- tabs << :account
- if @user == current_user
diff --git a/users/app/views/users/show.html.haml b/users/app/views/users/show.html.haml
index 056ed57..52a9cf5 100644
--- a/users/app/views/users/show.html.haml
+++ b/users/app/views/users/show.html.haml
@@ -3,7 +3,7 @@
.small
= link_to 'edit', edit_user_path(@user)
%dl.offset1
- - fields = ['login', 'email_address', 'created_at', 'updated_at', 'email_forward']
+ - fields = ['login', 'email_address', 'created_at', 'updated_at', 'email_forward', 'enabled']
- fields.each do |field|
%dt
= field.titleize