Implement proper mergeing of organisations

This commit is contained in:
Magnus Hagander
2011-08-18 10:46:25 +02:00
parent 26a72e1d4c
commit 248d940c7e
5 changed files with 75 additions and 2 deletions

View File

@ -1,4 +1,5 @@
from django import forms
from django.forms import ValidationError
from models import Organisation
@ -7,3 +8,11 @@ class OrganisationForm(forms.ModelForm):
model = Organisation
exclude = ('lastconfirmed', 'approved', 'managers', )
class MergeOrgsForm(forms.Form):
merge_into = forms.ModelChoiceField(queryset=Organisation.objects.all())
merge_from = forms.ModelChoiceField(queryset=Organisation.objects.all())
def clean(self):
if self.cleaned_data['merge_into'] == self.cleaned_data['merge_from']:
raise ValidationError("The two organisations selected must be different!")
return self.cleaned_data