Beispiel #1
0
def create_contact(request, pk, template_name='contacts/create-contact.html'):
    context = {}
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            contact = form.save()
            #get other forms as well
            contact.save()
            return render_to_response(template_name,
                                      context,
                                      context_instance=RequestContext(request))
        else:
            try:
                '''
                do error handling
                if 'email' in form.errors.keys():
                    ip = get_object_or_404(InterestedParty, email=request.POST['email'])
                    ip.followed_request.add(obj)
                    return render_to_response(template_name, context, context_instance=RequestContext(request))
                '''
                pass
            except Exception as e:
                pass
            return render_to_response(template_name,
                                      context,
                                      context_instance=RequestContext(request))
    context['contact_form'] = ContactForm()
    return render_to_response(template_name,
                              context,
                              context_instance=RequestContext(request))
Beispiel #2
0
    def test_candidate_register_form(
            self, first_name, last_name, email, message, captcha, validity):
        """
        Tests that variations of a contact form entry behaves as expected.
        URL: https://pypi.org/project/django-recaptcha/#local-development-and-functional-testing
        """
        form = ContactForm(data={
            'first_name': first_name,
            'last_name': last_name,
            'email': email,
            'message': message,
            'captcha': captcha,
        })

        assert form.is_valid() is validity, 'Asserts valid form submission for input variation'
Beispiel #3
0
def create_contact(request, pk, template_name='contacts/create-contact.html'):
    context = {}
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            contact = form.save()
            #get other forms as well
            contact.save()
            return render_to_response(template_name, context, context_instance=RequestContext(request))
        else:
            try:
                '''
                do error handling
                if 'email' in form.errors.keys():
                    ip = get_object_or_404(InterestedParty, email=request.POST['email'])
                    ip.followed_request.add(obj)
                    return render_to_response(template_name, context, context_instance=RequestContext(request))
                '''
                pass
            except Exception as e:
                pass
            return render_to_response(template_name, context, context_instance=RequestContext(request))
    context['contact_form'] = ContactForm()
    return render_to_response(template_name, context, context_instance=RequestContext(request))