Class: CamaleonCms::UserDecorator
- Inherits:
-
ApplicationDecorator
- Object
- Draper::Decorator
- ApplicationDecorator
- CamaleonCms::UserDecorator
- Includes:
- CustomFieldsConcern
- Defined in:
- app/decorators/camaleon_cms/user_decorator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #role_grantor?(other_user) ⇒ Boolean
-
#the_admin_profile_url ⇒ Object
return the url for the profile in the admin module.
-
#the_avatar(default_avatar = nil) ⇒ Object
return the avatar for this user, default: assets/admin/img/no_image.jpg.
-
#the_contents ⇒ Object
return all contents created by this user in current site.
-
#the_name ⇒ Object
return the fullname.
-
#the_role ⇒ Object
return the role title of this user for current site.
-
#the_slogan ⇒ Object
return the slogan for this user, default: Hello World.
-
#the_url(*args) ⇒ Object
return front url for this user.
-
#the_username ⇒ Object
return the identifier.
Methods included from CustomFieldsConcern
#render_fields, #the_field, #the_field_grouped, #the_fields, #the_fields_grouped, #the_json_field, #the_json_fields
Methods inherited from ApplicationDecorator
#_calc_locale, #get_locale, #set_decoration_locale, #the_breadcrumb, #the_created_at, #the_id, #the_keywords, #the_slug, #the_updated_at
Methods included from MetasDecoratorMethods
Class Method Details
.object_class_name ⇒ Object
58 59 60 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 58 def self.object_class_name 'CamaleonCms::User' end |
Instance Method Details
#role_grantor?(other_user) ⇒ Boolean
54 55 56 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 54 def role_grantor?(other_user) h.can?(:manage, :users) && id != other_user.id end |
#the_admin_profile_url ⇒ Object
return the url for the profile in the admin module
44 45 46 47 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 44 def the_admin_profile_url args = h.cama_current_site_host_port({}) h.cama_admin_profile_url(object.id, args) end |
#the_avatar(default_avatar = nil) ⇒ Object
return the avatar for this user, default: assets/admin/img/no_image.jpg
21 22 23 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 21 def the_avatar(default_avatar = nil) avatar_exists? ? object.("avatar") : (default_avatar || h.asset_url("camaleon_cms/admin/img/no_image.jpg")) end |
#the_contents ⇒ Object
return all contents created by this user in current site
50 51 52 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 50 def the_contents h.current_site.posts.where(user_id: object.id) end |
#the_name ⇒ Object
return the fullname
11 12 13 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 11 def the_name object.fullname end |
#the_role ⇒ Object
return the role title of this user for current site
16 17 18 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 16 def the_role object.get_role(h.current_site).try(:decorate).try(:the_title) || '' end |
#the_slogan ⇒ Object
return the slogan for this user, default: Hello World
26 27 28 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 26 def the_slogan object.("slogan", "Hello World") end |
#the_url(*args) ⇒ Object
return front url for this user
31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 31 def the_url(*args) args = args. args[:label] = I18n.t("routes.profile", default: "profile") args[:user_id] = the_id args[:user_name] = the_name.parameterize args[:user_name] = the_username unless args[:user_name].present? args[:locale] = get_locale unless args.include?(:locale) args[:format] = args[:format] || "html" as_path = args.delete(:as_path) h.cama_url_to_fixed("cama_profile_#{as_path.present? ? "path" : "url"}", args) end |
#the_username ⇒ Object
return the identifier
6 7 8 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 6 def the_username object.username end |