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

Merge branch 'connections' of github.com:noesya/osuny into connections

parents 8862dce5 2c5183e9
No related branches found
No related tags found
No related merge requests found
......@@ -88,6 +88,8 @@ class Communication::Website < ApplicationRecord
end
def dependencies
# Le website est le SEUL cas d'auto-dépendance
[self] +
configs +
pages +
posts +
......
......@@ -54,7 +54,7 @@ class Communication::Website::Post < ApplicationRecord
has_one :imported_post,
class_name: 'Communication::Website::Imported::Post',
dependent: :destroy
dependent: :destroy
belongs_to :author,
class_name: 'University::Person',
optional: true
......@@ -124,7 +124,8 @@ class Communication::Website::Post < ApplicationRecord
def dependencies
active_storage_blobs +
blocks +
categories
categories +
[author&.author]
end
def references
......
......@@ -11,11 +11,11 @@ module Communication::Website::WithGitRepository
@git_repository ||= Git::Repository.new self
end
# Supprimer tous les git_files qui ne sont pas dans les recursive_dependencie_syncable
# Supprimer tous les git_files qui ne sont pas dans les recursive_dependencies_syncable
def destroy_obsolete_git_files
website_git_files.find_each do |git_file|
dependency = git_file.about
is_obsolete = !dependency.in?(recursive_dependencie_syncable)
is_obsolete = !dependency.in?(recursive_dependencies_syncable)
if is_obsolete
# TODO git_file.destroy serait plus ActiveRecord
Communication::Website::GitFile.sync(self, dependency, destroy: true)
......
......@@ -17,11 +17,13 @@ module AsDirectObject
class_name: 'Communication::Website',
foreign_key: :communication_website_id
has_many :connections,
has_many :connections,
as: :direct_source,
class_name: 'Communication::Website::Connection',
dependent: :destroy # When the direct object disappears all connections with the object as a source must disappear
after_save :sync_connections
after_touch :sync_connections
end
def is_direct_object?
......@@ -31,4 +33,10 @@ module AsDirectObject
def is_indirect_object?
false
end
def sync_connections
dependencies.each do |dependency|
website.connect(dependency, self)
end
end
end
\ No newline at end of file
......@@ -52,6 +52,10 @@ class Education::Diploma < ApplicationRecord
"#{git_path_content_prefix(website)}diplomas/#{slug}/_index.html" if for_website?(website)
end
def dependencies
programs
end
def references
[]
end
......
......@@ -58,13 +58,14 @@ class University::Person < ApplicationRecord
include WithBlobs
include WithBlocks
include WithCountry
# WithRoles included before WithEducation because needed for the latter
include WithRoles
include WithEducation
include WithExperiences
include WithGitFiles
include WithPermalink
include WithPicture
include WithResearch
include WithRoles
include WithSlug
include WithTranslations
include WithUniversity
......@@ -206,7 +207,11 @@ class University::Person < ApplicationRecord
end
def references
[]
[administrator, author, researcher, teacher]
end
def person
@person ||= University::Person.find(id)
end
def administrator
......
......@@ -64,4 +64,12 @@ class University::Person::Administrator < University::Person
def template_static
"admin/university/people/administrators/static"
end
def dependencies
[person]
end
def references
education_programs_as_administrator
end
end
......@@ -64,4 +64,12 @@ class University::Person::Author < University::Person
def template_static
"admin/university/people/authors/static"
end
def dependencies
[person]
end
def references
communication_website_posts
end
end
......@@ -64,4 +64,12 @@ class University::Person::Researcher < University::Person
def template_static
"admin/university/people/researchers/static"
end
def dependencies
[person]
end
def references
research_journal_papers
end
end
......@@ -65,4 +65,12 @@ class University::Person::Teacher < University::Person
def template_static
"admin/university/people/teachers/static"
end
def dependencies
[person]
end
def references
education_programs_as_teacher
end
end
......@@ -47,6 +47,10 @@ Rails.application.config.to_prepare do
"data/media/#{id[0..1]}/#{id}.yml"
end
def syncable?
true
end
def exportable_to_git?
true
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