-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mixins added for required fields swagger
- Loading branch information
Showing
3 changed files
with
22 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
from rest_framework import serializers | ||
|
||
from api.mixins import UrlFieldMixin | ||
from api.mixins import RequiredFieldsMixin, UrlFieldMixin | ||
|
||
from . import models as gmn_models | ||
|
||
|
||
class GMNSerializer(UrlFieldMixin, serializers.ModelSerializer): | ||
class GMNSerializer(UrlFieldMixin, RequiredFieldsMixin, serializers.ModelSerializer): | ||
class Meta: | ||
model = gmn_models.GMN | ||
fields = "__all__" | ||
|
||
|
||
class MeasuringpointSerializer(UrlFieldMixin, serializers.ModelSerializer): | ||
class MeasuringpointSerializer( | ||
UrlFieldMixin, RequiredFieldsMixin, serializers.ModelSerializer | ||
): | ||
class Meta: | ||
model = gmn_models.Measuringpoint | ||
fields = "__all__" |
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,17 +1,24 @@ | ||
from rest_framework import serializers | ||
|
||
from api.mixins import UrlFieldMixin | ||
from api.mixins import RequiredFieldsMixin, UrlFieldMixin | ||
|
||
from . import models as gmw_models | ||
|
||
|
||
class GMWSerializer(UrlFieldMixin, serializers.ModelSerializer): | ||
class GMWSerializer(UrlFieldMixin, RequiredFieldsMixin, serializers.ModelSerializer): | ||
class Meta: | ||
model = gmw_models.GMW | ||
fields = "__all__" | ||
|
||
|
||
class MonitoringTubeSerializer(UrlFieldMixin, serializers.ModelSerializer): | ||
class MonitoringTubeSerializer( | ||
UrlFieldMixin, RequiredFieldsMixin, serializers.ModelSerializer | ||
): | ||
class Meta: | ||
model = gmw_models.MonitoringTube | ||
fields = "__all__" | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
for field in self.fields.values(): | ||
field.required = True |