Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nk20
Manage
Activity
Members
Labels
Plan
Issues
32
Issue boards
Milestones
Wiki
Code
Merge requests
6
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
BDE
nk20
Commits
6cc3cf41
Commit
6cc3cf41
authored
4 years ago
by
ynerant
Browse files
Options
Downloads
Patches
Plain Diff
A migration put the right role in the note account's memberships
parent
2097e673
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!136
PC Kfet
Pipeline
#8786
passed with stages
Stage: test
Stage: quality-assurance
in 12 minutes and 2 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/member/migrations/0006_create_note_account_bde_membership.py
+50
-0
50 additions, 0 deletions
...ber/migrations/0006_create_note_account_bde_membership.py
apps/scripts
+1
-1
1 addition, 1 deletion
apps/scripts
with
51 additions
and
1 deletion
apps/member/migrations/0006_create_note_account_bde_membership.py
0 → 100644
+
50
−
0
View file @
6cc3cf41
import
sys
from
django.db
import
migrations
def
give_note_account_permissions
(
apps
,
schema_editor
):
"""
Automatically manage the membership of the Note account.
"""
User
=
apps
.
get_model
(
"
auth
"
,
"
user
"
)
Membership
=
apps
.
get_model
(
"
member
"
,
"
membership
"
)
Role
=
apps
.
get_model
(
"
permission
"
,
"
role
"
)
note
=
User
.
objects
.
filter
(
username
=
"
note
"
)
if
not
note
.
exists
():
# We are in a test environment, don't log error message
if
len
(
sys
.
argv
)
>
1
and
sys
.
argv
[
1
]
==
'
test
'
:
return
print
(
"
Warning: Note account was not found. The note account was not imported.
"
)
print
(
"
Make sure you have imported the NK15 database. The new import script handles correctly the permissions.
"
)
print
(
"
This migration will be ignored, you can re-run it if you forgot the note account or ignore it if you
"
"
don
'
t want this account.
"
)
return
note
=
note
.
get
()
# Set for the two clubs a large expiration date and the correct role.
for
m
in
Membership
.
objects
.
filter
(
user_id
=
note
.
id
).
all
():
m
.
date_end
=
"
3142-12-12
"
m
.
roles
.
set
(
Role
.
objects
.
filter
(
name
=
"
PC Kfet
"
).
all
())
m
.
save
()
# By default, the note account is only authorized to be logged from localhost.
note
.
password
=
"
ipbased$127.0.0.1
"
note
.
is_active
=
False
note
.
save
()
# Ensure that the note of the account is disabled
note
.
note
.
inactivity_reason
=
'
forced
'
note
.
note
.
is_active
=
False
note
.
save
()
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'
member
'
,
'
0005_remove_null_tag_on_charfields
'
),
(
'
permission
'
,
'
0001_initial
'
),
]
operations
=
[
migrations
.
RunPython
(
give_note_account_permissions
),
]
This diff is collapsed.
Click to expand it.
scripts
@
84be9d00
Compare
7e27c3b7
...
84be9d00
Subproject commit
7e27c3b71b04af0867d5fbe4916e2d1278637599
Subproject commit
84be9d0062beee2c1dc09f2f7ef082e6f6240ad1
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