From 54e34a49b0588d0db322ae2ca4224a7910439067 Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Tue, 28 Mar 2017 13:00:27 +0200 Subject: [PATCH] Lang fixes, filter admins, fix nameserver adding --- domains/forms.py | 13 ++++++++++--- rrequests/forms.py | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/domains/forms.py b/domains/forms.py index d09e20f..fa8e813 100644 --- a/domains/forms.py +++ b/domains/forms.py @@ -1,7 +1,7 @@ from django import forms from django.db.models import Q -from whoisdb.models import InetNum +from whoisdb.models import InetNum, Contact from whoisdb.forms import MntFormMixin from whoisdb.validators import IP46CIDRValidator @@ -33,6 +33,9 @@ class DomainForm(MntFormMixin, forms.ModelForm): self.fields['nameservers'].queryset.distinct() + if 'admin_c' in self.fields: + self.fields['admin_c'].queryset = Contact.getMntQueryset(mnts, self.instance, "admin_c") + def clean_name(self): name = self.cleaned_data['name'].lower() if self._create: @@ -74,6 +77,10 @@ class NameserverForm(MntFormMixin, forms.ModelForm): instance = getattr(self, "instance", None) self._create = not (instance and instance.pk) + mnts = self._user.maintainer_set.all() + if 'admin_c' in self.fields: + self.fields['admin_c'].queryset = Contact.getMntQueryset(mnts, self.instance, "admin_c") + def clean_name(self): name = self.cleaned_data['name'].lower().strip() if not name.endswith("."): @@ -115,7 +122,7 @@ class NameserverForm(MntFormMixin, forms.ModelForm): ipv4 = cleaned_data.get("glueIPv4") ipv6 = cleaned_data.get("glueIPv6") - if (ipv4 or ipv6) and self._create or not (self.instance.glueIPv4 == ipv4 and self.instance.glueIPv6 == ipv6): + if self._create and (ipv4 or ipv6) or not self._create and not (self.instance.glueIPv4 == ipv4 and self.instance.glueIPv6 == ipv6): mnts = self._user.maintainer_set.all() domains = Domain.objects.filter(mnt_by__in=mnts) found = False @@ -125,7 +132,7 @@ class NameserverForm(MntFormMixin, forms.ModelForm): break if not found: - raise forms.ValidationError("This nameserver is not under a domain you control.") + raise forms.ValidationError("You have glue IPs set, but this domain is not under a domain you control.") return cleaned_data diff --git a/rrequests/forms.py b/rrequests/forms.py index ad60c25..54cf84c 100644 --- a/rrequests/forms.py +++ b/rrequests/forms.py @@ -14,7 +14,7 @@ class RequestForm(forms.Form): subject = forms.CharField(label="Subject") resources = forms.CheckboxSelectMultiple(choices=RESOURCES) - message = forms.CharField(widget=forms.Textarea, help_text="Describe shortly what resources you need and what for you need them") + message = forms.CharField(widget=forms.Textarea, help_text="Describe shortly what resources you need and what you need them for") def __init__(self, user, *args, **kwargs): super(RequestForm, self).__init__(*args, **kwargs)