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, #marshal_dump, #marshal_load, #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
59 60 61 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 59 def self.object_class_name 'CamaleonCms::User' end |
Instance Method Details
#role_grantor?(other_user) ⇒ Boolean
55 56 57 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 55 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
45 46 47 48 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 45 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
22 23 24 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 22 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
51 52 53 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 51 def the_contents h.current_site.posts.where(user_id: object.id) end |
#the_name ⇒ Object
return the fullname
12 13 14 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 12 def the_name object.fullname end |
#the_role ⇒ Object
return the role title of this user for current site
17 18 19 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 17 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
27 28 29 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 27 def the_slogan object.('slogan', 'Hello World') end |
#the_url(*args) ⇒ Object
return front url for this user
32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 32 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
7 8 9 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 7 def the_username object.username end |