Class: CamaleonCms::UserDecorator
- Inherits:
-
ApplicationDecorator
- Object
- Draper::Decorator
- ApplicationDecorator
- CamaleonCms::UserDecorator
- Includes:
- CustomFieldsConcern
- Defined in:
- app/decorators/camaleon_cms/user_decorator.rb
Overview
Camaleon CMS is a content management system
Copyright (C) 2015 by Owen Peredo Diaz
Email: [email protected]
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License (GPLv3) for more details.
Instance Method Summary collapse
-
#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_attribute_field, #the_attribute_fields, #the_field, #the_field!, #the_fields, #the_fields_grouped
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
Instance Method Details
#the_admin_profile_url ⇒ Object
return the url for the profile in the admin module
51 52 53 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 51 def the_admin_profile_url h.cama_admin_profile_url(object.id) end |
#the_avatar(default_avatar = nil) ⇒ Object
return the avatar for this user, default: assets/admin/img/no_image.jpg
29 30 31 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 29 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
56 57 58 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 56 def the_contents h.current_site.posts.where(user_id: object.id) end |
#the_name ⇒ Object
return the fullname
19 20 21 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 19 def the_name object.fullname end |
#the_role ⇒ Object
return the role title of this user for current site
24 25 26 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 24 def the_role object.get_role(h.current_site).name.titleize end |
#the_slogan ⇒ Object
return the slogan for this user, default: Hello World
34 35 36 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 34 def the_slogan object.("slogan", "Hello World") end |
#the_url(*args) ⇒ Object
return front url for this user
39 40 41 42 43 44 45 46 47 48 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 39 def the_url(*args) args = args. 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] = "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
14 15 16 |
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 14 def the_username object.username end |