|
@@ -53,7 +53,7 @@ class DomainList(generics.ListCreateAPIView):
|
|
|
|
|
|
queryset = Domain.objects.filter(name=serializer.validated_data['name'])
|
|
|
if queryset.exists():
|
|
|
- ex = ValidationError(detail={"detail": "This domain name is already registered.", "code": "domain-taken"})
|
|
|
+ ex = ValidationError(detail={"detail": "This domain name is unavailable.", "code": "domain-unavailable"})
|
|
|
ex.status_code = status.HTTP_409_CONFLICT
|
|
|
raise ex
|
|
|
|
|
@@ -62,7 +62,15 @@ class DomainList(generics.ListCreateAPIView):
|
|
|
ex.status_code = status.HTTP_403_FORBIDDEN
|
|
|
raise ex
|
|
|
|
|
|
- obj = serializer.save(owner=self.request.user)
|
|
|
+ try:
|
|
|
+ obj = serializer.save(owner=self.request.user)
|
|
|
+ except Exception as e:
|
|
|
+ if str(e).endswith(' already exists"}'):
|
|
|
+ ex = ValidationError(detail={"detail": "This domain name is unavailable.", "code": "domain-unavailable"})
|
|
|
+ ex.status_code = status.HTTP_409_CONFLICT
|
|
|
+ raise ex
|
|
|
+ else:
|
|
|
+ raise e
|
|
|
|
|
|
def sendDynDnsEmail(domain):
|
|
|
content_tmpl = get_template('emails/domain-dyndns/content.txt')
|