示例#1
0
def editReporter(request, reporter_pk):
    reporter = get_object_or_404(HealthProviderBase, pk=reporter_pk)
    reporter_form = ReporterForm(instance=reporter, request=request)
    if request.method == 'POST':
        reporter_form = ReporterForm(instance=reporter,
                data=request.POST, request=request)
        if reporter_form.is_valid():
            reporter_form.save()
            return generic_row(request, model=HealthProviderBase, pk=reporter_pk, partial_row='/cvs/reporter/partials/reporter_row.html')
        else:
            return render_to_response('cvs/reporter/partials/edit_reporter.html'
                    , {'reporter_form': reporter_form, 'reporter'
                    : reporter},
                    context_instance=RequestContext(request))
    else:
        return render_to_response('cvs/reporter/partials/edit_reporter.html',
                                  {'reporter_form': reporter_form,
                                  'reporter': reporter},
                                  context_instance=RequestContext(request))
示例#2
0
def newReporter(request):
    if request.method == 'POST':
        reporter_form = ReporterForm(data=request.POST, request=request)
        if reporter_form.is_valid():
            reporter_form.reporter = HealthProvider.objects.create(active=True)
            reporter_form.save()
            reporter = reporter_form.reporter
            return render_to_response('cvs/reporter/partials/new_reporter.html',
                                      {'added_reporter':reporter},
                                      context_instance=RequestContext(request))
        else:
            return render_to_response('cvs/reporter/partials/new_reporter.html',
                                      {'report_form':reporter_form},
                                      context_instance=RequestContext(request))
    else:
        reporter_form = ReporterForm(request=request)
        facilities = get_user_district_facilities(request.user)
        toret = render_to_response('cvs/reporter/partials/new_reporter.html',
                           {'reporter_form':reporter_form,
                            'facilities':facilities},
                           context_instance=RequestContext(request))
        return toret