You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
from django.contrib.auth.models import ContentType
|
|
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
from rest_framework import serializers
|
|
|
|
|
|
|
|
from ..models import Permission
|
|
|
|
|
|
|
|
__all__ = ['PermissionSerializer', 'UserPermsSerializer']
|
|
|
|
|
|
|
|
|
|
|
|
class ContentTypeSerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = ContentType
|
|
|
|
fields = ['id', 'app_label', 'model']
|
|
|
|
|
|
|
|
|
|
|
|
class PermissionSerializer(serializers.ModelSerializer):
|
|
|
|
content_type = ContentTypeSerializer(read_only=True)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Permission
|
|
|
|
fields = ['id', 'name', 'content_type', 'codename']
|
|
|
|
|
|
|
|
|
|
|
|
class UserPermsSerializer(serializers.Serializer):
|
|
|
|
perms = serializers.ListField(label=_('Perms'), read_only=True)
|
|
|
|
|
|
|
|
def create(self, validated_data):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def update(self, instance, validated_data):
|
|
|
|
pass
|