Class: Decidim::AssemblyMemberPresenter

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb

Overview

Decorator for assembly members

Instance Method Summary collapse

Instance Method Details

#ageObject



8
9
10
# File 'decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb', line 8

def age
  (Time.current.strftime("%Y%m%d").to_i - birthday.strftime("%Y%m%d").to_i) / 10_000 if birthday
end

#avatar_url(variant = nil) ⇒ Object



36
37
38
39
40
# File 'decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb', line 36

def avatar_url(variant = nil)
  return user.avatar_url(variant) if user.present?

  non_user_avatar_path(variant)
end

#deleted?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb', line 56

def deleted?
  false
end

#has_tooltip?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb', line 52

def has_tooltip?
  false
end

#nameObject



14
15
16
# File 'decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb', line 14

def name
  user ? user.name : full_name
end

#nicknameObject



18
19
20
# File 'decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb', line 18

def nickname
  user.nickname if user
end

#non_user_avatarObject



48
49
50
# File 'decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb', line 48

def non_user_avatar
  attached_uploader(:non_user_avatar)
end

#non_user_avatar_path(variant = nil) ⇒ Object



42
43
44
45
46
# File 'decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb', line 42

def non_user_avatar_path(variant = nil)
  return non_user_avatar.default_url(variant) unless non_user_avatar.attached?

  non_user_avatar.path(variant:)
end

#personal_informationObject



22
23
24
25
26
27
28
# File 'decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb', line 22

def personal_information
  [
    gender.presence,
    age,
    birthplace.presence
  ].compact.join(" / ")
end

#positionObject



30
31
32
33
34
# File 'decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb', line 30

def position
  return position_other if __getobj__.position == "other"

  I18n.t(__getobj__.position, scope: "decidim.admin.models.assembly_member.positions", default: "")
end