Skip to content
Snippets Groups Projects
Commit 06891c30 authored by Tanner Prestegard's avatar Tanner Prestegard Committed by Alexander Pace
Browse files

Adding requirement that a Contact should have either an e-mail or phone number

parent c0270e28
No related branches found
No related tags found
No related merge requests found
......@@ -47,6 +47,11 @@ class Contact(models.Model):
#return "%s: %s" % (self.user.name, self.desc)
return u"{0} {1}: {2}".format(self.user.first_name, self.user.last_name, self.desc)
# Require at least one contact method (e-mail or phone).
def clean(self):
if not self.email and not self.phone:
raise ValidationError('At least one contact method (email, phone) required')
class Trigger(models.Model):
TYPES = ( ("create", "create"), ("change","change"), ("label","label") )
user = models.ForeignKey(User, null=False)
......
......@@ -141,7 +141,7 @@ def createContact(request):
if form.is_valid():
# Create the Contact
c = Contact(
user=request.user,
user = request.user,
desc = form.cleaned_data['desc'],
email = form.cleaned_data['email'],
phone = form.cleaned_data['phone']
......@@ -152,9 +152,9 @@ def createContact(request):
else:
form = ContactForm()
return render_to_response('profile/createNotification.html',
{ "form" : form,
"creating":"Contact",
},
{ "form": form,
"creating": "Contact",
},
context_instance=RequestContext(request))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment