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 ...@@ -60,7 +60,7 @@ class Admin::University::OrganizationsController < Admin::University::Applicatio
def organization_params def organization_params
params.require(:university_organization) params.require(:university_organization)
.permit( .permit(
:name, :long_name, :description, :active, :sirene, :kind, :name, :long_name, :slug, :description, :active, :sirene, :kind,
:address, :zipcode, :city, :country, :address, :zipcode, :city, :country,
:website, :phone, :mail, :logo, :logo_delete :website, :phone, :mail, :logo, :logo_delete
) )
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
# #
# Foreign Keys # 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 class Administration::Qualiopi::Indicator < ApplicationRecord
include Sanitizable include Sanitizable
......
...@@ -3,14 +3,12 @@ class Communication::Block::Partner < Communication::Block::Abstract ...@@ -3,14 +3,12 @@ class Communication::Block::Partner < Communication::Block::Abstract
elements.each do |partner| elements.each do |partner|
blob = find_blob partner, 'logo' blob = find_blob partner, 'logo'
add_dependency blob unless blob.nil? add_dependency blob unless blob.nil?
id = partner['id']
# TODO : add organization dependency next if id.blank?
# id = partner['id'] organization = university.organizations.find id
# next if id.blank? next if organization.nil?
# organization = university.organizations.find id add_dependency organization
# next if organization.nil? add_dependency organization.active_storage_blobs
# add_dependency organization
# add_dependency organization.active_storage_blobs
end end
end end
end end
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
# #
# Foreign Keys # Foreign Keys
# #
# fk_rails_94b0abd85b (university_id => universities.id) # fk_rails_bb6a496c08 (university_id => universities.id)
# #
class Communication::Website < ApplicationRecord class Communication::Website < ApplicationRecord
include WithUniversity include WithUniversity
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
# #
# Foreign Keys # Foreign Keys
# #
# fk_rails_94b0abd85b (university_id => universities.id) # fk_rails_bb6a496c08 (university_id => universities.id)
# #
class Communication::Website::Configs::BaseUrl < Communication::Website class Communication::Website::Configs::BaseUrl < Communication::Website
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
# #
# Foreign Keys # Foreign Keys
# #
# fk_rails_94b0abd85b (university_id => universities.id) # fk_rails_bb6a496c08 (university_id => universities.id)
# #
class Communication::Website::Configs::Permalinks < Communication::Website class Communication::Website::Configs::Permalinks < Communication::Website
......
...@@ -60,6 +60,12 @@ module WithGit ...@@ -60,6 +60,12 @@ module WithGit
protected 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 def websites_for_self
if is_a? Communication::Website if is_a? Communication::Website
[self] [self]
......
...@@ -6,9 +6,10 @@ module WithSlug ...@@ -6,9 +6,10 @@ module WithSlug
validate :slug_must_be_unique validate :slug_must_be_unique
validates :slug, format: { with: /\A[a-z0-9\-]+\z/, message: I18n.t('slug_error') } 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 current_slug = self.slug
n = 0 n = 0
while slug_unavailable?(self.slug) while slug_unavailable?(self.slug)
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
# #
# Foreign Keys # Foreign Keys
# #
# fk_rails_6e16107511 (university_id => universities.id) # fk_rails_08b351087c (university_id => universities.id)
# fk_rails_ec1f16f607 (parent_id => education_programs.id) # fk_rails_ec1f16f607 (parent_id => education_programs.id)
# #
class Education::Program < ApplicationRecord class Education::Program < ApplicationRecord
......
...@@ -8,12 +8,13 @@ ...@@ -8,12 +8,13 @@
# city :string # city :string
# country :string # country :string
# description :text # description :text
# email :string
# kind :integer default("company") # kind :integer default("company")
# long_name :string # long_name :string
# mail :string
# name :string # name :string
# phone :string # phone :string
# sirene :string # sirene :string
# slug :string
# url :string # url :string
# zipcode :string # zipcode :string
# created_at :datetime not null # created_at :datetime not null
...@@ -32,6 +33,7 @@ class University::Organization < ApplicationRecord ...@@ -32,6 +33,7 @@ class University::Organization < ApplicationRecord
include WithGit include WithGit
include WithBlobs include WithBlobs
include WithUniversity include WithUniversity
include WithSlug
has_one_attached_deletable :logo has_one_attached_deletable :logo
...@@ -45,6 +47,18 @@ class University::Organization < ApplicationRecord ...@@ -45,6 +47,18 @@ class University::Organization < ApplicationRecord
government: 30 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 def to_s
"#{name}" "#{name}"
end end
......
...@@ -51,7 +51,7 @@ class University::Organization::Import < ApplicationRecord ...@@ -51,7 +51,7 @@ class University::Organization::Import < ApplicationRecord
:zipcode, :zipcode,
:city, :city,
:country, :country,
:mail, :email,
:phone, :phone,
:url, :url,
].each do |property| ].each do |property|
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
# first_name :string # first_name :string
# habilitation :boolean default(FALSE) # habilitation :boolean default(FALSE)
# is_administration :boolean # is_administration :boolean
# is_alumnus :boolean default(FALSE)
# is_researcher :boolean # is_researcher :boolean
# is_teacher :boolean # is_teacher :boolean
# last_name :string # last_name :string
...@@ -145,12 +146,6 @@ class University::Person < ApplicationRecord ...@@ -145,12 +146,6 @@ class University::Person < ApplicationRecord
@teacher ||= University::Person::Teacher.find(id) @teacher ||= University::Person::Teacher.find(id)
end 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) def for_website?(website)
in_block_dependencies?(website) || in_block_dependencies?(website) ||
administrator.for_website?(website) || administrator.for_website?(website) ||
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
# first_name :string # first_name :string
# habilitation :boolean default(FALSE) # habilitation :boolean default(FALSE)
# is_administration :boolean # is_administration :boolean
# is_alumnus :boolean default(FALSE)
# is_researcher :boolean # is_researcher :boolean
# is_teacher :boolean # is_teacher :boolean
# last_name :string # last_name :string
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
# first_name :string # first_name :string
# habilitation :boolean default(FALSE) # habilitation :boolean default(FALSE)
# is_administration :boolean # is_administration :boolean
# is_alumnus :boolean default(FALSE)
# is_researcher :boolean # is_researcher :boolean
# is_teacher :boolean # is_teacher :boolean
# last_name :string # last_name :string
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
# first_name :string # first_name :string
# habilitation :boolean default(FALSE) # habilitation :boolean default(FALSE)
# is_administration :boolean # is_administration :boolean
# is_alumnus :boolean default(FALSE)
# is_researcher :boolean # is_researcher :boolean
# is_teacher :boolean # is_teacher :boolean
# last_name :string # last_name :string
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
# first_name :string # first_name :string
# habilitation :boolean default(FALSE) # habilitation :boolean default(FALSE)
# is_administration :boolean # is_administration :boolean
# is_alumnus :boolean default(FALSE)
# is_researcher :boolean # is_researcher :boolean
# is_teacher :boolean # is_teacher :boolean
# last_name :string # last_name :string
......
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
<td>FR</td> <td>FR</td>
</tr> </tr>
<tr> <tr>
<th>mail</th> <th>email</th>
<td>contact@lemonde.fr</td> <td>contact@lemonde.fr</td>
</tr> </tr>
<tr> <tr>
......
...@@ -7,6 +7,12 @@ ...@@ -7,6 +7,12 @@
</div> </div>
<div class="card-body"> <div class="card-body">
<%= f.input :name %> <%= 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 :long_name %>
<%= f.input :kind, include_blank: false %> <%= f.input :kind, include_blank: false %>
<%= f.input :active %> <%= f.input :active %>
......
...@@ -11,7 +11,7 @@ city: "<%= @about.city %>" ...@@ -11,7 +11,7 @@ city: "<%= @about.city %>"
country: "<%= @about.country %>" country: "<%= @about.country %>"
phone: "<%= @about.phone %>" phone: "<%= @about.phone %>"
email: "<%= @about.email %>" email: "<%= @about.email %>"
website: "<%= @about.website %>" website: "<%= @about.url %>"
<% if @about.logo.attached? %> <% if @about.logo.attached? %>
logo: "<%= @about.logo.blob.id %>" logo: "<%= @about.logo.blob.id %>"
<% end %> <% 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