Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iric-data
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
Container Registry
Model registry
Operate
Environments
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
bioinfo_iric
iric-data
Commits
44fc4c06
Commit
44fc4c06
authored
2 years ago
by
LouisGendron
Browse files
Options
Downloads
Patches
Plain Diff
Public share group
parent
6f03eab9
Branches
162-rm-dependence-to-python2
Branches containing commit
No related tags found
1 merge request
!89
Resolve "group public"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
portal/listeners.py
+12
-2
12 additions, 2 deletions
portal/listeners.py
portal/migrations/0029_auto_20230127_0952.py
+30
-0
30 additions, 0 deletions
portal/migrations/0029_auto_20230127_0952.py
with
42 additions
and
2 deletions
portal/listeners.py
+
12
−
2
View file @
44fc4c06
...
...
@@ -5,7 +5,7 @@ from django.dispatch import receiver
from
django_auth_ldap.backend
import
LDAPBackend
,
populate_user
from
django.db
import
transaction
from
django.utils
import
timezone
from
.models
import
Profile
,
Lab
from
.models
import
Profile
,
Lab
,
ShareGroup
@receiver
(
user_logged_in
)
...
...
@@ -47,13 +47,23 @@ def create_user_profile(sender, user, ldap_user=None, **kwargs):
profile
.
accountname
=
accountname
profile
.
save
()
public_group
=
ShareGroup
.
objects
.
filter
(
name
=
'
Public
'
).
first
()
if
public_group
and
profile
not
in
public_group
.
profiles
.
all
():
public_group
.
profiles
.
add
(
profile
)
public_group
.
save
()
@receiver
(
post_save
,
sender
=
User
)
def
create_external_user_profile
(
sender
,
instance
,
created
,
**
kwargs
):
"""
Create user profile for non LDAP users
"""
if
created
:
Profile
.
objects
.
create
(
user
=
instance
)
profile
=
Profile
.
objects
.
create
(
user
=
instance
)
public_group
=
ShareGroup
.
objects
.
filter
(
name
=
'
Public
'
).
first
()
if
public_group
and
profile
not
in
public_group
.
profiles
.
all
():
public_group
.
profiles
.
add
(
profile
)
public_group
.
save
()
# Automatically manage Auth Groups
...
...
This diff is collapsed.
Click to expand it.
portal/migrations/0029_auto_20230127_0952.py
0 → 100644
+
30
−
0
View file @
44fc4c06
# Generated by Django 2.2.17 on 2023-01-27 14:52
from
django.db
import
migrations
def
add_public_sharegroup
(
apps
,
schema_editor
):
ShareGroup
=
apps
.
get_model
(
'
portal
'
,
'
ShareGroup
'
)
Profile
=
apps
.
get_model
(
'
portal
'
,
'
Profile
'
)
creator
=
Profile
.
objects
.
get
(
user__username
=
'
louis.gendron@umontreal.ca
'
)
group
,
created
=
ShareGroup
.
objects
.
get_or_create
(
name
=
'
Public
'
,
last_update_by
=
creator
)
profiles
=
Profile
.
objects
.
all
()
group
.
profiles
.
add
(
*
profiles
)
group
.
save
()
def
remove_public_sharegroup
(
apps
,
schema_editor
):
ShareGroup
=
apps
.
get_model
(
'
portal
'
,
'
ShareGroup
'
)
group
=
ShareGroup
.
objects
.
filter
(
name
=
'
Public
'
).
first
()
if
group
:
group
.
delete
()
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'
portal
'
,
'
0028_auto_20230105_1026
'
),
]
operations
=
[
migrations
.
RunPython
(
add_public_sharegroup
,
remove_public_sharegroup
)
]
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