2023-06-14 06:42:53 +00:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2023-04-10 02:57:44 +00:00
|
|
|
from rest_framework import serializers
|
|
|
|
|
2023-06-30 07:54:06 +00:00
|
|
|
from assets.const import FillType
|
2023-04-10 02:57:44 +00:00
|
|
|
from assets.models import Database, Web
|
2023-06-14 06:42:53 +00:00
|
|
|
from common.serializers.fields import LabeledChoiceField
|
2023-04-10 02:57:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DatabaseSpecSerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = Database
|
|
|
|
fields = ['db_name', 'use_ssl', 'allow_invalid_cert']
|
|
|
|
|
|
|
|
|
|
|
|
class WebSpecSerializer(serializers.ModelSerializer):
|
2023-06-14 06:42:53 +00:00
|
|
|
autofill = LabeledChoiceField(choices=FillType.choices, label=_('Autofill'))
|
2023-06-30 07:54:06 +00:00
|
|
|
|
2023-04-10 02:57:44 +00:00
|
|
|
class Meta:
|
|
|
|
model = Web
|
|
|
|
fields = [
|
|
|
|
'autofill', 'username_selector', 'password_selector',
|
|
|
|
'submit_selector', 'script'
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
category_spec_serializer_map = {
|
|
|
|
'database': DatabaseSpecSerializer,
|
|
|
|
'web': WebSpecSerializer,
|
|
|
|
}
|