typus 3.0.8 → 3.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +8 -1
- data/README.md +2 -2
- data/Rakefile +6 -14
- data/app/controllers/admin/base_controller.rb +1 -1
- data/app/controllers/admin/dashboard_controller.rb +0 -1
- data/app/controllers/admin/resources_controller.rb +8 -11
- data/app/controllers/admin/session_controller.rb +5 -4
- data/app/helpers/admin/base_helper.rb +9 -2
- data/app/helpers/admin/dashboard_helper.rb +0 -6
- data/app/helpers/admin/display_helper.rb +1 -0
- data/app/helpers/admin/file_preview_helper.rb +0 -2
- data/app/helpers/admin/filters_helper.rb +6 -3
- data/app/helpers/admin/form_helper.rb +2 -4
- data/app/helpers/admin/list_helper.rb +1 -3
- data/app/helpers/admin/relationships_helper.rb +2 -4
- data/app/helpers/admin/resources_helper.rb +0 -2
- data/app/helpers/admin/search_helper.rb +0 -2
- data/app/helpers/admin/sidebar_helper.rb +0 -2
- data/app/helpers/admin/table_helper.rb +3 -6
- data/app/views/admin/account/forgot_password.html.erb +2 -2
- data/app/views/admin/account/new.html.erb +3 -7
- data/app/views/admin/{helpers/dashboard → dashboard}/_applications.html.erb +0 -0
- data/app/views/admin/dashboard/_sidebar.html.erb +1 -1
- data/app/views/admin/dashboard/show.html.erb +7 -1
- data/app/views/admin/helpers/base/_apps.html.erb +1 -1
- data/app/views/admin/helpers/base/_login_info.html.erb +2 -2
- data/app/views/admin/helpers/filters/_filters.html.erb +3 -1
- data/app/views/admin/resources/_form.html.erb +5 -2
- data/app/views/admin/resources/edit.html.erb +1 -1
- data/app/views/admin/resources/index.html.erb +1 -1
- data/app/views/admin/resources/show.html.erb +2 -2
- data/app/views/admin/session/new.html.erb +3 -7
- data/app/views/admin/templates/_belongs_to.html.erb +8 -1
- data/app/views/admin/templates/_belongs_to_with_autocomplete.html.erb +1 -1
- data/app/views/admin/templates/_relate_form.html.erb +1 -1
- data/app/views/admin/templates/_relate_form_with_autocomplete.html.erb +3 -1
- data/app/views/admin/templates/_string.html.erb +1 -1
- data/app/views/admin/templates/_text.html.erb +1 -1
- data/app/views/layouts/admin/base.html.erb +2 -0
- data/app/views/layouts/admin/headless.html.erb +2 -0
- data/app/views/layouts/admin/session.html.erb +6 -0
- data/config/routes.rb +4 -1
- data/lib/support/active_record.rb +0 -10
- data/lib/support/fake_user.rb +4 -6
- data/lib/support/object.rb +4 -0
- data/lib/support/string.rb +0 -8
- data/lib/typus.rb +2 -3
- data/lib/typus/authentication/base.rb +0 -1
- data/lib/typus/authentication/session.rb +22 -29
- data/lib/typus/orm/active_record.rb +5 -5
- data/lib/typus/orm/active_record/admin_user_v1.rb +93 -0
- data/lib/typus/orm/active_record/admin_user_v2.rb +49 -0
- data/lib/typus/orm/active_record/class_methods.rb +23 -143
- data/lib/typus/orm/active_record/user/instance_methods.rb +64 -0
- data/lib/typus/orm/base.rb +170 -0
- data/lib/typus/orm/mongo/class_methods.rb +11 -0
- data/lib/typus/resources.rb +2 -1
- data/lib/typus/version.rb +1 -1
- data/test/app/controllers/admin/account_controller_test.rb +4 -2
- data/test/app/controllers/admin/assets_controller_test.rb +12 -12
- data/test/app/controllers/admin/categories_controller_test.rb +5 -12
- data/test/app/controllers/admin/comments_controller_test.rb +1 -1
- data/test/app/controllers/admin/image_holders_controller_test.rb +1 -1
- data/test/app/controllers/admin/invoices_controller_test.rb +1 -1
- data/test/app/controllers/admin/posts_controller_test.rb +32 -32
- data/test/app/controllers/admin/projects_controller_test.rb +1 -1
- data/test/app/controllers/admin/typus_users_controller_test.rb +13 -17
- data/test/app/controllers/admin/users_controller_test.rb +9 -9
- data/test/app/helpers/admin/list_helper_test.rb +17 -0
- data/test/app/models/admin_user_test.rb +5 -0
- data/test/app/models/typus_user_roles_test.rb +1 -0
- data/test/app/models/typus_user_test.rb +45 -11
- data/test/factories.rb +1 -1
- data/test/fixtures/rails_app/app/controllers/admin/hits_controller.rb +40 -0
- data/test/fixtures/rails_app/app/controllers/admin_user.rb +3 -0
- data/test/fixtures/rails_app/app/models/asset.rb +0 -6
- data/test/fixtures/rails_app/app/models/hit.rb +27 -0
- data/test/fixtures/rails_app/app/views/admin/hits/_edit.html.erb +7 -0
- data/test/fixtures/rails_app/app/views/admin/hits/_index.html.erb +3 -0
- data/test/fixtures/rails_app/app/views/admin/hits/index.html.erb +28 -0
- data/test/fixtures/rails_app/config/boot.rb +3 -10
- data/test/fixtures/rails_app/config/deploy.rb +1 -1
- data/test/fixtures/rails_app/config/mongoid.yml +20 -0
- data/test/fixtures/rails_app/config/typus/crud_extended.yml +2 -0
- data/test/fixtures/rails_app/config/typus/mongo_db.yml +4 -0
- data/test/fixtures/rails_app/config/typus/mongo_db_roles.yml +2 -0
- data/test/fixtures/rails_app/db/schema.rb +11 -0
- data/test/lib/support/fake_user_test.rb +4 -0
- data/test/lib/support/string_test.rb +0 -18
- data/test/lib/typus/orm/active_record/class_methods_test.rb +14 -2
- data/test/lib/typus/orm/active_record/search_test.rb +1 -1
- data/test/lib/typus_test.rb +2 -1
- data/typus.gemspec +1 -1
- metadata +32 -45
- data/lib/typus/orm/active_record/instance_methods.rb +0 -13
- data/lib/typus/orm/active_record/user.rb +0 -157
- data/test/fixtures/rails_app/public/javascripts/application.js +0 -2
- data/test/fixtures/rails_app/public/javascripts/controls.js +0 -965
- data/test/fixtures/rails_app/public/javascripts/dragdrop.js +0 -974
- data/test/fixtures/rails_app/public/javascripts/effects.js +0 -1123
- data/test/fixtures/rails_app/public/javascripts/prototype.js +0 -6001
- data/test/fixtures/rails_app/public/javascripts/rails.js +0 -175
@@ -8,18 +8,14 @@
|
|
8
8
|
<ul>
|
9
9
|
|
10
10
|
<li>
|
11
|
-
<%= form.label :email, Typus.user_class.human_attribute_name(:email)
|
12
|
-
<%= form.text_field :email, :size => 20, :class => "text", :
|
11
|
+
<%= form.label :email, Typus.user_class.human_attribute_name(:email) %>
|
12
|
+
<%= form.text_field :email, :size => 20, :class => "text", :autofocus => 'autofocus' %>
|
13
13
|
</li>
|
14
14
|
|
15
15
|
<li>
|
16
|
-
<%= submit_tag Typus::I18n.t("Sign up"), :class => "button" %>
|
16
|
+
<%= submit_tag Typus::I18n.t("Sign up"), :class => "button", :disable_with => Typus::I18n.t("Sending data ...") %>
|
17
17
|
</li>
|
18
18
|
|
19
19
|
</ul>
|
20
20
|
|
21
|
-
<script type="text/javascript">
|
22
|
-
(function() { document.getElementById('autofocus').focus(); })();
|
23
|
-
</script>
|
24
|
-
|
25
21
|
<% end %>
|
File without changes
|
@@ -4,4 +4,4 @@
|
|
4
4
|
|
5
5
|
<p>Replace this sidebar dropping a file named <code>_sidebar.html.erb</code> on the <code>app/views/admin/dashboard</code> folder.</p>
|
6
6
|
|
7
|
-
<p>If you need help you can use the provided <%= link_to "user guide",
|
7
|
+
<p>If you need help you can use the provided <%= link_to "user guide", admin_user_guide_path %>.</p>
|
@@ -11,6 +11,12 @@
|
|
11
11
|
<%= page_title %>
|
12
12
|
</h2>
|
13
13
|
|
14
|
-
|
14
|
+
<% if admin_user.applications.any? %>
|
15
|
+
<%= render 'applications' %>
|
16
|
+
<% else %>
|
17
|
+
<div class="notice">
|
18
|
+
No applications detected.
|
19
|
+
</div>
|
20
|
+
<% end %>
|
15
21
|
|
16
22
|
<%= resources(admin_user) %>
|
@@ -1,4 +1,4 @@
|
|
1
1
|
<ul>
|
2
|
-
<li><%= Typus::I18n.t("Logged as") %> <%= link_to admin_user.
|
3
|
-
<li><%= link_to Typus::I18n.t("Sign out"),
|
2
|
+
<li><%= Typus::I18n.t("Logged as") %> <%= link_to admin_user.to_label, { :controller => "/admin/#{Typus.user_class.to_resource}", :action => 'edit', :id => admin_user.id } %></li>
|
3
|
+
<li><%= link_to Typus::I18n.t("Sign out"), admin_sign_out_path, :confirm => Typus::I18n.t("Are you sure you want to sign out and end your session?") %></li>
|
4
4
|
</ul>
|
@@ -10,7 +10,9 @@
|
|
10
10
|
<%= hidden_field_tag key, value %>
|
11
11
|
<% end %>
|
12
12
|
|
13
|
-
<li><%= submit_tag Typus::I18n.t("Filter"),
|
13
|
+
<li><%= submit_tag Typus::I18n.t("Filter"),
|
14
|
+
:name => nil,
|
15
|
+
:disable_with => Typus::I18n.t("Sending data ...") %></li>
|
14
16
|
</ul>
|
15
17
|
</div>
|
16
18
|
|
@@ -4,13 +4,16 @@
|
|
4
4
|
|
5
5
|
<fieldset class="inputs">
|
6
6
|
<ol>
|
7
|
-
<%=
|
7
|
+
<%= build_form(fields, form) %>
|
8
8
|
</ol>
|
9
9
|
</fieldset>
|
10
10
|
|
11
11
|
<fieldset class="buttons">
|
12
12
|
<ol>
|
13
|
-
<li><%= submit_tag button,
|
13
|
+
<li><%= submit_tag button,
|
14
|
+
:class => "commit",
|
15
|
+
:onclick => "setConfirmUnload(false);",
|
16
|
+
:disable_with => Typus::I18n.t("Sending data ...") %></li>
|
14
17
|
</ol>
|
15
18
|
</fieldset>
|
16
19
|
|
@@ -28,7 +28,7 @@
|
|
28
28
|
<% end %>
|
29
29
|
|
30
30
|
<% if @items.any? -%>
|
31
|
-
<%=
|
31
|
+
<%= build_list(@resource, fields, @items) %>
|
32
32
|
<%= will_paginate(@items, Typus.pagination) %>
|
33
33
|
<% else %>
|
34
34
|
<p><%= Typus::I18n.t("No %{resources} found.", :resources => @resource.model_name.human.downcase.pluralize) %></p>
|
@@ -14,10 +14,10 @@
|
|
14
14
|
<%= render 'show' %>
|
15
15
|
|
16
16
|
<dl>
|
17
|
-
<% build_display(@item,
|
17
|
+
<% build_display(@item, fields).each do |attribute, type| %>
|
18
18
|
<dt><%= attribute %></dt>
|
19
19
|
<dd><%= type %></dd>
|
20
20
|
<% end %>
|
21
21
|
</dl>
|
22
22
|
|
23
|
-
<%=
|
23
|
+
<%= typus_relationships %>
|
@@ -8,8 +8,8 @@
|
|
8
8
|
<ul>
|
9
9
|
|
10
10
|
<li>
|
11
|
-
<%= form.label :email, Typus.user_class.human_attribute_name(:email)
|
12
|
-
<%= form.text_field :email, :size => 20, :class => "text", :
|
11
|
+
<%= form.label :email, Typus.user_class.human_attribute_name(:email) %>
|
12
|
+
<%= form.text_field :email, :size => 20, :class => "text", :autofocus => "autofocus" %>
|
13
13
|
</li>
|
14
14
|
|
15
15
|
<li>
|
@@ -18,13 +18,9 @@
|
|
18
18
|
</li>
|
19
19
|
|
20
20
|
<li>
|
21
|
-
<%= submit_tag Typus::I18n.t("Sign in"), :class => "button" %> <%= link_to Typus::I18n.t("Recover password"), forgot_password_admin_account_index_path if Typus.mailer_sender %>
|
21
|
+
<%= submit_tag Typus::I18n.t("Sign in"), :class => "button", :disable_with => Typus::I18n.t("Sending data ...") %> <%= link_to Typus::I18n.t("Recover password"), forgot_password_admin_account_index_path if Typus.mailer_sender %>
|
22
22
|
</li>
|
23
23
|
|
24
24
|
</ul>
|
25
25
|
|
26
|
-
<script type="text/javascript">
|
27
|
-
(function() { document.getElementById('autofocus').focus(); })();
|
28
|
-
</script>
|
29
|
-
|
30
26
|
<% end %>
|
@@ -1,4 +1,11 @@
|
|
1
|
+
<%
|
2
|
+
if @resource.typus_field_options_for(:read_only).include?(attribute.to_sym)
|
3
|
+
html_options.merge!(:disabled => 'disabled')
|
4
|
+
message = Typus::I18n.t("Read only")
|
5
|
+
end
|
6
|
+
%>
|
7
|
+
|
1
8
|
<li id="<%= attribute %>">
|
2
|
-
<%= form.label related_fk,
|
9
|
+
<%= form.label related_fk, "#{label_text} <small>#{message}</small>".html_safe %>
|
3
10
|
<%= form.select related_fk, values, options, html_options %>
|
4
11
|
</li>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<li id="<%= attribute %>">
|
2
|
-
<%= form.label related_fk,
|
2
|
+
<%= form.label related_fk, "#{label_text} <small>#{message}</small>".html_safe %>
|
3
3
|
<%= form.hidden_field related_fk %>
|
4
4
|
<input data-autocomplete="<%= "/admin/#{related.to_resource}/autocomplete" %>"
|
5
5
|
id="autocomplete"
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<%= form_tag :action => :relate, :id => @item.id do %>
|
2
2
|
<%= hidden_field :related, :model, :value => model_to_relate %>
|
3
3
|
<%= hidden_field :related, :association_name, :value => association_name %>
|
4
|
-
<p><%= select :related, :id, items_to_relate.map { |f| [f.to_label, f.id] } %> <%= submit_tag Typus::I18n.t("
|
4
|
+
<p><%= select :related, :id, items_to_relate.map { |f| [f.to_label, f.id] } %> <%= submit_tag Typus::I18n.t("Assign"), :class => "button", :disable_with => Typus::I18n.t("Sending data ...") %></p>
|
5
5
|
<% end %>
|
@@ -8,6 +8,8 @@
|
|
8
8
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
9
9
|
<meta name="generator" content="Typus <%= Typus::VERSION %>" />
|
10
10
|
|
11
|
+
<%= favicon_link_tag %>
|
12
|
+
|
11
13
|
<title><%= Typus.admin_title %> — <%= yield :title %></title>
|
12
14
|
|
13
15
|
<%= stylesheet_link_tag "/vendor/typus/stylesheets/reset",
|
@@ -8,6 +8,8 @@
|
|
8
8
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
9
9
|
<meta name="generator" content="Typus <%= Typus::VERSION %>" />
|
10
10
|
|
11
|
+
<%= favicon_link_tag %>
|
12
|
+
|
11
13
|
<title><%= Typus.admin_title %> — <%= yield :title %></title>
|
12
14
|
|
13
15
|
<%= stylesheet_link_tag "/vendor/typus/stylesheets/reset",
|
@@ -8,12 +8,18 @@
|
|
8
8
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
9
9
|
<meta name="generator" content="Typus <%= Typus::VERSION %>" />
|
10
10
|
|
11
|
+
<%= favicon_link_tag %>
|
12
|
+
|
11
13
|
<title><%= Typus.admin_title %> — <%= yield :title %></title>
|
12
14
|
|
13
15
|
<%= stylesheet_link_tag "/vendor/typus/stylesheets/reset",
|
14
16
|
"/vendor/typus/stylesheets/screen",
|
15
17
|
"/vendor/typus/stylesheets/application" %>
|
16
18
|
|
19
|
+
<%= javascript_include_tag "/vendor/jquery-ui-1.8.9.custom/js/jquery-1.4.4.min.js",
|
20
|
+
"/vendor/typus/javascripts/jquery.rails.js",
|
21
|
+
"/vendor/typus/javascripts/application" %>
|
22
|
+
|
17
23
|
<%= csrf_meta_tag %>
|
18
24
|
|
19
25
|
</head>
|
data/config/routes.rb
CHANGED
@@ -6,7 +6,10 @@ Rails.application.routes.draw do
|
|
6
6
|
match "user_guide" => "base#user_guide"
|
7
7
|
|
8
8
|
if Typus.authentication == :session
|
9
|
-
resource :session, :only => [:new, :create
|
9
|
+
resource :session, :only => [:new, :create], :controller => :session do
|
10
|
+
get :destroy, :as => "destroy"
|
11
|
+
end
|
12
|
+
|
10
13
|
resources :account, :only => [:new, :create, :show, :forgot_password] do
|
11
14
|
collection do
|
12
15
|
get :forgot_password
|
@@ -6,16 +6,6 @@ class ActiveRecord::Base
|
|
6
6
|
association.macro
|
7
7
|
end
|
8
8
|
|
9
|
-
#--
|
10
|
-
# >> Post.to_resource
|
11
|
-
# => "posts"
|
12
|
-
# >> Admin::User.to_resource
|
13
|
-
# => "admin/users"
|
14
|
-
#++
|
15
|
-
def self.to_resource
|
16
|
-
name.underscore.pluralize
|
17
|
-
end
|
18
|
-
|
19
9
|
#--
|
20
10
|
# On a model:
|
21
11
|
#
|
data/lib/support/fake_user.rb
CHANGED
@@ -24,12 +24,6 @@ class FakeUser
|
|
24
24
|
::I18n.locale
|
25
25
|
end
|
26
26
|
|
27
|
-
=begin
|
28
|
-
def resources
|
29
|
-
Typus::Configuration.roles[role].compact
|
30
|
-
end
|
31
|
-
=end
|
32
|
-
|
33
27
|
def applications
|
34
28
|
Typus.applications
|
35
29
|
end
|
@@ -46,4 +40,8 @@ class FakeUser
|
|
46
40
|
true
|
47
41
|
end
|
48
42
|
|
43
|
+
def owns?(resource)
|
44
|
+
true
|
45
|
+
end
|
46
|
+
|
49
47
|
end
|
data/lib/support/object.rb
CHANGED
data/lib/support/string.rb
CHANGED
@@ -16,14 +16,6 @@ class String
|
|
16
16
|
Typus::Configuration.models_constantized[self]
|
17
17
|
end
|
18
18
|
|
19
|
-
def action_mapper
|
20
|
-
case self
|
21
|
-
when "index" then :list
|
22
|
-
when "new", "create", "edit", "update", "toggle" then :form
|
23
|
-
else self
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
19
|
def acl_action_mapper
|
28
20
|
case self
|
29
21
|
when "new", "create"
|
data/lib/typus.rb
CHANGED
@@ -6,7 +6,7 @@ require "support/object"
|
|
6
6
|
require "support/string"
|
7
7
|
|
8
8
|
require "typus/engine"
|
9
|
-
require "typus/
|
9
|
+
require "typus/orm/base"
|
10
10
|
require "typus/orm/active_record"
|
11
11
|
require "typus/regex"
|
12
12
|
require "typus/version"
|
@@ -19,16 +19,15 @@ autoload :FakeUser, "support/fake_user"
|
|
19
19
|
module Typus
|
20
20
|
|
21
21
|
autoload :Configuration, "typus/configuration"
|
22
|
+
autoload :I18n, "typus/i18n"
|
22
23
|
autoload :Resources, "typus/resources"
|
23
24
|
|
24
25
|
module Controller
|
25
|
-
|
26
26
|
autoload :Actions, "typus/controller/actions"
|
27
27
|
autoload :Associations, "typus/controller/associations"
|
28
28
|
autoload :Autocomplete, "typus/controller/autocomplete"
|
29
29
|
autoload :Filters, "typus/controller/filters"
|
30
30
|
autoload :Format, "typus/controller/format"
|
31
|
-
|
32
31
|
end
|
33
32
|
|
34
33
|
module Authentication
|
@@ -15,16 +15,21 @@ module Typus
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
def deauthenticate
|
19
|
+
session[:typus_user_id] = nil
|
20
|
+
::I18n.locale = ::I18n.default_locale
|
21
|
+
redirect_to new_admin_session_path
|
22
|
+
end
|
23
|
+
|
18
24
|
#--
|
19
|
-
# Return the current user. If role does not longer exist on the
|
20
|
-
#
|
25
|
+
# Return the current user. If role does not longer exist on the system
|
26
|
+
# admin_user will be signed out from the system.
|
21
27
|
#++
|
22
28
|
def admin_user
|
23
29
|
@admin_user ||= Typus.user_class.find_by_id(session[:typus_user_id])
|
24
30
|
|
25
31
|
if !@admin_user || !Typus::Configuration.roles.has_key?(@admin_user.role) || !@admin_user.status
|
26
|
-
|
27
|
-
redirect_to new_admin_session_path
|
32
|
+
deauthenticate
|
28
33
|
end
|
29
34
|
|
30
35
|
@admin_user
|
@@ -66,9 +71,7 @@ module Typus
|
|
66
71
|
#++
|
67
72
|
def check_if_user_can_perform_action_on_resource
|
68
73
|
resource = params[:controller].remove_prefix.camelize
|
69
|
-
|
70
|
-
not_allowed
|
71
|
-
end
|
74
|
+
not_allowed if admin_user.cannot?(params[:action], resource, { :special => true })
|
72
75
|
end
|
73
76
|
|
74
77
|
def not_allowed
|
@@ -76,18 +79,14 @@ module Typus
|
|
76
79
|
end
|
77
80
|
|
78
81
|
#--
|
79
|
-
# If item is owned by another user, we only can perform a
|
80
|
-
#
|
81
|
-
#
|
82
|
-
# before_filter :check_resource_ownership, :only => [ :edit, :update, :destroy,
|
83
|
-
# :toggle, :position,
|
84
|
-
# :relate, :unrelate ]
|
82
|
+
# If item is owned by another user, we only can perform a show action on
|
83
|
+
# the item. Updated item is also blocked.
|
85
84
|
#++
|
86
85
|
def check_resource_ownership
|
87
86
|
if admin_user.is_not_root?
|
88
87
|
|
89
88
|
condition_typus_users = @item.respond_to?(Typus.relationship) && !@item.send(Typus.relationship).include?(admin_user)
|
90
|
-
condition_typus_user_id = @item.respond_to?(Typus.user_fk) &&
|
89
|
+
condition_typus_user_id = @item.respond_to?(Typus.user_fk) && !admin_user.owns?(@item)
|
91
90
|
|
92
91
|
not_allowed if (condition_typus_users || condition_typus_user_id)
|
93
92
|
end
|
@@ -99,33 +98,27 @@ module Typus
|
|
99
98
|
#++
|
100
99
|
def check_resources_ownership
|
101
100
|
if admin_user.is_not_root? && @resource.typus_user_id?
|
102
|
-
|
103
|
-
@resource = @resource.where(condition)
|
101
|
+
@resource = @resource.where(Typus.user_fk => admin_user)
|
104
102
|
end
|
105
103
|
end
|
106
104
|
|
105
|
+
##
|
106
|
+
# OPTIMIZE: This method should accept args.
|
107
|
+
#
|
107
108
|
def set_attributes_on_create
|
108
|
-
if @resource.typus_user_id?
|
109
|
-
@item.attributes = { Typus.user_fk => admin_user.id }
|
110
|
-
end
|
109
|
+
@item.send("#{Typus.user_fk}=", admin_user.id) if @resource.typus_user_id?
|
111
110
|
end
|
112
111
|
|
112
|
+
##
|
113
|
+
# OPTIMIZE: This method should accept args and not perform an update
|
114
|
+
# because we are updating the attributes twice!
|
115
|
+
#
|
113
116
|
def set_attributes_on_update
|
114
117
|
if @resource.typus_user_id? && admin_user.is_not_root?
|
115
118
|
@item.update_attributes(Typus.user_fk => admin_user.id)
|
116
119
|
end
|
117
120
|
end
|
118
121
|
|
119
|
-
#--
|
120
|
-
# Reload admin_user when updating to see flash message in the
|
121
|
-
# correct locale.
|
122
|
-
#++
|
123
|
-
def reload_locales
|
124
|
-
if @resource.eql?(Typus.user_class)
|
125
|
-
::I18n.locale = admin_user.reload.locale
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
122
|
end
|
130
123
|
end
|
131
124
|
end
|