Class: CamaleonCms::UserDecorator

Inherits:
ApplicationDecorator show all
Includes:
CustomFieldsConcern
Defined in:
app/decorators/camaleon_cms/user_decorator.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CustomFieldsConcern

#render_fields, #the_field, #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

#the_meta, #the_option

Class Method Details

.object_class_nameObject



54
55
56
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 54

def self.object_class_name
  'CamaleonCms::User'
end

Instance Method Details

#the_admin_profile_urlObject

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.get_meta("avatar") : (default_avatar || h.asset_url("camaleon_cms/admin/img/no_image.jpg"))
end

#the_contentsObject

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_nameObject

return the fullname



11
12
13
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 11

def the_name
  object.fullname
end

#the_roleObject

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_sloganObject

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.get_meta("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.extract_options!
  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_usernameObject

return the identifier



6
7
8
# File 'app/decorators/camaleon_cms/user_decorator.rb', line 6

def the_username
  object.username
end