Added unique constraint on the Domain.name column.

This commit is contained in:
Antoine Nguyen
2011-07-09 15:08:21 +02:00
parent c7d43f31aa
commit 8e25023c00
4 changed files with 163 additions and 39 deletions
+12 -2
View File
@@ -14,9 +14,19 @@ class DomainForm(forms.ModelForm):
fields = ("name", "quota", "enabled")
def __init__(self, *args, **kwargs):
self.oldname = None
if kwargs.has_key("instance"):
self.oldname = kwargs["instance"].name
super(DomainForm, self).__init__(*args, **kwargs)
for f in ['name', 'quota']:
self.fields[f].widget.attrs['size'] = 14
def save(self, force_insert=False, force_update=False, commit=True):
d = super(DomainForm, self).save(commit=False)
if commit:
if self.oldname is not None and d.name != self.oldname:
if not d.rename_dir(self.oldname):
raise AdminError(_("Failed to rename domain, check permissions"))
d.save()
return d
class ProxyForm(forms.ModelForm):
def __init__(self, user, *args, **kwargs):