Class: User

Inherits:
Object
  • Object
show all
Includes:
GDS::SSO::User, Mongoid::Document, Mongoid::Timestamps
Defined in:
app/models/user.rb

Instance Method Summary collapse

Instance Method Details

#assign(edition, recipient) ⇒ Object



75
76
77
# File 'app/models/user.rb', line 75

def assign(edition, recipient)
  GovukContentModels::ActionProcessors::AssignProcessor.new(self, edition, { recipient_id: recipient.id }).processed_edition
end

#create_edition(format, attributes = {}) ⇒ Object



67
68
69
# File 'app/models/user.rb', line 67

def create_edition(format, attributes = {})
  GovukContentModels::ActionProcessors::CreateEditionProcessor.new(self, nil, {}, { format: format, edition_attributes: attributes }).processed_edition
end

#gravatar_url(opts = {}) ⇒ Object



42
43
44
45
46
47
48
49
# File 'app/models/user.rb', line 42

def gravatar_url(opts = {})
  opts.symbolize_keys!
  "%s.gravatar.com/avatar/%s%s" % [
    opts[:ssl] ? "https://secure" : "http://www",
    Digest::MD5.hexdigest(email.downcase),
    opts[:s] ? "?s=#{CGI.escape(opts[:s])}" : ""
  ]
end

#new_version(edition, convert_to = nil) ⇒ Object



71
72
73
# File 'app/models/user.rb', line 71

def new_version(edition, convert_to = nil)
  GovukContentModels::ActionProcessors::NewVersionProcessor.new(self, edition, {}, { convert_to: convert_to }).processed_edition
end

#progress(edition, action_attributes) ⇒ Object



51
52
53
54
55
56
57
# File 'app/models/user.rb', line 51

def progress(edition, action_attributes)
  request_type = action_attributes.delete(:request_type)

  processor = GovukContentModels::ActionProcessors::REQUEST_TYPE_TO_PROCESSOR[request_type.to_sym]
  edition = GovukContentModels::ActionProcessors::const_get(processor).new(self, edition, action_attributes, {}).processed_edition
  edition.save if edition
end

#record_note(edition, comment, type = Action::NOTE) ⇒ Object



59
60
61
# File 'app/models/user.rb', line 59

def record_note(edition, comment, type = Action::NOTE)
  edition.new_action(self, type, comment: comment)
end

#resolve_important_note(edition) ⇒ Object



63
64
65
# File 'app/models/user.rb', line 63

def resolve_important_note(edition)
  record_note(edition, nil, Action::IMPORTANT_NOTE_RESOLVED)
end

#to_sObject



38
39
40
# File 'app/models/user.rb', line 38

def to_s
  name || email || ""
end

#unassign(edition) ⇒ Object



79
80
81
# File 'app/models/user.rb', line 79

def unassign(edition)
  GovukContentModels::ActionProcessors::AssignProcessor.new(self, edition).processed_edition
end