Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Admin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
osuny
Admin
Commits
c0c4fc05
Commit
c0c4fc05
authored
1 year ago
by
Arnaud Levy
Browse files
Options
Downloads
Patches
Plain Diff
à tester
parent
9bc77a3c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/controllers/server/websites_controller.rb
+0
-4
0 additions, 4 deletions
app/controllers/server/websites_controller.rb
app/models/communication/website.rb
+18
-0
18 additions, 0 deletions
app/models/communication/website.rb
with
18 additions
and
4 deletions
app/controllers/server/websites_controller.rb
+
0
−
4
View file @
c0c4fc05
...
...
@@ -27,10 +27,6 @@ class Server::WebsitesController < Server::ApplicationController
def
update
@website
.
update
(
website_params
)
@website
.
recursive_dependencies
.
each
do
|
dependency
|
next
unless
dependency
.
respond_to?
(
:university_id
)
dependency
.
update_column
:university_id
,
@website
.
university_id
end
redirect_to
server_website_path
(
@website
),
notice:
t
(
'admin.successfully_updated_html'
,
model:
@website
.
to_s
)
end
...
...
This diff is collapsed.
Click to expand it.
app/models/communication/website.rb
+
18
−
0
View file @
c0c4fc05
...
...
@@ -81,6 +81,7 @@ class Communication::Website < ApplicationRecord
validates
:default_image
,
size:
{
less_than:
5
.
megabytes
}
before_validation
:sanitize_fields
after_save
:manage_university_change
scope
:ordered
,
-
>
{
order
(
:name
)
}
scope
:in_production
,
-
>
{
where
(
in_production:
true
)
}
...
...
@@ -155,4 +156,21 @@ class Communication::Website < ApplicationRecord
self
.
repository
=
Osuny
::
Sanitizer
.
sanitize
(
self
.
repository
,
'string'
)
self
.
url
=
Osuny
::
Sanitizer
.
sanitize
(
self
.
url
,
'string'
)
end
def
manage_university_change
if
saved_change_to_university_id?
recursive_dependencies
.
each
do
|
dependency
|
reconnect_dependency
dependency
end
end
end
def
reconnect_dependency
(
dependency
)
return
unless
dependency
.
respond_to?
(
:university_id
)
# vérifier par les connexions qu'un objet indirect n'est pas utilisé dans un autre website
return
if
dependency
.
connections
.
where
.
not
(
website:
self
)
.
any?
# il faut si l'objet est une person déconnecter le user éventuellement associé.
dependency
.
update_column
:user_id
,
nil
if
dependency
.
is_a?
University
::
Person
dependency
.
update_column
:university_id
,
university_id
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment