Saturday progress
This commit is contained in:
+19
-5
@@ -31,7 +31,6 @@ class Supplier
|
||||
has_many :sections, dependent: :destroy
|
||||
|
||||
after_create :add_section_on_create
|
||||
after_create :send_creation_notifications
|
||||
|
||||
view :by_email, key: :email
|
||||
|
||||
@@ -39,7 +38,7 @@ class Supplier
|
||||
validates :iens_profile, numericality: {allow_blank: true}
|
||||
|
||||
def location=(val)
|
||||
lat, lng = val.strip.split(/[ ,]+/).map(&:to_f)
|
||||
lat, lng = val.is_a?(Array) ? val : val.strip.split(/[ ,]+/).map(&:to_f)
|
||||
self.lat = lat
|
||||
self.lng = lng
|
||||
end
|
||||
@@ -88,14 +87,29 @@ class Supplier
|
||||
self.open = false
|
||||
save
|
||||
end
|
||||
|
||||
|
||||
# Find a user by its confirmation token and try to confirm it.
|
||||
# If no user is found, returns a new user with an error.
|
||||
# If the user is already confirmed, create an error for the user
|
||||
# Options must have the confirmation_token
|
||||
#
|
||||
# Overwrite devise method for mail sending
|
||||
def self.confirm_by_token(confirmation_token)
|
||||
confirmable = find_or_initialize_with_error_by(:confirmation_token, confirmation_token)
|
||||
confirmable.confirm! if confirmable.persisted?
|
||||
confirmable.send_creation_notifications if confirmable.errors.empty?
|
||||
confirmable
|
||||
end
|
||||
|
||||
def send_creation_notifications
|
||||
SupplierMailer.creation(self).deliver
|
||||
end
|
||||
private
|
||||
|
||||
def add_section_on_create
|
||||
@section = Section.create supplier: self, title: I18n.t('supplier.section.first_section_title')
|
||||
end
|
||||
|
||||
def send_creation_notifications
|
||||
SupplierMailer.creation(self).deliver
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user