Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hypha
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
Package registry
Container 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
ots
hypha
Commits
7ce6b973
Commit
7ce6b973
authored
7 years ago
by
Dan Braghis
Browse files
Options
Downloads
Patches
Plain Diff
Fix user permissions not found
Related:
https://code.djangoproject.com/ticket/23422
parent
72e49544
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
opentech/users/groups.py
+2
-2
2 additions, 2 deletions
opentech/users/groups.py
opentech/users/migrations/0002_initial_data.py
+22
-3
22 additions, 3 deletions
opentech/users/migrations/0002_initial_data.py
opentech/users/models.py
+1
-0
1 addition, 0 deletions
opentech/users/models.py
with
25 additions
and
5 deletions
opentech/users/groups.py
+
2
−
2
View file @
7ce6b973
...
...
@@ -21,7 +21,7 @@ GROUPS = [
'
add_image
'
,
'
change_image
'
,
'
delete_image
'
,
'
add_document
'
,
'
change_document
'
,
'
delete_document
'
,
'
access_admin
'
],
],
},
{
'
name
'
:
'
Administrator
'
,
...
...
@@ -30,6 +30,6 @@ GROUPS = [
'
add_document
'
,
'
change_document
'
,
'
delete_document
'
,
'
add_user
'
,
'
change_user
'
,
'
delete_user
'
,
'
access_admin
'
,
'
change_site
'
],
],
}
]
This diff is collapsed.
Click to expand it.
opentech/users/migrations/0002_initial_data.py
+
22
−
3
View file @
7ce6b973
...
...
@@ -2,20 +2,36 @@
# Generated by Django 1.11.7 on 2017-12-15 13:15
from
__future__
import
unicode_literals
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.core.management.sql
import
emit_post_migrate_signal
from
django.db
import
migrations
from
opentech.users.groups
import
GROUPS
def
add_groups
(
apps
,
schema_editor
):
# Workaround for https://code.djangoproject.com/ticket/23422
db_alias
=
schema_editor
.
connection
.
alias
try
:
emit_post_migrate_signal
(
2
,
False
,
db_alias
)
except
TypeError
:
# Django < 1.9
try
:
# Django 1.8
emit_post_migrate_signal
(
2
,
False
,
'
default
'
,
db_alias
)
except
TypeError
:
# Django < 1.8
emit_post_migrate_signal
([],
2
,
False
,
'
default
'
,
db_alias
)
Group
=
apps
.
get_model
(
'
auth.Group
'
)
Permission
=
apps
.
get_model
(
'
auth.Permission
'
)
for
group_data
in
GROUPS
:
group
,
created
=
Group
.
objects
.
get_or_create
(
name
=
group_data
[
'
name
'
])
for
permission
in
group_data
[
'
permissions
'
]:
group
.
permissions
.
add
(
Permission
.
objects
.
get
(
codename
=
permission
))
pass
try
:
group
.
permissions
.
add
(
Permission
.
objects
.
get
(
codename
=
permission
))
except
ObjectDoesNotExist
:
print
(
"
Could not find the
'
%s
'
permission
"
%
permission
)
def
remove_groups
(
apps
,
schema_editor
):
...
...
@@ -29,7 +45,10 @@ class Migration(migrations.Migration):
dependencies
=
[
(
'
users
'
,
'
0001_initial
'
),
(
'
wagtailadmin
'
,
'
0001_create_admin_access_permissions
'
)
(
'
wagtailadmin
'
,
'
0001_create_admin_access_permissions
'
),
(
'
wagtailimages
'
,
'
0002_initial_data
'
),
(
'
wagtaildocs
'
,
'
0002_initial_data
'
),
(
'
contenttypes
'
,
'
__latest__
'
),
]
operations
=
[
...
...
This diff is collapsed.
Click to expand it.
opentech/users/models.py
+
1
−
0
View file @
7ce6b973
from
django.contrib.auth.models
import
AbstractUser
class
User
(
AbstractUser
):
pass
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