示例#1
0
    def get(self, request, *args, **kwargs):
        return_type = get_object_or_404(ReturnType, pk=args[0])
        filename = 'Return_{}_template.xlsx'.format(return_type.licence_type.code)

        wb = create_return_template_workbook(return_type)

        return excel.WorkbookResponse(wb, filename)
示例#2
0
文件: views.py 项目: wilsonc86/ledger
    def get(self, request, *args, **kwargs):
        form = ReportForm(request.GET)

        if form.is_valid():
            from_date = form.cleaned_data.get('from_date')
            to_date = form.cleaned_data.get('to_date')
            statuses = ['submitted', 'accepted', 'declined']
            qs = Return.objects.filter(lodgement_date__range=(from_date, to_date)).filter(status__in=statuses)
            wb = ReportHelper.to_workbook('Returns', self.ALL_HEADERS, self.row_generator(qs))
            filename = 'returns_{}-{}.xlsx'.format(from_date, to_date)
            return excel.WorkbookResponse(wb, filename)
        else:
            messages.error(request, form.errors)
            redirect('wl_reports:reports')
示例#3
0
文件: views.py 项目: wilsonc86/ledger
    def get(self, request, *args, **kwargs):
        form = ReportForm(request.GET)

        if form.is_valid():
            from_date = form.cleaned_data.get('from_date')
            to_date = form.cleaned_data.get('to_date')
            qs = Application.objects.filter(lodgement_date__range=(from_date, to_date)).exclude(
                processing_status='draft')
            wb = ReportHelper.to_workbook('Applications', self.ALL_HEADERS, self.row_generator(qs))
            filename = 'applications_{}-{}.xlsx'.format(from_date, to_date)
            return excel.WorkbookResponse(wb, filename)
        else:
            messages.error(request, form.errors)
            redirect('wl_reports:reports')
示例#4
0
文件: views.py 项目: wilsonc86/ledger
    def get(self, request, *args, **kwargs):
        form = ReportForm(request.GET)

        if form.is_valid():
            from_date = form.cleaned_data.get('from_date')
            to_date = form.cleaned_data.get('to_date')
            qs = WildlifeLicence.objects.filter(issue_date__range=(from_date, to_date))
            regions = form.cleaned_data.get('regions')
            if regions:
                qs = qs.filter(regions__in=regions)
            wb = ReportHelper.to_workbook('Licences', self.ALL_HEADERS, self.row_generator(qs))
            filename = 'licences_{}-{}.xlsx'.format(from_date, to_date)
            return excel.WorkbookResponse(wb, filename)
        else:
            messages.error(request, form.errors)
            redirect('wl_reports:reports')