Example #1
0
    def report(self, request=None):
        if self.cleaned_data['has_department_info'] == u'has_department_info':
            has_department_info = True
        else:
            has_department_info = False

        if self.cleaned_data['has_pregnant_info'] == u'has_pregnant_info':
            has_pregnant_info = True
        else:
            has_pregnant_info = False
        if self.cleaned_data['has_special_info'] == u'has_special_info':
            has_special_info = True
        else:
            has_special_info = False

        if self.cleaned_data['has_check'] == u'has_check':
            has_check = True
        else:
            has_check = False

        if self.cleaned_data['has_not'] == u'has_not':
            has_not = True
        else:
            has_not = False

        query_set = ServiceArea.objects.filter(is_active=True).order_by('id')
        return download.down_zipfile(request, check_project_report(query_set, request, has_department_info, has_pregnant_info, has_special_info, has_check, has_not, self.cleaned_data['check_project']))
Example #2
0
def check_object_list(request, template_name='my.html', next='/', check_object_page='1',):
    """
    检查对象查询视图
    """
    page_title = u'查询检查对象'
    if request.method == 'POST':

        post_data = request.POST.copy()
        submit_value = post_data.get(u'submit', False)
        if submit_value == u'查询':
            check_object_search_form = CheckObjectSearchForm(post_data)
            if check_object_search_form.is_valid():
                check_object_search_form.data_to_session(request)
                check_object_search_form.init_from_session(request)
                query_set = check_object_search_form.search()
                results_page = pagination_results(check_object_page, query_set, settings.CHECK_OBJECT_PER_PAGE)
            else:
                results_page = None
            return render_to_response(template_name,
                                      {'search_form': check_object_search_form,
                                       'page_title': page_title,
                                       'results_page': results_page,
                                       },
                                      context_instance=RequestContext(request))
        else:
            if submit_value == u'打印检查对象报表':
                check_object_search_form = CheckObjectSearchForm(post_data)
                if check_object_search_form.is_valid():
                    check_object_search_form.data_to_session(request)
                    check_object_search_form.init_from_session(request)
                    query_set = check_object_search_form.search()
                    return download.down_zipfile(request, check_object_report(query_set, request))
                else:
                    results_page = None
                    return render_to_response(template_name,
                                              {'search_form': check_object_search_form,
                                               'page_title': page_title,
                                               'results_page': results_page,
                                               },
                                              context_instance=RequestContext(request))
            else:
                raise Http404('Invalid Request!')
    else:
        check_object_search_form = CheckObjectSearchForm(CheckObjectSearchForm().data_from_session(request))
        check_object_search_form.init_from_session(request)
        if check_object_search_form.is_valid():
            query_set = check_object_search_form.search()
            results_page = pagination_results(check_object_page, query_set, settings.CHECK_OBJECT_PER_PAGE)
        else:
            results_page = None
        return render_to_response(template_name,
                                  {'search_form': check_object_search_form,
                                   'page_title': page_title,
                                   'results_page': results_page,
                                   },
                                  context_instance=RequestContext(request))
Example #3
0
 def has_total_report(self, request=None):
     if self.service_area_department_object is None:
         query_set = ServiceArea.objects.filter(name=self.cleaned_data['service_area_name'], is_active=True)
         return download.down_zipfile(request, check_object_service_area_report(query_set, request, self.cleaned_data['check_project']))
     else:
         return download.down_zipfile(request, check_object_service_area_department_report([self.service_area_department_object], request, self.cleaned_data['check_project']))
Example #4
0
def check_result_list(request, template_name='my.html', next='/', check_result_page='1',):
    """
    检查结果查询视图
    """
    page_title = u'查询检查结果'

    if request.method == 'POST':
        post_data = request.POST.copy()
        submit_value = post_data.get(u'submit', False)
        if submit_value == u'查询':
            check_result_search_form = CheckResultSearchForm(post_data)
            check_result_search_form.init_check_project()
            if check_result_search_form.is_valid():
                check_result_search_form.data_to_session(request)
                check_result_search_form.init_from_session(request)
                query_set = check_result_search_form.search()
                results_page = pagination_results(check_result_page, query_set, settings.CHECK_RESULT_PER_PAGE)
            else:
                results_page = None
            return render_to_response(template_name,
                                      {'search_form': check_result_search_form,
                                       'page_title': page_title,
                                       'results_page': results_page,
                                       },
                                      context_instance=RequestContext(request))
        else:
            if submit_value == u'打印检查结果报表':
                check_result_search_form = CheckResultSearchForm(post_data)
                check_result_search_form.init_check_project()
                if check_result_search_form.is_valid():
                    check_result_search_form.data_to_session(request)
                    check_result_search_form.init_from_session(request)
                    query_set = check_result_search_form.search()
                    filename = check_result_report(query_set, request)
                    #filename = '/home/bright/nanopb-0.3.1-linux-x86.tar.gz'
                    #print __file__
                    #wrapper = FileWrapper(file(filename))
                    #response = HttpResponse(wrapper, content_type='text/plain')
                    #response['Content-Length'] = os.path.getsize(filename)
                    #
                    return download.down_zipfile(request, filename)
                else:
                    results_page = None
                    return render_to_response(template_name,
                                              {'search_form': check_result_search_form,
                                               'page_title': page_title,
                                               'results_page': results_page,
                                               },
                                              context_instance=RequestContext(request))
    else:
        check_result_search_form = CheckResultSearchForm(CheckResultSearchForm().data_from_session(request))
        check_result_search_form.init_check_project()
        check_result_search_form.init_from_session(request)
        if check_result_search_form.is_valid():
            query_set = check_result_search_form.search()
            results_page = pagination_results(check_result_page, query_set, settings.CHECK_RESULT_PER_PAGE)
        else:
            results_page = None
        return render_to_response(template_name,
                                  {'search_form': check_result_search_form,
                                   'page_title': page_title,
                                   'results_page': results_page,
                                   },
                                  context_instance=RequestContext(request))