Skip to content
Snippets Groups Projects
Commit b010f2fc authored by Arnaud Levy's avatar Arnaud Levy
Browse files

List dependencies

parent 68f0e814
No related branches found
No related tags found
No related merge requests found
Showing
with 55 additions and 26 deletions
......@@ -60,7 +60,7 @@ class Admin::University::OrganizationsController < Admin::University::Applicatio
def organization_params
params.require(:university_organization)
.permit(
:name, :long_name, :description, :active, :sirene, :kind,
:name, :long_name, :slug, :description, :active, :sirene, :kind,
:address, :zipcode, :city, :country,
:website, :phone, :mail, :logo, :logo_delete
)
......
......@@ -20,7 +20,7 @@
#
# Foreign Keys
#
# fk_rails_31f1a0a2c9 (criterion_id => administration_qualiopi_criterions.id)
# fk_rails_eed87f7acf (criterion_id => administration_qualiopi_criterions.id)
#
class Administration::Qualiopi::Indicator < ApplicationRecord
include Sanitizable
......
......@@ -3,14 +3,12 @@ class Communication::Block::Partner < Communication::Block::Abstract
elements.each do |partner|
blob = find_blob partner, 'logo'
add_dependency blob unless blob.nil?
# TODO : add organization dependency
# id = partner['id']
# next if id.blank?
# organization = university.organizations.find id
# next if organization.nil?
# add_dependency organization
# add_dependency organization.active_storage_blobs
id = partner['id']
next if id.blank?
organization = university.organizations.find id
next if organization.nil?
add_dependency organization
add_dependency organization.active_storage_blobs
end
end
end
......@@ -22,7 +22,7 @@
#
# Foreign Keys
#
# fk_rails_94b0abd85b (university_id => universities.id)
# fk_rails_bb6a496c08 (university_id => universities.id)
#
class Communication::Website < ApplicationRecord
include WithUniversity
......
......@@ -22,7 +22,7 @@
#
# Foreign Keys
#
# fk_rails_94b0abd85b (university_id => universities.id)
# fk_rails_bb6a496c08 (university_id => universities.id)
#
class Communication::Website::Configs::BaseUrl < Communication::Website
......
......@@ -22,7 +22,7 @@
#
# Foreign Keys
#
# fk_rails_94b0abd85b (university_id => universities.id)
# fk_rails_bb6a496c08 (university_id => universities.id)
#
class Communication::Website::Configs::Permalinks < Communication::Website
......
......@@ -60,6 +60,12 @@ module WithGit
protected
def in_block_dependencies?(website)
website.blocks.find_each do |block|
return true if in? block.git_dependencies
end
end
def websites_for_self
if is_a? Communication::Website
[self]
......
......@@ -6,9 +6,10 @@ module WithSlug
validate :slug_must_be_unique
validates :slug, format: { with: /\A[a-z0-9\-]+\z/, message: I18n.t('slug_error') }
before_validation :regenerate_slug, :make_path
before_validation :check_slug, :make_path
def regenerate_slug
def check_slug
self.slug = to_s.parameterize if self.slug.blank?
current_slug = self.slug
n = 0
while slug_unavailable?(self.slug)
......
......@@ -39,7 +39,7 @@
#
# Foreign Keys
#
# fk_rails_6e16107511 (university_id => universities.id)
# fk_rails_08b351087c (university_id => universities.id)
# fk_rails_ec1f16f607 (parent_id => education_programs.id)
#
class Education::Program < ApplicationRecord
......
......@@ -8,12 +8,13 @@
# city :string
# country :string
# description :text
# email :string
# kind :integer default("company")
# long_name :string
# mail :string
# name :string
# phone :string
# sirene :string
# slug :string
# url :string
# zipcode :string
# created_at :datetime not null
......@@ -32,6 +33,7 @@ class University::Organization < ApplicationRecord
include WithGit
include WithBlobs
include WithUniversity
include WithSlug
has_one_attached_deletable :logo
......@@ -45,6 +47,18 @@ class University::Organization < ApplicationRecord
government: 30
}
def websites
university.communication_websites
end
def for_website?(website)
in_block_dependencies?(website)
end
def git_path(website)
"content/organizations/#{slug}.html" if for_website?(website)
end
def to_s
"#{name}"
end
......
......@@ -51,7 +51,7 @@ class University::Organization::Import < ApplicationRecord
:zipcode,
:city,
:country,
:mail,
:email,
:phone,
:url,
].each do |property|
......
......@@ -9,6 +9,7 @@
# first_name :string
# habilitation :boolean default(FALSE)
# is_administration :boolean
# is_alumnus :boolean default(FALSE)
# is_researcher :boolean
# is_teacher :boolean
# last_name :string
......@@ -145,12 +146,6 @@ class University::Person < ApplicationRecord
@teacher ||= University::Person::Teacher.find(id)
end
def in_block_dependencies?(website)
website.blocks.find_each do |block|
return true if in? block.git_dependencies
end
end
def for_website?(website)
in_block_dependencies?(website) ||
administrator.for_website?(website) ||
......
......@@ -9,6 +9,7 @@
# first_name :string
# habilitation :boolean default(FALSE)
# is_administration :boolean
# is_alumnus :boolean default(FALSE)
# is_researcher :boolean
# is_teacher :boolean
# last_name :string
......
......@@ -9,6 +9,7 @@
# first_name :string
# habilitation :boolean default(FALSE)
# is_administration :boolean
# is_alumnus :boolean default(FALSE)
# is_researcher :boolean
# is_teacher :boolean
# last_name :string
......
......@@ -9,6 +9,7 @@
# first_name :string
# habilitation :boolean default(FALSE)
# is_administration :boolean
# is_alumnus :boolean default(FALSE)
# is_researcher :boolean
# is_teacher :boolean
# last_name :string
......
......@@ -9,6 +9,7 @@
# first_name :string
# habilitation :boolean default(FALSE)
# is_administration :boolean
# is_alumnus :boolean default(FALSE)
# is_researcher :boolean
# is_teacher :boolean
# last_name :string
......
......@@ -58,7 +58,7 @@
<td>FR</td>
</tr>
<tr>
<th>mail</th>
<th>email</th>
<td>contact@lemonde.fr</td>
</tr>
<tr>
......
......@@ -7,6 +7,12 @@
</div>
<div class="card-body">
<%= f.input :name %>
<%= f.input :slug,
as: :string,
input_html: organization.persisted? ? {} : {
class: 'js-slug-input',
data: { source: '#university_organization_name' }
} %>
<%= f.input :long_name %>
<%= f.input :kind, include_blank: false %>
<%= f.input :active %>
......
......@@ -11,7 +11,7 @@ city: "<%= @about.city %>"
country: "<%= @about.country %>"
phone: "<%= @about.phone %>"
email: "<%= @about.email %>"
website: "<%= @about.website %>"
website: "<%= @about.url %>"
<% if @about.logo.attached? %>
logo: "<%= @about.logo.blob.id %>"
<% end %>
......
class AddSlugToUniversityOrganizations < ActiveRecord::Migration[6.1]
def change
add_column :university_organizations, :slug, :string
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