Exemplo n.º 1
0
def add_model(request):
    page_type, model = get_page_type_from_url(request.path)
    form_type = import_form("%sForm" % model.__name__)
    template_variables = process_form(request, form_type)
    template_variables["url"] = "/%s/add" % page_type
    template = "new_%s.html" % page_type
    return render_to_response(template, template_variables, context_instance=RequestContext(request))
Exemplo n.º 2
0
 def test_process_form(self):
     form_data = self.event_form_data
     form_data['name'] = 'Test3'
     request = self.factory.post('/event/add', self.event_form_data)
     template_variables = process_form(request, EventForm)
     self.assertEqual(template_variables['success_message'],
                      'Record successfully created')
     self.assertEqual(Event.objects.filter(name='Test3').count(), 1)
Exemplo n.º 3
0
def add_alert(request):
    template_variables = process_form(request, AlertForm, request.user)
    return render_to_response("new_alert.html", template_variables, context_instance=RequestContext(request))