alchemy_cms 2.8.3 → 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/README.md +108 -25
- data/alchemy_cms.gemspec +0 -1
- data/app/assets/stylesheets/alchemy/archive.scss +2 -2
- data/app/assets/stylesheets/alchemy/base.scss +0 -37
- data/app/assets/stylesheets/alchemy/elements.scss +1 -1
- data/app/assets/stylesheets/alchemy/flash.scss +1 -1
- data/app/assets/stylesheets/alchemy/form_elements.scss +1 -1
- data/app/assets/stylesheets/alchemy/icon-font.css.scss +40 -40
- data/app/assets/stylesheets/alchemy/icons.scss +4 -32
- data/app/assets/stylesheets/alchemy/jquery-ui.scss +4 -4
- data/app/assets/stylesheets/alchemy/menubar.css.scss +20 -12
- data/app/assets/stylesheets/alchemy/modules.scss +0 -4
- data/app/assets/stylesheets/alchemy/search.scss +1 -1
- data/app/assets/stylesheets/alchemy/sitemap.scss +1 -1
- data/app/assets/stylesheets/tiny_mce/plugins/inlinepopups/skins/alchemy-tinymce-dialog/window.css.scss +3 -3
- data/app/controllers/alchemy/admin/base_controller.rb +12 -8
- data/app/controllers/alchemy/admin/dashboard_controller.rb +10 -5
- data/app/controllers/alchemy/admin/elements_controller.rb +1 -1
- data/app/controllers/alchemy/admin/essence_pictures_controller.rb +8 -1
- data/app/controllers/alchemy/admin/layoutpages_controller.rb +1 -1
- data/app/controllers/alchemy/admin/pages_controller.rb +11 -6
- data/app/controllers/alchemy/admin/resources_controller.rb +2 -2
- data/app/controllers/alchemy/admin/users_controller.rb +1 -1
- data/app/controllers/alchemy/base_controller.rb +71 -37
- data/app/controllers/alchemy/elements_controller.rb +1 -1
- data/app/controllers/alchemy/pages_controller.rb +9 -3
- data/app/controllers/alchemy/pictures_controller.rb +1 -0
- data/app/helpers/alchemy/admin/base_helper.rb +2 -10
- data/app/helpers/alchemy/admin/pages_helper.rb +1 -1
- data/app/helpers/alchemy/base_helper.rb +1 -1
- data/app/helpers/alchemy/pages_helper.rb +1 -1
- data/app/models/alchemy/attachment.rb +3 -4
- data/app/models/alchemy/cell.rb +1 -1
- data/app/models/alchemy/content.rb +3 -4
- data/app/models/alchemy/element.rb +5 -6
- data/app/models/alchemy/folded_page.rb +1 -1
- data/app/models/alchemy/language.rb +1 -1
- data/app/models/alchemy/message.rb +1 -7
- data/app/models/alchemy/page.rb +12 -10
- data/app/models/alchemy/page/{cells.rb → page_cells.rb} +2 -2
- data/app/models/alchemy/page/{elements.rb → page_elements.rb} +2 -2
- data/app/models/alchemy/page/{naming.rb → page_naming.rb} +1 -1
- data/app/models/alchemy/page/{natures.rb → page_natures.rb} +3 -3
- data/app/models/alchemy/page/{scopes.rb → page_scopes.rb} +3 -3
- data/app/models/alchemy/page/page_users.rb +33 -0
- data/app/models/alchemy/picture.rb +3 -3
- data/app/models/alchemy/site.rb +2 -2
- data/app/views/alchemy/admin/dashboard/_locked_pages.html.erb +1 -1
- data/app/views/alchemy/admin/dashboard/_recent_pages.html.erb +1 -1
- data/app/views/alchemy/admin/dashboard/_sites.html.erb +1 -1
- data/app/views/alchemy/admin/dashboard/index.html.erb +10 -4
- data/app/views/alchemy/admin/pages/_page.html.erb +1 -1
- data/app/views/alchemy/admin/pages/update.js.erb +1 -1
- data/app/views/alchemy/{user_sessions → base}/leave.html.erb +2 -2
- data/app/views/alchemy/base/permission_denied.js.erb +3 -2
- data/app/views/layouts/alchemy/admin.html.erb +6 -3
- data/config/alchemy/config.yml +1 -11
- data/config/alchemy/modules.yml +0 -12
- data/config/locales/alchemy.de.yml +3 -40
- data/config/locales/alchemy.en.yml +2 -22
- data/config/routes.rb +2 -27
- data/db/migrate/20130827094554_alchemy_two_point_six.rb +0 -31
- data/lib/alchemy/auth_accessors.rb +54 -0
- data/lib/alchemy/capistrano.rb +5 -17
- data/lib/alchemy/engine.rb +7 -7
- data/lib/alchemy/errors.rb +6 -0
- data/lib/alchemy/essence.rb +2 -2
- data/lib/alchemy/seeder.rb +1 -1
- data/lib/alchemy/tasks/helpers.rb +83 -0
- data/lib/alchemy/test_support/auth_helpers.rb +35 -0
- data/lib/alchemy/test_support/controller_requests.rb +37 -0
- data/{spec/support → lib/alchemy/test_support}/factories.rb +7 -28
- data/{spec/support/alchemy → lib/alchemy/test_support}/integration_helpers.rb +9 -36
- data/lib/alchemy/upgrader.rb +8 -7
- data/lib/alchemy/upgrader/two_point_nine.rb +33 -0
- data/lib/alchemy/userstamp.rb +10 -0
- data/lib/alchemy/version.rb +1 -3
- data/lib/rails/templates/alchemy.rb +1 -0
- data/lib/tasks/alchemy/db.rake +5 -5
- data/spec/controllers/admin/attachments_controller_spec.rb +3 -3
- data/spec/controllers/admin/dashboard_controller_spec.rb +55 -34
- data/spec/controllers/admin/elements_controller_spec.rb +1 -1
- data/spec/controllers/admin/essence_pictures_controller_spec.rb +22 -6
- data/spec/controllers/admin/pages_controller_spec.rb +41 -58
- data/spec/controllers/admin/resources_controller_spec.rb +30 -5
- data/spec/controllers/admin/trash_controller_spec.rb +1 -1
- data/spec/controllers/attachments_controller_spec.rb +26 -44
- data/spec/controllers/base_controller_spec.rb +8 -33
- data/spec/controllers/elements_controller_spec.rb +1 -1
- data/spec/controllers/pages_controller_spec.rb +7 -15
- data/spec/controllers/pictures_controller_spec.rb +44 -5
- data/spec/dummy/app/controllers/application_controller.rb +9 -1
- data/spec/dummy/app/models/user.rb +14 -0
- data/spec/dummy/db/migrate/20130827094554_alchemy_two_point_six.rb +0 -31
- data/spec/dummy/db/schema.rb +0 -31
- data/spec/features/admin/language_tree_feature_spec.rb +34 -0
- data/spec/features/admin/pages_controller_spec.rb +1 -1
- data/spec/features/pages_controller_spec.rb +5 -12
- data/spec/features/picture_security_spec.rb +2 -2
- data/spec/features/security_spec.rb +6 -45
- data/spec/features/translation_integration_spec.rb +11 -20
- data/spec/{support → fixtures}/80x60.png +0 -0
- data/spec/support/image with spaces.png b/data/spec/fixtures/image with → spaces.png +0 -0
- data/spec/{support → fixtures}/image.png +0 -0
- data/spec/{support → fixtures}/image2.PNG +0 -0
- data/spec/{support → fixtures}/image3.jpeg +0 -0
- data/spec/helpers/admin/base_helper_spec.rb +31 -43
- data/spec/helpers/admin/pages_helper_spec.rb +4 -2
- data/spec/helpers/base_helper_spec.rb +10 -3
- data/spec/helpers/pages_helper_spec.rb +32 -22
- data/spec/models/attachment_spec.rb +1 -1
- data/spec/models/element_spec.rb +33 -57
- data/spec/models/message_spec.rb +0 -16
- data/spec/models/page_spec.rb +62 -26
- data/spec/models/picture_spec.rb +5 -5
- data/spec/spec_helper.rb +13 -4
- data/spec/tasks/helpers_spec.rb +213 -0
- metadata +33 -75
- data/app/controllers/alchemy/passwords_controller.rb +0 -35
- data/app/controllers/alchemy/user_sessions_controller.rb +0 -67
- data/app/controllers/alchemy/users_controller.rb +0 -46
- data/app/mailers/alchemy/notifications.rb +0 -33
- data/app/models/alchemy/page/users.rb +0 -25
- data/app/models/alchemy/user.rb +0 -183
- data/app/views/alchemy/admin/users/_table.html.erb +0 -69
- data/app/views/alchemy/admin/users/_user.html.erb +0 -39
- data/app/views/alchemy/admin/users/edit.html.erb +0 -6
- data/app/views/alchemy/admin/users/index.html.erb +0 -58
- data/app/views/alchemy/admin/users/new.html.erb +0 -6
- data/app/views/alchemy/notifications/admin_user_created.de.text.erb +0 -15
- data/app/views/alchemy/notifications/admin_user_created.en.text.erb +0 -15
- data/app/views/alchemy/notifications/registered_user_created.de.text.erb +0 -13
- data/app/views/alchemy/notifications/registered_user_created.en.text.erb +0 -13
- data/app/views/alchemy/notifications/reset_password_instructions.de.text.erb +0 -8
- data/app/views/alchemy/notifications/reset_password_instructions.en.text.erb +0 -8
- data/app/views/alchemy/passwords/edit.html.erb +0 -35
- data/app/views/alchemy/passwords/new.html.erb +0 -30
- data/app/views/alchemy/user_sessions/new.html.erb +0 -48
- data/app/views/alchemy/users/new.html.erb +0 -14
- data/config/initializers/devise.rb +0 -242
- data/config/locales/devise.de.yml +0 -58
- data/config/locales/devise.en.yml +0 -60
- data/lib/rails/generators/alchemy/devise/devise_generator.rb +0 -29
- data/spec/controllers/admin/users_controller_spec.rb +0 -132
- data/spec/controllers/passwords_controller_spec.rb +0 -16
- data/spec/controllers/user_sessions_controller_spec.rb +0 -22
- data/spec/controllers/users_controller_spec.rb +0 -66
- data/spec/mailers/notifications_spec.rb +0 -67
- data/spec/models/user_spec.rb +0 -252
- data/spec/support/alchemy/controller_helpers.rb +0 -35
@@ -1,35 +0,0 @@
|
|
1
|
-
module Alchemy
|
2
|
-
class PasswordsController < Devise::PasswordsController
|
3
|
-
include Ferret::Search
|
4
|
-
helper 'Alchemy::Admin::Base', 'Alchemy::Pages'
|
5
|
-
|
6
|
-
before_filter { enforce_ssl if ssl_required? && !request.ssl? }
|
7
|
-
before_filter :set_translation
|
8
|
-
|
9
|
-
layout 'alchemy/login'
|
10
|
-
|
11
|
-
def new
|
12
|
-
build_resource(email: params[:email])
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
# Override for Devise method
|
18
|
-
def new_session_path(resource_name)
|
19
|
-
alchemy.login_path
|
20
|
-
end
|
21
|
-
|
22
|
-
def edit_password_url(resource, options={})
|
23
|
-
alchemy.edit_password_url(options)
|
24
|
-
end
|
25
|
-
|
26
|
-
def after_sign_in_path_for(resource_or_scope)
|
27
|
-
if permitted_to?(:index, :alchemy_admin_dashboard)
|
28
|
-
alchemy.admin_dashboard_path
|
29
|
-
else
|
30
|
-
alchemy.root_path
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
module Alchemy
|
2
|
-
class UserSessionsController < Devise::SessionsController
|
3
|
-
# Necessary because this controller is also used for general login.
|
4
|
-
include Ferret::Search
|
5
|
-
helper 'Alchemy::Admin::Base', 'Alchemy::Pages'
|
6
|
-
|
7
|
-
before_filter(except: 'destroy') { enforce_ssl if ssl_required? && !request.ssl? }
|
8
|
-
before_filter :set_translation
|
9
|
-
before_filter :check_user_count, :only => :new
|
10
|
-
|
11
|
-
layout 'alchemy/login'
|
12
|
-
|
13
|
-
def new
|
14
|
-
super
|
15
|
-
end
|
16
|
-
|
17
|
-
def create
|
18
|
-
authenticate_user!
|
19
|
-
if user_signed_in?
|
20
|
-
store_screen_size
|
21
|
-
if session[:redirect_path].blank?
|
22
|
-
redirect_path = admin_dashboard_path
|
23
|
-
else
|
24
|
-
# We have to strip double slashes from beginning of path, because of strange rails/rack bug.
|
25
|
-
redirect_path = session[:redirect_path].gsub(/^\/{2,}/, '/')
|
26
|
-
end
|
27
|
-
redirect_to redirect_path, :notice => t(:signed_in, :scope => 'devise.sessions')
|
28
|
-
else
|
29
|
-
super
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def leave
|
34
|
-
render layout: !request.xhr?
|
35
|
-
end
|
36
|
-
|
37
|
-
def destroy
|
38
|
-
cookies.clear
|
39
|
-
session.clear
|
40
|
-
super
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
def check_user_count
|
46
|
-
if User.count == 0
|
47
|
-
redirect_to signup_path
|
48
|
-
else
|
49
|
-
return true
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def store_screen_size
|
54
|
-
session[:screen_size] = params[:user_screensize]
|
55
|
-
end
|
56
|
-
|
57
|
-
# Ovewriting the default of Devise
|
58
|
-
def after_sign_out_path_for(resource_or_scope)
|
59
|
-
if request.referer.blank? || request.referer.to_s =~ /admin/
|
60
|
-
root_path
|
61
|
-
else
|
62
|
-
request.referer
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
module Alchemy
|
2
|
-
class UsersController < BaseController
|
3
|
-
|
4
|
-
before_filter { enforce_ssl if ssl_required? && !request.ssl? }
|
5
|
-
before_filter :set_translation
|
6
|
-
before_filter :check_user_count
|
7
|
-
before_filter :load_genders
|
8
|
-
|
9
|
-
layout 'alchemy/admin'
|
10
|
-
|
11
|
-
helper 'Alchemy::Admin::Base'
|
12
|
-
|
13
|
-
def new
|
14
|
-
@signup = true
|
15
|
-
@user = User.new(:roles => 'admin')
|
16
|
-
end
|
17
|
-
|
18
|
-
def create
|
19
|
-
@user = User.new(params[:user])
|
20
|
-
if @user.save
|
21
|
-
flash[:notice] = _t('Successfully signup admin user')
|
22
|
-
sign_in :user, @user
|
23
|
-
redirect_to admin_dashboard_path
|
24
|
-
else
|
25
|
-
@signup = true
|
26
|
-
render :new
|
27
|
-
end
|
28
|
-
rescue Errno::ECONNREFUSED => e
|
29
|
-
flash[:error] = _t(:signup_mail_delivery_error)
|
30
|
-
redirect_to admin_dashboard_path
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
def load_genders
|
36
|
-
@user_genders = User.genders_for_select
|
37
|
-
end
|
38
|
-
|
39
|
-
def check_user_count
|
40
|
-
if User.count > 0
|
41
|
-
redirect_to admin_dashboard_path
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Alchemy
|
2
|
-
class Notifications < ActionMailer::Base
|
3
|
-
|
4
|
-
default(from: Config.get(:mailer)['mail_from'])
|
5
|
-
|
6
|
-
def registered_user_created(user)
|
7
|
-
@user = user
|
8
|
-
@url = login_url
|
9
|
-
mail(
|
10
|
-
to: user.email,
|
11
|
-
subject: I18n.t("Your user credentials")
|
12
|
-
)
|
13
|
-
end
|
14
|
-
|
15
|
-
def admin_user_created(user)
|
16
|
-
@user = user
|
17
|
-
@url = admin_url
|
18
|
-
mail(
|
19
|
-
to: user.email,
|
20
|
-
subject: I18n.t("Your Alchemy Login")
|
21
|
-
)
|
22
|
-
end
|
23
|
-
|
24
|
-
def reset_password_instructions(user, opts={})
|
25
|
-
@user = user
|
26
|
-
mail(
|
27
|
-
to: user.email,
|
28
|
-
subject: I18n.t("Reset password instructions")
|
29
|
-
)
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Alchemy
|
2
|
-
module Page::Users
|
3
|
-
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
# Returns the name of the creator of this page.
|
7
|
-
def creator_name
|
8
|
-
return I18n.t('unknown') if creator.nil?
|
9
|
-
creator.name
|
10
|
-
end
|
11
|
-
|
12
|
-
# Returns the name of the last updater of this page.
|
13
|
-
def updater_name
|
14
|
-
return I18n.t('unknown') if updater.nil?
|
15
|
-
updater.name
|
16
|
-
end
|
17
|
-
|
18
|
-
# Returns the name of the user currently editing this page.
|
19
|
-
def locker_name
|
20
|
-
return I18n.t('unknown') if locker.nil?
|
21
|
-
locker.name
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
data/app/models/alchemy/user.rb
DELETED
@@ -1,183 +0,0 @@
|
|
1
|
-
require 'userstamp'
|
2
|
-
require 'acts-as-taggable-on'
|
3
|
-
|
4
|
-
module Alchemy
|
5
|
-
class User < ActiveRecord::Base
|
6
|
-
|
7
|
-
model_stamper
|
8
|
-
stampable(:stamper_class_name => 'Alchemy::User')
|
9
|
-
|
10
|
-
begin
|
11
|
-
devise(*Config.get(:devise_modules))
|
12
|
-
rescue NameError => e
|
13
|
-
abort <<-WARN
|
14
|
-
You enabled the encryptable devise module, but did not have the `devise-encryptable` gem installed!
|
15
|
-
Please add the `devise-encryptable` gem into your Gemfile.
|
16
|
-
WARN
|
17
|
-
end
|
18
|
-
|
19
|
-
acts_as_taggable
|
20
|
-
|
21
|
-
attr_accessible(
|
22
|
-
:firstname,
|
23
|
-
:lastname,
|
24
|
-
:login,
|
25
|
-
:email,
|
26
|
-
:gender,
|
27
|
-
:language,
|
28
|
-
:password,
|
29
|
-
:password_confirmation,
|
30
|
-
:roles,
|
31
|
-
:send_credentials,
|
32
|
-
:tag_list
|
33
|
-
)
|
34
|
-
|
35
|
-
attr_accessor :send_credentials
|
36
|
-
|
37
|
-
has_many :folded_pages
|
38
|
-
|
39
|
-
validates_uniqueness_of :login
|
40
|
-
validates_presence_of :roles
|
41
|
-
|
42
|
-
# Unlock all locked pages before destroy and before the user gets logged out.
|
43
|
-
before_destroy :unlock_pages!
|
44
|
-
Warden::Manager.before_logout do |user, auth, opts|
|
45
|
-
if user
|
46
|
-
user.unlock_pages!
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
after_save :deliver_welcome_mail, if: -> { send_credentials == '1' }
|
51
|
-
|
52
|
-
scope :admins, where(arel_table[:roles].matches("%admin%")) # not pleased with that approach
|
53
|
-
# mysql regexp word matching would be much nicer, but it's not included in SQLite functions per se.
|
54
|
-
# scope :admins, where("#{table_name}.roles REGEXP '[[:<:]]admin[[:>:]]'")
|
55
|
-
|
56
|
-
scope :logged_in, lambda { where("last_request_at > ?", logged_in_timeout.seconds.ago) }
|
57
|
-
scope :logged_out, lambda { where("last_request_at is NULL or last_request_at <= ?", logged_in_timeout.seconds.ago) }
|
58
|
-
|
59
|
-
ROLES = Config.get(:user_roles)
|
60
|
-
|
61
|
-
class << self
|
62
|
-
def human_rolename(role)
|
63
|
-
I18n.t("user_roles.#{role}")
|
64
|
-
end
|
65
|
-
|
66
|
-
def genders_for_select
|
67
|
-
[
|
68
|
-
[I18n.t('male'), 'male'],
|
69
|
-
[I18n.t('female'), 'female']
|
70
|
-
]
|
71
|
-
end
|
72
|
-
|
73
|
-
def logged_in_timeout
|
74
|
-
Config.get(:auto_logout_time).minutes.to_i
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def role_symbols
|
79
|
-
roles.map(&:to_sym)
|
80
|
-
end
|
81
|
-
|
82
|
-
def role
|
83
|
-
roles.first
|
84
|
-
end
|
85
|
-
|
86
|
-
def roles
|
87
|
-
read_attribute(:roles).split(' ')
|
88
|
-
end
|
89
|
-
|
90
|
-
def roles=(roles_string)
|
91
|
-
if roles_string.is_a? Array
|
92
|
-
write_attribute(:roles, roles_string.join(' '))
|
93
|
-
elsif roles_string.is_a? String
|
94
|
-
write_attribute(:roles, roles_string)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def add_role(role)
|
99
|
-
self.roles = self.roles.push(role.to_s).uniq
|
100
|
-
end
|
101
|
-
|
102
|
-
# Returns true if the user ahs admin role
|
103
|
-
def is_admin?
|
104
|
-
has_role? 'admin'
|
105
|
-
end
|
106
|
-
alias_method :admin?, :is_admin?
|
107
|
-
|
108
|
-
# Returns true if the user has the given role.
|
109
|
-
def has_role?(role)
|
110
|
-
roles.include? role.to_s
|
111
|
-
end
|
112
|
-
|
113
|
-
# Calls unlock on all locked pages
|
114
|
-
def unlock_pages!
|
115
|
-
pages_locked_by_me.map(&:unlock!)
|
116
|
-
end
|
117
|
-
|
118
|
-
# Returns all pages locked by user.
|
119
|
-
#
|
120
|
-
# A page gets locked, if the user requests to edit the page.
|
121
|
-
#
|
122
|
-
def pages_locked_by_me
|
123
|
-
Page.where(:locked => true).where(:locked_by => self.id).order(:updated_at)
|
124
|
-
end
|
125
|
-
alias_method :locked_pages, :pages_locked_by_me
|
126
|
-
|
127
|
-
# Returns the firstname and lastname as a string
|
128
|
-
#
|
129
|
-
# If both are blank, returns the login
|
130
|
-
#
|
131
|
-
# @option options :flipped (false)
|
132
|
-
# Flip the firstname and lastname
|
133
|
-
#
|
134
|
-
def fullname(options = {})
|
135
|
-
if lastname.blank? && firstname.blank?
|
136
|
-
login
|
137
|
-
else
|
138
|
-
options = {:flipped => false}.merge(options)
|
139
|
-
fullname = options[:flipped] ? "#{lastname}, #{firstname}" : "#{firstname} #{lastname}"
|
140
|
-
fullname.squeeze(" ").strip
|
141
|
-
end
|
142
|
-
end
|
143
|
-
alias_method :name, :fullname
|
144
|
-
|
145
|
-
# Returns true if the last request not longer ago then the logged_in_time_out
|
146
|
-
def logged_in?
|
147
|
-
raise "Can not determine the records login state because there is no last_request_at column" if !respond_to?(:last_request_at)
|
148
|
-
!last_request_at.nil? && last_request_at > logged_in_timeout.seconds.ago
|
149
|
-
end
|
150
|
-
|
151
|
-
# Opposite of logged_in?
|
152
|
-
def logged_out?
|
153
|
-
!logged_in?
|
154
|
-
end
|
155
|
-
|
156
|
-
def human_roles_string
|
157
|
-
roles.map do |role|
|
158
|
-
self.class.human_rolename(role)
|
159
|
-
end.to_sentence
|
160
|
-
end
|
161
|
-
|
162
|
-
def store_request_time!
|
163
|
-
update_attribute(:last_request_at, Time.now)
|
164
|
-
end
|
165
|
-
|
166
|
-
private
|
167
|
-
|
168
|
-
def logged_in_timeout
|
169
|
-
self.class.logged_in_timeout
|
170
|
-
end
|
171
|
-
|
172
|
-
# Delivers a welcome mail depending from user's role.
|
173
|
-
#
|
174
|
-
def deliver_welcome_mail
|
175
|
-
if has_role?('author') || has_role?('editor') || has_role?('admin')
|
176
|
-
Notifications.admin_user_created(self).deliver
|
177
|
-
else
|
178
|
-
Notifications.registered_user_created(self).deliver
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
end
|
183
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
<table>
|
2
|
-
<tr>
|
3
|
-
<td class="label"><%= f.label 'gender' %></td>
|
4
|
-
<td class="select"><%= f.select 'gender', options_for_select(@user_genders, @user.gender), {:prompt => _t('Please choose')}, :class => 'alchemy_selectbox long', :autofocus => true -%></td>
|
5
|
-
</tr>
|
6
|
-
<tr>
|
7
|
-
<td class="label"><%= f.label 'firstname' %></td>
|
8
|
-
<td class="input"><%= f.text_field 'firstname', :class => 'thin_border long' %></td>
|
9
|
-
</tr>
|
10
|
-
<tr>
|
11
|
-
<td class="label"><%= f.label 'lastname' %></td>
|
12
|
-
<td class="input"><%= f.text_field 'lastname', :class => 'thin_border long' %></td>
|
13
|
-
</tr>
|
14
|
-
<tr>
|
15
|
-
<td class="label mandatory"><%= f.label 'login' %></td>
|
16
|
-
<td class="input"><%= f.text_field 'login', :class => 'thin_border long', :required => true, :autofocus => true %></td>
|
17
|
-
</tr>
|
18
|
-
<tr>
|
19
|
-
<td class="label mandatory"><%= f.label 'email' %></td>
|
20
|
-
<td class="input"><%= f.email_field 'email', :class => 'thin_border long', :required => true %></td>
|
21
|
-
</tr>
|
22
|
-
<tr>
|
23
|
-
<td class="label"><%= f.label 'language' %></td>
|
24
|
-
<td class="select"><%= f.select 'language', translations_for_select, {}, {:class => 'alchemy_selectbox long'} %></td>
|
25
|
-
</tr>
|
26
|
-
<tr>
|
27
|
-
<td class="label mandatory"><%= f.label 'password' %></td>
|
28
|
-
<td class="input mandatory"><%= f.password_field 'password', :class => 'thin_border long', :autocomplete => "off", :required => action_name == 'signup' %></td>
|
29
|
-
</tr>
|
30
|
-
<tr>
|
31
|
-
<td class="label mandatory"><%= f.label 'password_confirmation' %></td>
|
32
|
-
<td class="input"><%= f.password_field 'password_confirmation', :class => 'thin_border long', :autocomplete => "off", :required => action_name == 'signup' %></td>
|
33
|
-
</tr>
|
34
|
-
<% if @signup %>
|
35
|
-
<%= f.hidden_field :roles %>
|
36
|
-
<% elsif permitted_to? :update_roles %>
|
37
|
-
<tr>
|
38
|
-
<td class="label"><%= f.label 'roles' %></td>
|
39
|
-
<td id="user_roles">
|
40
|
-
<% Alchemy::User::ROLES.each do |role| %>
|
41
|
-
<label>
|
42
|
-
<%= check_box_tag 'user[roles][]', role, @user.has_role?(role) %>
|
43
|
-
<%= Alchemy::User.human_rolename(role) %>
|
44
|
-
</label>
|
45
|
-
<% end %>
|
46
|
-
</td>
|
47
|
-
</tr>
|
48
|
-
<% end %>
|
49
|
-
<% unless @signup %>
|
50
|
-
<tr>
|
51
|
-
<td class="label"><%= f.label :tag_list %></td>
|
52
|
-
<td class="input">
|
53
|
-
<%= render 'alchemy/admin/partials/autocomplete_tag_list', :f => f, :object => @user %>
|
54
|
-
</td>
|
55
|
-
</tr>
|
56
|
-
<% end %>
|
57
|
-
<tr>
|
58
|
-
<td> </td>
|
59
|
-
<td class="checkbox long">
|
60
|
-
<%= f.check_box(:send_credentials, checked: @user.new_record?) %>
|
61
|
-
<%= f.label(:send_credentials) %>
|
62
|
-
</td>
|
63
|
-
</tr>
|
64
|
-
<tr>
|
65
|
-
<td class="submit" colspan="2">
|
66
|
-
<%= f.button _t(:save), :class => 'button' %>
|
67
|
-
</td>
|
68
|
-
</tr>
|
69
|
-
</table>
|