Skip to content

Commit

Permalink
Add check button for name uniqueueness
Browse files Browse the repository at this point in the history
Signed-off-by: Dimitris Aragiorgis <[email protected]>
  • Loading branch information
dimara committed Aug 12, 2013
1 parent 72b9e82 commit 3e4060e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion reception/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ class PersonForm(BaseNestedModelForm):
("USE", "Use Existing"),
)

check = BooleanField(required=False)
resolve = Field(required=False, widget=HiddenInput())
existing = Field(required=False, widget=HiddenInput())

Expand All @@ -443,12 +444,13 @@ class Meta:
def full_clean(self):
self.cleaned_data = {}
super(PersonForm, self).full_clean()
check = self.cleaned_data.get("check", None)
resolve = self.cleaned_data.get("resolve", None)
existing = self.cleaned_data.get("existing", None)
name = self.cleaned_data.get("name", None)
surname = self.cleaned_data.get("surname", None)
conflicting = Person.objects.filter(surname=surname).exclude(id=self.instance.id)
if conflicting and not self.instance.id:
if conflicting and (check or not self.instance.id):
self.fields["resolve"] = ChoiceField(choices=PersonForm.RESOLVE, required=False, label="Resolve")
self.fields["existing"] = ModelChoiceField(queryset=conflicting, required=False, label="Existing")
msgs = [u"Conflicting Person:", ]
Expand Down

0 comments on commit 3e4060e

Please sign in to comment.