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
9f6faa83
Verified
Commit
9f6faa83
authored
4 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Synchronise group to Django group on saving
parent
23d2c21d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!214
Resolve "Synchronise AlekSIS groups with Django groups"
Pipeline
#1292
failed
4 years ago
Stage: test
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/core/models.py
+13
-0
13 additions, 0 deletions
aleksis/core/models.py
with
13 additions
and
0 deletions
aleksis/core/models.py
+
13
−
0
View file @
9f6faa83
...
...
@@ -2,6 +2,7 @@ from datetime import date, datetime
from
typing
import
Optional
,
Iterable
,
Union
,
Sequence
,
List
from
django.contrib.auth
import
get_user_model
from
djang.contrib.auth.models
import
Group
as
DjangoGroup
from
django.contrib.contenttypes.fields
import
GenericForeignKey
from
django.contrib.contenttypes.models
import
ContentType
from
django.db
import
models
...
...
@@ -260,6 +261,18 @@ class Group(ExtensibleModel):
def
__str__
(
self
)
->
str
:
return
"
%s (%s)
"
%
(
self
.
name
,
self
.
short_name
)
def
save
(
self
,
*
args
,
**
kwargs
):
super
().
save
(
*
args
,
**
kwargs
)
# Synchronise group to Django group with same name
dj_group
,
_
=
DjangoGroup
.
objects
.
get_or_create
(
name
=
self
.
name
)
dj_group
.
users
.
set
(
list
(
self
.
members
.
values_list
(
"
user
"
,
flat
=
True
).
union
(
self
.
owners
.
values_list
(
"
user
"
,
flat
=
True
))
)
)
dj_group
.
save
()
class
Activity
(
ExtensibleModel
):
user
=
models
.
ForeignKey
(
"
Person
"
,
on_delete
=
models
.
CASCADE
,
related_name
=
"
activities
"
)
...
...
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