Lang fixes, filter admins, fix nameserver adding
This commit is contained in:
		
							parent
							
								
									9e241adb8e
								
							
						
					
					
						commit
						54e34a49b0
					
				|  | @ -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 | ||||
| 
 | ||||
|  |  | |||
|  | @ -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) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue