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
Merge requests
!248
Resolve "Allow matching primary groups on arbitrary field"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Allow matching primary groups on arbitrary field"
241-allow-matching-primary-groups-on-arbitrary-field
into
master
Overview
0
Commits
10
Pipelines
9
Changes
3
Merged
Nik | Klampfradler
requested to merge
241-allow-matching-primary-groups-on-arbitrary-field
into
master
4 years ago
Overview
0
Commits
10
Pipelines
9
Changes
3
Expand
Closes
#241 (closed)
Edited
4 years ago
by
Nik | Klampfradler
0
0
Merge request reports
Compare
master
version 7
cc504b7f
4 years ago
version 6
66bb5ea1
4 years ago
version 5
871a619b
4 years ago
version 4
03d83a6a
4 years ago
version 3
93baf4e9
4 years ago
version 2
01a6ad0c
4 years ago
version 1
650562e0
4 years ago
master (base)
and
latest version
latest version
5c91e7cf
10 commits,
4 years ago
version 7
cc504b7f
9 commits,
4 years ago
version 6
66bb5ea1
7 commits,
4 years ago
version 5
871a619b
5 commits,
4 years ago
version 4
03d83a6a
4 commits,
4 years ago
version 3
93baf4e9
3 commits,
4 years ago
version 2
01a6ad0c
2 commits,
4 years ago
version 1
650562e0
1 commit,
4 years ago
3 files
+
45
−
4
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
aleksis/core/mixins.py
+
26
−
1
Options
from
datetime
import
datetime
from
typing
import
Any
,
Callable
,
Optional
,
Union
from
typing
import
Any
,
Callable
,
List
,
Optional
,
Tuple
,
Union
from
django.contrib.contenttypes.models
import
ContentType
from
django.contrib.sites.managers
import
CurrentSiteManager
@@ -7,6 +7,7 @@ from django.contrib.sites.models import Site
from
django.db
import
models
from
django.db.models
import
QuerySet
from
django.forms.models
import
ModelForm
,
ModelFormMetaclass
from
django.utils.functional
import
lazy
import
reversion
from
easyaudit.models
import
CRUDEvent
@@ -176,6 +177,30 @@ class ExtensibleModel(models.Model):
cls
.
_safe_add
(
field
,
name
)
@classmethod
def
syncable_fields
(
cls
)
->
List
[
models
.
Field
]:
"""
Collect all fields that can be synced on a model
"""
return
[
field
for
field
in
cls
.
_meta
.
fields
if
(
field
.
editable
and
not
field
.
auto_created
and
not
field
.
is_relation
)
]
@classmethod
def
syncable_fields_choices
(
cls
)
->
Tuple
[
Tuple
[
str
,
str
]]:
"""
Collect all fields that can be synced on a model
"""
return
tuple
(
[(
field
.
name
,
field
.
verbose_name
or
field
.
name
)
for
field
in
cls
.
syncable_fields
()]
)
@classmethod
def
syncable_fields_choices_lazy
(
cls
)
->
Callable
[[],
Tuple
[
Tuple
[
str
,
str
]]]:
"""
Collect all fields that can be synced on a model
"""
return
lazy
(
cls
.
syncable_fields_choices
,
tuple
)
class
Meta
:
abstract
=
True
Loading