2017-03-22 16:15:25 +00:00
|
|
|
# ~*~ coding: utf-8 ~*~
|
|
|
|
from __future__ import unicode_literals
|
2024-09-06 09:41:09 +00:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2017-03-22 16:15:25 +00:00
|
|
|
from rest_framework import serializers
|
|
|
|
|
2024-11-07 02:38:34 +00:00
|
|
|
from common.serializers import WritableNestedModelSerializer
|
|
|
|
from common.serializers.fields import ReadableHiddenField
|
2024-09-06 09:41:09 +00:00
|
|
|
from common.serializers.mixin import CommonBulkModelSerializer
|
|
|
|
from .mixin import ScopeSerializerMixin
|
2022-11-29 11:44:12 +00:00
|
|
|
from ..models import AdHoc
|
2024-11-07 02:38:34 +00:00
|
|
|
from ops.serializers import AdhocVariableSerializer
|
2017-03-22 16:15:25 +00:00
|
|
|
|
|
|
|
|
2024-11-07 02:38:34 +00:00
|
|
|
class AdHocSerializer(ScopeSerializerMixin, CommonBulkModelSerializer, WritableNestedModelSerializer):
|
2022-11-29 11:44:12 +00:00
|
|
|
creator = ReadableHiddenField(default=serializers.CurrentUserDefault())
|
2024-11-07 02:38:34 +00:00
|
|
|
variable = AdhocVariableSerializer(many=True, required=False, allow_null=True, label=_('Variable'))
|
2022-11-11 11:20:17 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = AdHoc
|
2024-10-09 08:10:14 +00:00
|
|
|
read_only_field = ["id", "creator", "date_created", "date_updated", "created_by"]
|
2024-11-07 02:38:34 +00:00
|
|
|
fields_m2m = ['variable']
|
|
|
|
fields = read_only_field + fields_m2m + ["id", "name", "scope", "module", "args", "comment"]
|