Пример #1
0
class GroupActionSerializer(serializers.ModelSerializer):
    """
    群组行为
    """

    group = serializers.PrimaryKeyRelatedField(queryset=Group.objects.filter(is_active=True), required=True)
    action = serializers.PrimaryKeyRelatedField(queryset=Action.objects.filter(is_active=True), required=True)

    class Meta:
        model = GroupAction
        validators = [UniqueTogetherValidator(queryset=GroupAction.objects.all(), fields=('group', 'action'), message='群组行为已存在')]
        fields = ('id', 'group', 'action')
Пример #2
0
class GroupMenuSerializer(serializers.ModelSerializer):
    """
    群组菜单
    """

    group = serializers.PrimaryKeyRelatedField(queryset=Group.objects.filter(is_active=True), required=True)
    menu = serializers.PrimaryKeyRelatedField(queryset=Menu.objects.filter(is_active=True), required=True)

    class Meta:
        model = GroupMenu
        validators = [UniqueTogetherValidator(queryset=GroupMenu.objects.all(), fields=('group', 'menu'), message='群组角色已存在')]
        fields = ('id', 'group', 'menu')
Пример #3
0
class RoleActionSerializer(serializers.ModelSerializer):
    """
    角色行为
    """

    role = serializers.PrimaryKeyRelatedField(
        queryset=Role.objects.filter(is_active=True), required=True)
    action = serializers.PrimaryKeyRelatedField(
        queryset=Action.objects.filter(is_active=True), required=True)

    class Meta:
        model = RoleAction
        validators = [
            UniqueTogetherValidator(queryset=RoleAction.objects.all(),
                                    fields=('role', 'action'),
                                    message='角色菜单已存在')
        ]
        fields = ('id', 'role', 'action')