Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
11c5c493
Verified
Commit
11c5c493
authored
4 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Auto-exclude self as remote when scanning remote syncable fields
parent
d8c992f9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!396
Resolve "Support syncing fields across foreign keys"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/core/mixins.py
+5
-2
5 additions, 2 deletions
aleksis/core/mixins.py
with
5 additions
and
2 deletions
aleksis/core/mixins.py
+
5
−
2
View file @
11c5c493
...
...
@@ -270,7 +270,7 @@ class ExtensibleModel(models.Model, metaclass=_ExtensibleModelBase):
to
.
property_
(
_virtual_related
,
related_name
)
@classmethod
def
syncable_fields
(
cls
,
recursive
:
bool
=
True
)
->
List
[
models
.
Field
]:
def
syncable_fields
(
cls
,
recursive
:
bool
=
True
,
exclude_remotes
:
List
=
[]
)
->
List
[
models
.
Field
]:
"""
Collect all fields that can be synced on a model.
If recursive is True, it recurses into related models and generates virtual
...
...
@@ -281,9 +281,12 @@ class ExtensibleModel(models.Model, metaclass=_ExtensibleModelBase):
if
ExtensibleModel
not
in
field
.
related_model
.
__mro__
:
# Related model is not extensible and thus has no syncable fields
continue
if
field
.
related_model
in
exclude_remotes
:
# Remote is excluded, probably to avoid recursion
continue
# Recurse into related model to get its fields as well
for
subfield
in
field
.
related_model
.
syncable_fields
():
for
subfield
in
field
.
related_model
.
syncable_fields
(
recursive
,
exclude_remotes
+
[
cls
]
):
# generate virtual field names for proxy access
name
=
f
"
_
{
field
.
name
}
__
{
subfield
.
name
}
"
verbose_name
=
f
"
{
field
.
verbose_name
}
->
{
subfield
.
verbose_name
}
"
...
...
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