def index(request): groups = RespondentGroup.objects.all() search_fields = ['name', 'description'] if 'q' in request.GET: groups = get_filterset(groups, request.GET['q'], search_fields) return render(request, 'respondent_groups/index.html', {'groups': groups, 'request': request})
def index(request, qset_id): # now I'm gonna call question set a batch of questions.\ #If there's time, I'll rename them properly # So don't get confused :) try: batch = QuestionSet.get(pk=qset_id) except QuestionSet.DoesNotExist: raise Http404("No QuestionSet Model matches the given query.") questions = batch.questions_inline() request_data = request.GET if request.method == 'GET' else request.POST question_filter_form = QuestionFilterForm(data=request_data, qset=batch) search_fields = ['identifier', 'text', ] qset_questions = batch.questions.all() if 'q' in request_data: questions = get_filterset(qset_questions, request_data['q'], search_fields) if 'question_types' in request_data: relevant_ids = list(question_filter_form.filter( qset_questions).values_list('id', flat=True)) questions = [q for q in questions if q.id in relevant_ids] # now maintain same inline other exclusing questions in breadcrumbs = Question.index_breadcrumbs(qset=batch) if breadcrumbs: request.breadcrumbs(breadcrumbs) context = {'questions': questions, 'request': request, 'batch': batch, 'question_filter_form': question_filter_form, 'placeholder': 'identifier, text', 'template_file': 'interviews/answer.html', 'is_preview': True # caution atleast on ODK access # at least on access must exist } return render(request, 'set_questions/index.html', context)
def index(request, batch_id): batch = get_object_or_404(Batch, pk=batch_id) questions = batch.questions_inline() max_per_page = None if request.method == 'GET': question_filter_form = QuestionFilterForm(data=request.GET, batch=batch) batch_questions = batch.batch_questions.all() search_fields = ['identifier', 'group__name', 'text', ] if request.GET.has_key('q'): questions = get_filterset(batch_questions, request.GET['q'], search_fields) relevant_questions = question_filter_form.filter(batch_questions) questions = [q for q in questions if q in relevant_questions] #now maintain same inline other exclusing questions in max_per_page = _max_number_of_question_per_page(request.GET.get('number_of_questions_per_page', 0)) else: question_filter_form = QuestionFilterForm(batch=batch) #question_library = question_filter_form.filter(QuestionTemplate.objects.all()) question_form = QuestionForm(batch) request.breadcrumbs([ ('Surveys', reverse('survey_list_page')), (batch.survey.name, reverse('batch_index_page', args=(batch.survey.pk, ))), ]) context = {'questions': questions, 'request': request, 'batch': batch, 'max_question_per_page':max_per_page, 'question_filter_form': question_filter_form, 'placeholder': 'identifier, group name, text', } return render(request, 'questions/index.html', context)
def _view_qset_data(request, model_class, interviews, title, disabled_fields=[]): params = request.GET if request.method == 'GET' else request.POST survey_filter = SurveyResultsFilterForm(model_class, disabled_fields=disabled_fields, data=params) locations_filter = LocationsFilterForm(data=request.GET, include_ea=True) selected_qset = None survey = None items_per_page = int(params.get('max_display_per_page', 50)) try: page_index = int(params.get('page', 1)) - 1 except BaseException: page_index = 0 if survey_filter.is_valid(): interviews = survey_filter.get_interviews(interviews=interviews) selected_qset = survey_filter.cleaned_data['question_set'] survey = survey_filter.cleaned_data['survey'] if locations_filter.is_valid(): interviews = interviews.filter( ea__in=locations_filter.get_enumerations()) search_fields = [ 'ea__name', 'survey__name', 'question_set__name', 'answer__as_text', ] if 'q' in request.GET: interviews = get_filterset(interviews, request.GET['q'], search_fields) context = { 'survey_filter': survey_filter, 'interviews': interviews, 'locations_filter': locations_filter, 'location_filter_types': LocationType.in_between(), 'placeholder': 'Response, EA, Survey, %s' % model_class.verbose_name(), 'selected_qset': selected_qset, 'model_class': model_class, 'items_per_page': items_per_page, 'max_display_per_page': items_per_page, 'title': title } if selected_qset and survey: # page_start = page_index * items_per_page # interviews = interviews[page_start: page_start + items_per_page]() download_service = ResultsDownloadService( selected_qset, survey=survey, interviews=interviews, page_index=page_index, items_per_page=items_per_page) df = download_service.get_interview_answers() context['report'] = mark_safe( df.to_html(classes='table table-striped\ dataTable table-bordered table-hover table-sort', max_rows=items_per_page)) return render(request, 'question_set/view_all_data.html', context)
def index(request): all_question_modules = QuestionModule.objects.all() search_fields = ['name', 'description'] if 'q' in request.GET: all_question_modules = get_filterset( all_question_modules, request.GET['q'], search_fields) context = {'question_modules': all_question_modules} return render(request, "question_module/index.html", context)
def index(request): all_question_modules = QuestionModule.objects.all() search_fields = ['name', 'description'] if 'q' in request.GET: all_question_modules = get_filterset(all_question_modules, request.GET['q'], search_fields) context = {'question_modules': all_question_modules} return render(request, "question_module/index.html", context)
def index(request): groups = RespondentGroup.objects.all() search_fields = ['name', 'description'] if 'q' in request.GET: groups = get_filterset(groups, request.GET['q'], search_fields) return render(request, 'respondent_groups/index.html', { 'groups': groups, 'request': request })
def filter(request): question_lib = QuestionTemplate.objects.all() search_fields = ['identifier', 'text', ] if request.GET.has_key('q'): question_lib = get_filterset(question_lib, request.GET['q'], search_fields) question_filter_form = QuestionFilterForm(data=request.GET) questions = question_filter_form.filter(question_lib).values('id', 'text', 'answer_type', 'group', 'module').order_by('text') json_dump = json.dumps(list(questions), cls=DjangoJSONEncoder) return HttpResponse(json_dump, mimetype='application/json')
def household_filter(request): locations_filter = LocationsFilterForm(request.GET, include_ea=True) enumeration_areas = locations_filter.get_enumerations() all_households = Household.objects.filter(ea__in=enumeration_areas).order_by('household_member__householdhead__surname') search_fields = ['house_number', 'listing__ea__name', 'last_registrar__name', 'listing__initial_survey__name', ] if request.GET.has_key('q'): all_households = get_filterset(all_households, request.GET['q'], search_fields) all_households = all_households.values('id', 'house_number', ).order_by('name') json_dump = json.dumps(list(all_households), cls=DjangoJSONEncoder) return HttpResponse(json_dump, mimetype='application/json')
def submission_list(request): odk_submissions = ODKSubmission.objects.all().order_by('-created') search_fields = ['interviewer__name', 'interviewer__ea__name', 'survey__name', 'household_member__household__house_number', 'household_member__surname', 'household_member__first_name', 'form_id', 'instance_id'] if request.GET.has_key('q'): odk_submissions = get_filterset(odk_submissions, request.GET['q'], search_fields) return render(request, 'odk/submission_list.html', { 'submissions' : odk_submissions, 'placeholder': 'interviewer, house, member, survey', 'request': request})
def _view_qset_data(request, model_class, interviews,title, disabled_fields=[]): params = request.GET if request.method == 'GET' else request.POST survey_filter = SurveyResultsFilterForm( model_class, disabled_fields=disabled_fields, data=params) locations_filter = LocationsFilterForm(data=request.GET, include_ea=True) selected_qset = None survey = None items_per_page = int(params.get('max_display_per_page', 50)) try: page_index = int(params.get('page', 1)) - 1 except BaseException: page_index = 0 if survey_filter.is_valid(): interviews = survey_filter.get_interviews(interviews=interviews) selected_qset = survey_filter.cleaned_data['question_set'] survey = survey_filter.cleaned_data['survey'] if locations_filter.is_valid(): interviews = interviews.filter(ea__in=locations_filter.get_enumerations()) search_fields = [ 'ea__name', 'survey__name', 'question_set__name', 'answer__as_text', ] if 'q' in request.GET: interviews = get_filterset(interviews, request.GET['q'], search_fields) context = { 'survey_filter': survey_filter, 'interviews': interviews, 'locations_filter': locations_filter, 'location_filter_types': LocationType.in_between(), 'placeholder': 'Response, EA, Survey, %s' % model_class.verbose_name(), 'selected_qset': selected_qset, 'model_class': model_class, 'items_per_page': items_per_page, 'max_display_per_page': items_per_page, 'title':title} if selected_qset and survey: # page_start = page_index * items_per_page # interviews = interviews[page_start: page_start + items_per_page]() download_service = ResultsDownloadService( selected_qset, survey=survey, interviews=interviews, page_index=page_index, items_per_page=items_per_page) df = download_service.get_interview_answers() context['report'] = mark_safe( df.to_html( classes='table table-striped\ dataTable table-bordered table-hover table-sort', max_rows=items_per_page)) return render(request, 'question_set/view_all_data.html', context)
def index(request): ''' show all library questions ''' question_filter_form = QuestionFilterForm(data=request.GET or None) questions = question_filter_form.filter(QuestionTemplate.objects.all()) search_fields = ['identifier', 'group__name', 'text', ] if request.GET.has_key('q'): questions = get_filterset(questions, request.GET['q'], search_fields) context = {'questions': questions, 'request': request, 'placeholder': 'identifier, group name, text', 'question_filter_form' : question_filter_form} return render(request, 'question_templates/index.html', context)
def index(request): locations_filter = LocationsFilterForm(data=request.GET) enumeration_areas = locations_filter.get_enumerations() search_fields = ['name', 'locations__name', ] if request.GET.has_key('q'): enumeration_areas = get_filterset(enumeration_areas, request.GET['q'], search_fields) loc_types = LocationType.in_between() context = {'enumeration_areas': enumeration_areas, 'locations_filter' : locations_filter, 'location_filter_types' : loc_types, 'placeholder': 'name, location name', 'max_display_per_page': settings.MAX_DISPLAY_PER_PAGE} return render(request, "enumeration_area/index.html", context)
def listing_entries(request, qset_id): listing_qset = get_object_or_404(ListingTemplate, pk=qset_id) surveys = listing_qset.survey_settings.all() request.breadcrumbs(listing_qset.edit_breadcrumbs(qset=listing_qset)) search_fields = ['name', ] if 'q' in request.GET: surveys = get_filterset(surveys, request.GET['q'], search_fields) context = { 'question_set': listing_qset, 'surveys': surveys, 'placeholder': 'name,', } return render(request, 'question_set/listing_entries.html', context)
def index(request): locations_filter = LocationsFilterForm(data=request.GET) enumeration_areas = locations_filter.get_enumerations() search_fields = ['name', 'locations__name', ] if 'q' in request.GET: enumeration_areas = get_filterset( enumeration_areas, request.GET['q'], search_fields) loc_types = LocationType.in_between() context = {'enumeration_areas': enumeration_areas, 'locations_filter': locations_filter, 'location_filter_types': loc_types, 'placeholder': 'name, location name'} return render(request, "enumeration_area/index.html", context)
def index(request): surveys = Survey.objects.all().order_by('created') search_fields = ['name', 'description'] if 'q' in request.GET: surveys = get_filterset(surveys, request.GET['q'], search_fields) if 'type' in request.GET: surveys = surveys.filter(type=ast.literal_eval(request.GET['type'])) if 'isopen' in request.GET: surveys = surveys.filter(type=ast.literal_eval(request.GET['isopen'])) context = {'surveys': surveys.order_by('-created'), 'request': request, 'placeholder': 'name, description', 'survey_form': SurveyForm(), 'batch_model': Batch} return render(request, 'surveys/index.html', context)
def list_households(request): locations_filter = LocationsFilterForm(data=request.GET, include_ea=True) enumeration_areas = locations_filter.get_enumerations() households = Household.objects.filter(listing__ea__in=enumeration_areas).order_by('house_number') search_fields = ['house_number', 'listing__ea__name', 'last_registrar__name', 'listing__initial_survey__name', ] if request.GET.has_key('q'): households = get_filterset(households, request.GET['q'], search_fields) return render(request, 'households/index.html', {'households': households, 'locations_filter' : locations_filter, 'location_filter_types' : LocationType.in_between(), 'Largest Unit' : LocationType.largest_unit(), 'placeholder': 'house no, ea, survey, interviewer', 'request': request})
def filter(request): question_lib = QuestionTemplate.objects.all() search_fields = [ 'identifier', 'text', ] if 'q' in request.GET: question_lib = get_filterset(question_lib, request.GET['q'], search_fields) question_filter_form = QuestionFilterForm(data=request.GET) questions = question_filter_form.filter(question_lib).values( 'id', 'text', 'answer_type', 'module').order_by('text') json_dump = json.dumps(list(questions), cls=DjangoJSONEncoder) return HttpResponse(json_dump, content_type='application/json')
def listing_entries(request, qset_id): listing_qset = get_object_or_404(ListingTemplate, pk=qset_id) surveys = listing_qset.survey_settings.all() request.breadcrumbs(listing_qset.edit_breadcrumbs(qset=listing_qset)) search_fields = [ 'name', ] if 'q' in request.GET: surveys = get_filterset(surveys, request.GET['q'], search_fields) context = { 'question_set': listing_qset, 'surveys': surveys, 'placeholder': 'name,', } return render(request, 'question_set/listing_entries.html', context)
def test_question_filters(self): search_fields = ['identifier', 'text', ] list_1 = ListingTemplate.objects.create(name="ListA3") batch = QuestionSet.get(pk=list_1.id) q1 = Question.objects.create(identifier='123.1', text="This is a question123.1", answer_type='Numerical Answer', qset_id=list_1.id, response_validation_id=self.rsp.id) response = self.client.get(reverse('qset_questions_page', kwargs={'qset_id':list_1.id})) q = 'q2' qset_questions = batch.questions.all() filter_result = get_filterset(qset_questions, q, search_fields) response = self.client.get("%s?q=ListA3"%(reverse('qset_questions_page', kwargs={'qset_id':list_1.id}))) self.assertEqual(200, response.status_code) response = self.client.get("%s?q=ListA3&question_types=Numerical Answer"%(reverse('qset_questions_page', kwargs={'qset_id':list_1.id}))) self.assertEqual(200, response.status_code)
def submission_list(request): odk_submissions = ODKSubmission.objects.all().order_by('-created') search_fields = [ 'interviewer__name', 'interviewer__ea__name', 'survey__name', 'form_id', 'instance_id' ] if 'q' in request.GET: odk_submissions = get_filterset(odk_submissions, request.GET['q'], search_fields) return render( request, 'odk/submission_list.html', { 'submissions': odk_submissions, 'placeholder': 'interviewer, house, member, survey', 'request': request })
def index(request): surveys = Survey.objects.all().order_by('created') search_fields = ['name', 'description'] if request.GET.has_key('q'): surveys = get_filterset(surveys, request.GET['q'], search_fields) if request.GET.has_key('type'): surveys = surveys.filter(type=ast.literal_eval(request.GET['type'])) if request.GET.has_key('isopen'): surveys = surveys.filter(type=ast.literal_eval(request.GET['isopen'])) context = { 'surveys': surveys, 'request': request, 'placeholder': 'name, description', 'survey_form': SurveyForm() } return render(request, 'surveys/index.html', context)
def index(request): if request.GET.has_key("mobile_number"): return check_mobile_number(request.GET["mobile_number"]) if request.GET.has_key("username"): return check_user_attribute(username=request.GET["username"]) if request.GET.has_key("email"): return check_user_attribute(email=request.GET["email"]) userlist = User.objects.exclude(is_superuser=True).order_by("first_name") search_fields = ["first_name", "last_name", "groups__name"] if request.GET.has_key("q"): userlist = get_filterset(userlist, request.GET["q"], search_fields) if request.GET.has_key("status"): userlist = userlist.filter(is_active=(True if request.GET["status"].lower() == "active" else False)) return render(request, "users/index.html", {"users": userlist, "request": request})
def show_interviewer_completion_summary(request): params = request.GET selected_location = None selected_ea = None interviewers = Interviewer.objects.order_by('id') search_fields = ['name', 'ea__name'] if request.GET.has_key('q'): interviewers = get_filterset(interviewers, request.GET['q'], search_fields) if params.has_key('status'): interviewers = interviewers.intervieweraccess.filter(is_active=ast.literal_eval(params['status'])) locations_filter = LocFilterForm(data=request.GET, include_ea=True) if locations_filter.is_valid(): print 'locations count: ', locations_filter.get_enumerations().count() interviewers = interviewers.filter(ea__in=locations_filter.get_enumerations()).order_by('name') return render(request, 'aggregates/interviewers_summary.html', {'interviewers': interviewers, 'locations_filter' : locations_filter, 'request': request})
def index(request): locations_filter = LocationsFilterForm(data=request.GET) enumeration_areas = locations_filter.get_enumerations() search_fields = [ 'name', 'locations__name', ] if 'q' in request.GET: enumeration_areas = get_filterset(enumeration_areas, request.GET['q'], search_fields) loc_types = LocationType.in_between() context = { 'enumeration_areas': enumeration_areas, 'locations_filter': locations_filter, 'location_filter_types': loc_types, 'placeholder': 'name, location name' } return render(request, "enumeration_area/index.html", context)
def index(request): users_filter_form = UsersFilterForm(request.GET) userlist = users_filter_form.get_users() if 'mobile_number' in request.GET: return check_mobile_number(request.GET['mobile_number']) if 'username' in request.GET: return check_user_attribute(username=request.GET['username']) if 'email' in request.GET: return check_user_attribute(email=request.GET['email']) search_fields = ['first_name', 'last_name', 'groups__name'] if 'q' in request.GET: userlist = get_filterset(userlist, request.GET['q'], search_fields) return render( request, 'users/index.html', { 'users': userlist, 'request': request, 'users_filter_form': users_filter_form })
def index(request): users_filter_form = UsersFilterForm(request.GET) userlist = users_filter_form.get_users() if 'mobile_number' in request.GET: return check_mobile_number(request.GET['mobile_number']) if 'username' in request.GET: return check_user_attribute( username=request.GET['username']) if 'email' in request.GET: return check_user_attribute(email=request.GET['email']) search_fields = ['first_name', 'last_name', 'groups__name'] if 'q' in request.GET: userlist = get_filterset(userlist, request.GET['q'], search_fields) return render(request, 'users/index.html', {'users': userlist, 'request': request, 'users_filter_form': users_filter_form})
def list_interviewers(request): params = request.GET locations_filter = LocationsFilterForm(data=request.GET, include_ea=True) if locations_filter.is_valid(): interviewers = Interviewer.objects.filter(ea__in=locations_filter.get_enumerations()).order_by('name') else: interviewers = Interviewer.objects.all() search_fields = ['name', 'intervieweraccess__user_identifier'] if request.GET.has_key('q'): interviewers = get_filterset(interviewers, request.GET['q'], search_fields) if params.has_key('status'): interviewers = interviewers.filter(is_blocked=ast.literal_eval(params['status'])) loc_types = LocationType.in_between() return render(request, 'interviewers/index.html', {'interviewers': interviewers, 'locations_filter' : locations_filter, 'location_filter_types' : loc_types, 'placeholder': 'name, mobile numbers, odk id', 'request': request})
def index(request): ''' show all library questions ''' question_filter_form = QuestionFilterForm(data=request.GET or None) questions = question_filter_form.filter(QuestionTemplate.objects.all()) search_fields = [ 'identifier', 'group__name', 'text', ] if request.GET.has_key('q'): questions = get_filterset(questions, request.GET['q'], search_fields) context = { 'questions': questions, 'request': request, 'placeholder': 'identifier, group name, text', 'question_filter_form': question_filter_form } return render(request, 'question_templates/index.html', context)
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)
def index(request): if request.GET.has_key('mobile_number'): return check_mobile_number(request.GET['mobile_number']) if request.GET.has_key('username'): return check_user_attribute( username=request.GET['username']) if request.GET.has_key('email'): return check_user_attribute(email=request.GET['email']) userlist = User.objects.all() search_fields = ['first_name', 'last_name', 'groups__name'] if request.GET.has_key('q'): userlist = get_filterset(userlist, request.GET['q'], search_fields) if request.GET.has_key('status'): userlist = userlist.filter(is_active=(True if request.GET['status'].lower() == 'active' else False)) return render(request, 'users/index.html', { 'users' : userlist, 'request': request})
def index(self, request, qsets, extra_context={}, template_name='question_set/index.html', **form_extra): search_fields = ['name', 'description'] if 'q' in request.GET: qsets = get_filterset(qsets, request.GET['q'], search_fields) context = { 'question_sets': qsets.order_by('-created'), 'request': request, 'model': self.model, 'placeholder': 'name, description', 'model_name': self.model.__name__, 'question_set_form': self.questionSetForm(**form_extra) } context.update(extra_context) return render(request, template_name, context)
def index(request, model_class=QuestionTemplate): ''' show all library questions ''' question_filter_form = QuestionFilterForm(data=request.GET or None) questions = question_filter_form.filter(model_class.objects.all()) search_fields = ['identifier', 'text', ] if 'q' in request.GET: questions = get_filterset(questions, request.GET['q'], search_fields) context = { 'questions': questions, 'request': request, 'placeholder': 'identifier, text', 'question_filter_form': question_filter_form, 'model_class': model_class} if model_class == ParameterTemplate: request.breadcrumbs([ ('Groups', reverse('respondent_groups_page')), ]) return render(request, 'question_templates/index.html', context)
def household_filter(request): locations_filter = LocationsFilterForm(request.GET, include_ea=True) enumeration_areas = locations_filter.get_enumerations() all_households = Household.objects.filter( ea__in=enumeration_areas).order_by( 'household_member__householdhead__surname') search_fields = [ 'house_number', 'listing__ea__name', 'last_registrar__name', 'listing__initial_survey__name', ] if request.GET.has_key('q'): all_households = get_filterset(all_households, request.GET['q'], search_fields) all_households = all_households.values( 'id', 'house_number', ).order_by('name') json_dump = json.dumps(list(all_households), cls=DjangoJSONEncoder) return HttpResponse(json_dump, content_type='application/json')
def index(request): if request.GET.has_key('mobile_number'): return check_mobile_number(request.GET['mobile_number']) if request.GET.has_key('username'): return check_user_attribute(username=request.GET['username']) if request.GET.has_key('email'): return check_user_attribute(email=request.GET['email']) userlist = User.objects.exclude(is_superuser=True).order_by('first_name') search_fields = ['first_name', 'last_name', 'groups__name'] if request.GET.has_key('q'): userlist = get_filterset(userlist, request.GET['q'], search_fields) if request.GET.has_key('status'): userlist = userlist.filter(is_active=( True if request.GET['status'].lower() == 'active' else False)) return render(request, 'users/index.html', { 'users': userlist, 'request': request })
def index(request, qset_id): # now I'm gonna call question set a batch of questions.\ #If there's time, I'll rename them properly # So don't get confused :) try: batch = QuestionSet.get(pk=qset_id) except QuestionSet.DoesNotExist: raise Http404("No QuestionSet Model matches the given query.") questions = batch.questions_inline() request_data = request.GET if request.method == 'GET' else request.POST question_filter_form = QuestionFilterForm(data=request_data, qset=batch) search_fields = [ 'identifier', 'text', ] qset_questions = batch.questions.all() if 'q' in request_data: questions = get_filterset(qset_questions, request_data['q'], search_fields) if 'question_types' in request_data: relevant_ids = list( question_filter_form.filter(qset_questions).values_list('id', flat=True)) questions = [q for q in questions if q.id in relevant_ids] # now maintain same inline other exclusing questions in breadcrumbs = Question.index_breadcrumbs(qset=batch) if breadcrumbs: request.breadcrumbs(breadcrumbs) context = { 'questions': questions, 'request': request, 'batch': batch, 'question_filter_form': question_filter_form, 'placeholder': 'identifier, text', 'template_file': 'interviews/answer.html', 'is_preview': True # caution atleast on ODK access # at least on access must exist } return render(request, 'set_questions/index.html', context)
def list_interviewers(request): params = request.GET locations_filter = LocationsFilterForm(data=request.GET, include_ea=True) if locations_filter.is_valid(): interviewers = Interviewer.objects.filter( ea__in=locations_filter.get_enumerations()) else: interviewers = Interviewer.objects.all() search_fields = ['name', 'intervieweraccess__user_identifier'] if 'q' in request.GET: interviewers = get_filterset( interviewers, request.GET['q'], search_fields) if 'status' in params: interviewers = interviewers.filter( is_blocked=ast.literal_eval(params['status'])) loc_types = LocationType.in_between() return render(request, 'interviewers/index.html', {'interviewers': interviewers.order_by('name'), 'locations_filter': locations_filter, 'location_filter_types': loc_types, 'placeholder': 'name, mobile numbers, odk id', 'request': request})
def list_households(request): locations_filter = LocationsFilterForm(data=request.GET, include_ea=True) enumeration_areas = locations_filter.get_enumerations() households = Household.objects.filter( listing__ea__in=enumeration_areas).order_by('house_number') search_fields = [ 'house_number', 'listing__ea__name', 'last_registrar__name', 'listing__initial_survey__name', ] if request.GET.has_key('q'): households = get_filterset(households, request.GET['q'], search_fields) return render( request, 'households/index.html', { 'households': households, 'locations_filter': locations_filter, 'location_filter_types': LocationType.in_between(), 'Largest Unit': LocationType.largest_unit(), 'placeholder': 'house no, ea, survey, interviewer', 'request': request })
def index( self, request, qsets, extra_context={}, template_name='question_set/index.html', **form_extra): search_fields = ['name', 'description'] if 'q' in request.GET: qsets = get_filterset(qsets, request.GET['q'], search_fields) context = { 'question_sets': qsets.order_by('-created'), 'request': request, 'model': self.model, 'placeholder': 'name, description', 'model_name' : self.model.__name__, 'question_set_form': self.questionSetForm( **form_extra)} context.update(extra_context) return render(request, template_name, context)
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)
def index(request, model_class=QuestionTemplate): """show all library questions""" question_filter_form = QuestionFilterForm(data=request.GET or None) questions = question_filter_form.filter(model_class.objects.all()) search_fields = [ 'identifier', 'text', ] if 'q' in request.GET: questions = get_filterset(questions, request.GET['q'], search_fields) context = { 'questions': questions, 'request': request, 'placeholder': 'identifier, text', 'question_filter_form': question_filter_form, 'model_class': model_class } if model_class == ParameterTemplate: request.breadcrumbs([ ('Groups', reverse('respondent_groups_page')), ]) return render(request, 'question_templates/index.html', context)