|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
#
|
|
|
|
|
import re
|
|
|
|
|
from rest_framework import serializers
|
|
|
|
|
from django.db.models import Prefetch
|
|
|
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
@ -91,6 +92,15 @@ class AssetSerializer(BulkOrgResourceModelSerializer):
|
|
|
|
|
'org_name': {'label': _('Org name')}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def validate_hostname(hostname):
|
|
|
|
|
pattern = r"^[\._@a-zA-Z0-9-]+$"
|
|
|
|
|
res = re.match(pattern, hostname)
|
|
|
|
|
if res is None:
|
|
|
|
|
msg = _("* The hostname contains characters that are not allowed")
|
|
|
|
|
raise serializers.ValidationError(msg)
|
|
|
|
|
return hostname
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def setup_eager_loading(cls, queryset):
|
|
|
|
|
""" Perform necessary eager loading of data. """
|
|
|
|
|