def list_all_questions(request): batch_id = request.GET.get('id', None) batch = Batch.get(pk=batch_id) # if request.is_ajax(): json_dump = json.dumps( [{'id': q.id, 'identifier': q.identifier} for q in batch.all_questions], cls=DjangoJSONEncoder) return HttpResponse(json_dump, content_type='application/json')
def update_parameter_list(batch_question): # check if this group has been previously assigned to this Question set. from survey.models import Batch if batch_question.group and RespondentGroup.objects.filter( questions__qset__id=batch_question.qset.id, id=batch_question.group.id).exists(): SurveyParameterList.update_parameter_list( Batch.get(pk=batch_question.qset.pk))
def delete(request, survey_id, batch_id): try: batch = Batch.get(id=batch_id) QuestionSetView(model_class=Batch).delete(request, batch) except Exception as e: messages.warning(request, str(e)) return HttpResponseRedirect( reverse('batch_index_page', args=(batch.survey.id, )))
def list_all_questions(request): batch_id = request.GET.get('id', None) batch = Batch.get(pk=batch_id) # if request.is_ajax(): json_dump = json.dumps([{ 'id': q.id, 'identifier': q.identifier } for q in batch.all_questions], cls=DjangoJSONEncoder) return HttpResponse(json_dump, content_type='application/json')
def delete(request, survey_id, batch_id): try: batch = Batch.get(id=batch_id) QuestionSetView(model_class=Batch).delete(request, batch) except Exception as e: messages.warning(request, str(e)) return HttpResponseRedirect( reverse( 'batch_index_page', args=( batch.survey.id, )))
def list_batch_questions(request): batch_id = request.GET.get('id', None) batch = Batch.get(pk=batch_id) if request.is_ajax(): json_dump = json.dumps([{ 'id': q.id, 'identifier': q.identifier } for q in batch.flow_questions], cls=DjangoJSONEncoder) return HttpResponse(json_dump, content_type='application/json') return HttpResponseRedirect( reverse('batch_index_page', args=(batch.survey.pk, )))
def _get_name_references(qset): name_references = {} for question in qset.questions.all(): name_references[question.identifier] = mark_safe('<output value="%s"/>' % get_node_path(question)) try: qset = Batch.get(pk=qset.pk) if hasattr(qset, 'parameter_list'): for question in qset.parameter_list.questions.all(): name_references[question.identifier] = \ mark_safe('<output value="%s"/>' % get_group_question_path(qset, question)) except Batch.DoesNotExist: pass return name_references
def list_batch_questions(request): batch_id = request.GET.get('id', None) batch = Batch.get(pk=batch_id) if request.is_ajax(): json_dump = json.dumps( [{'id': q.id, 'identifier': q.identifier} for q in batch.flow_questions], cls=DjangoJSONEncoder) return HttpResponse(json_dump, content_type='application/json') return HttpResponseRedirect( reverse( 'batch_index_page', args=( batch.survey.pk, )))
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
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