Skip to content
Snippets Groups Projects
Unverified Commit 805fbe12 authored by Sébastien Gaya's avatar Sébastien Gaya
Browse files

orga from extranet

parent e3809bfd
No related branches found
No related tags found
No related merge requests found
......@@ -74,6 +74,8 @@ class University::Organization < ApplicationRecord
}
validates_presence_of :name
# Organization can be created from extranet with only their name. Be careful for future validators.
# There is an attribute accessor above : `created_from_extranet`
enum kind: {
company: 10,
......
......@@ -50,11 +50,10 @@ class University::Person::Experience < ApplicationRecord
def create_organization_if_needed
if organization.nil? && organization_name.present?
self.organization_name = self.organization_name.strip
self.organization = university.organizations
.where("name ILIKE ?", organization_name)
.or(university.organizations.where(siren: organization_name)).first_or_create do |organization|
organization.created_from_extranet = true
end
orga = university.organizations.find_by("name ILIKE ?", organization_name)
orga ||= university.organizations.find_by(siren: organization_name)
orga ||= university.organizations.create(name: organization_name, created_from_extranet: true)
self.organization = orga if orga.persisted?
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment