-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Redo the permissions system again. It is now much simpler and the c…
…ode is easier to follow (sort of). * The tests have been fixed. There still needs to a be a lot more testing to make sure that everything is correct.
- Loading branch information
Showing
26 changed files
with
429 additions
and
453 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
from django.contrib.auth import get_user_model | ||
from django.contrib.auth.models import Permission | ||
from rest_framework import serializers | ||
|
||
from auth.models import Permissions | ||
|
||
User = get_user_model() | ||
|
||
|
||
class UserSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = User | ||
fields = ('id', 'email', 'first_name', 'last_name') | ||
|
||
|
||
class PermissionSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = Permission | ||
fields = ('id', 'name') | ||
|
||
|
||
class PermissionsSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = Permissions | ||
fields = ['user', 'permission', 'object_uuid'] | ||
# from django.contrib.auth import get_user_model | ||
# from django.contrib.auth.models import Permission | ||
# from rest_framework import serializers | ||
# | ||
# from auth.models import Permissions | ||
# | ||
# User = get_user_model() | ||
# | ||
# | ||
# class UserSerializer(serializers.ModelSerializer): | ||
# class Meta: | ||
# model = User | ||
# fields = ('id', 'email', 'first_name', 'last_name') | ||
# | ||
# | ||
# class PermissionSerializer(serializers.ModelSerializer): | ||
# class Meta: | ||
# model = Permission | ||
# fields = ('id', 'name') | ||
# | ||
# | ||
# class PermissionsSerializer(serializers.ModelSerializer): | ||
# class Meta: | ||
# model = Permissions | ||
# fields = ['user', 'permission', 'object_uuid'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Generated by Django 2.0.8 on 2018-10-02 00:15 | ||
from django.db import migrations | ||
|
||
|
||
def create_permission(Permission, content_type, name): | ||
Permission.objects.get_or_create(name='Can manage {0}'.format(name), content_type=content_type, codename='can_manage') | ||
Permission.objects.get_or_create(name='Can invite users to {0}'.format(name), content_type=content_type, codename='can_invite') | ||
Permission.objects.get_or_create(name='Can create {0}'.format(name), content_type=content_type, codename='can_create') | ||
|
||
|
||
def create_permissions(apps, schema_editor): | ||
ContentType = apps.get_model("contenttypes", "ContentType") | ||
Permission = apps.get_model("auth", "Permission") | ||
create_permission(Permission, ContentType.objects.get_or_create(app_label='documents', model='document')[0], 'documents') | ||
create_permission(Permission, ContentType.objects.get_or_create(app_label='projects', model='project')[0], 'projects') | ||
create_permission(Permission, ContentType.objects.get_or_create(app_label='organizations', model='organization')[0], 'organizations') | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('kala_auth', '0002_auto_20180116_0036'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(create_permissions), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Generated by Django 2.0.8 on 2018-10-09 02:52 | ||
|
||
import auth.models | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('kala_auth', '0003_auto_20181002_0231'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelManagers( | ||
name='user', | ||
managers=[ | ||
('objects', auth.models.KalaUserManager()), | ||
], | ||
), | ||
migrations.AlterField( | ||
model_name='user', | ||
name='last_name', | ||
field=models.CharField(blank=True, max_length=150, verbose_name='last name'), | ||
), | ||
] |
Oops, something went wrong.