コード例 #1
0
ファイル: batch.py プロジェクト: lalitnandandiwakar/uSurvey
def edit(request, batch_id):
    batch = Batch.get(pk=batch_id)
    survey = batch.survey
    qset_view = QuestionSetView(model_class=Batch)
    qset_view.questionSetForm = BatchForm
    breadcrumbs = Batch.edit_breadcrumbs(survey=survey)
    cancel_url = '../'
    if breadcrumbs:
        request.breadcrumbs(breadcrumbs)
        cancel_url = breadcrumbs[-1][1]
    response = qset_view.edit(request,
                              batch,
                              extra_context={'cancel_url': cancel_url},
                              initial={'survey': survey.pk})
    if response.status_code == 302:
        response = HttpResponseRedirect(
            reverse('batch_index_page', args=(survey.pk, )))
    return response
コード例 #2
0
ファイル: batch.py プロジェクト: unicefuganda/uSurvey
def edit(request, batch_id):
    batch = Batch.get(pk=batch_id)
    survey = batch.survey
    qset_view = QuestionSetView(model_class=Batch)
    qset_view.questionSetForm = BatchForm
    breadcrumbs = Batch.edit_breadcrumbs(survey=survey)
    cancel_url = '../'
    if breadcrumbs:
        request.breadcrumbs(breadcrumbs)
        cancel_url = breadcrumbs[-1][1]
    response = qset_view.edit(
        request, batch, extra_context={
            'cancel_url': cancel_url}, initial={
            'survey': survey.pk})
    if response.status_code == 302:
        response = HttpResponseRedirect(
            reverse('batch_index_page', args=(survey.pk, )))
    return response
コード例 #3
0
ファイル: batch.py プロジェクト: unicefuganda/uSurvey
def show(request, survey_id, batch_id):
    batch = Batch.objects.get(id=batch_id)
    open_status_filter = BatchOpenStatusFilterForm(batch, request.GET)
    batch_location_ids = batch.open_locations.values_list(
        'location_id', flat=True)
    locations = open_status_filter.get_locations()
    search_fields = ['name', ]
    if 'q' in request.GET:
        locations = get_filterset(locations, request.GET['q'], search_fields)
    request.breadcrumbs(Batch.edit_breadcrumbs(survey=batch.survey))
    open_locations = locations.filter(id__in=batch_location_ids)
    non_response_active_locations = batch.get_non_response_active_locations()
    context = {
        'batch': batch,
        'locations': locations,
        'open_locations': open_locations,
        'open_status_filter': open_status_filter,
        'non_response_active_locations': non_response_active_locations
        }
    return render(request, 'batches/show.html', context)
コード例 #4
0
ファイル: batch.py プロジェクト: lalitnandandiwakar/uSurvey
def show(request, survey_id, batch_id):
    batch = Batch.objects.get(id=batch_id)
    open_status_filter = BatchOpenStatusFilterForm(batch, request.GET)
    batch_location_ids = batch.open_locations.values_list('location_id',
                                                          flat=True)
    locations = open_status_filter.get_locations()
    search_fields = [
        'name',
    ]
    if 'q' in request.GET:
        locations = get_filterset(locations, request.GET['q'], search_fields)
    request.breadcrumbs(Batch.edit_breadcrumbs(survey=batch.survey))
    open_locations = locations.filter(id__in=batch_location_ids)
    non_response_active_locations = batch.get_non_response_active_locations()
    context = {
        'batch': batch,
        'locations': locations,
        'open_locations': open_locations,
        'open_status_filter': open_status_filter,
        'non_response_active_locations': non_response_active_locations
    }
    return render(request, 'batches/show.html', context)