Last active
January 28, 2020 15:27
-
-
Save netpastor/d30679ba82729c12c64534031dc94b02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'reportName': report['reportName'], | |
'reportPolicy': report['policy__name'], | |
'submittedDate': report['submitted'], | |
'approvedDate': report['approved'], | |
'exportOperationId': report['export_operation_id'], | |
'exportOperationStatus': report['export_operation_status'] | |
} | |
def paginate(self, reports): | |
limit = self.request.GET.get('limit') | |
offset = self.request.GET.get('offset') | |
if limit and offset: | |
reports = reports[int(offset): int(offset) + int(limit)] | |
return reports | |
class ReportForm(forms.ModelForm): | |
class Meta: | |
model = Report | |
fields = '__all__' | |
class ReportDetailView(ExpensifyXeroMixin, DetailView): | |
template_name = 'expensify_xero/report_detail.html' | |
queryset = Report.objects.for_xero() | |
slug_url_kwarg = 'reportID' | |
slug_field = 'reportID' | |
def get_context_data(self, **kwargs): | |
context = super().get_context_data(**kwargs) | |
context['form'] = ReportForm(instance=self.object) | |
return context | |
class ExportOperationForm(forms.ModelForm): | |
class Meta: | |
model = ExportXeroInvoiceOperation | |
fields = '__all__' | |
class ExportOperationDetailView(ExpensifyXeroMixin, DetailView): | |
template_name = 'expensify_xero/export_operation_detail.html' | |
model = ExportXeroInvoiceOperation | |
def get_context_data(self, **kwargs): | |
context = super().get_context_data(**kwargs) | |
context['form'] = ExportOperationForm(instance=self.object) | |
return context | |
@method_decorator(csrf_exempt, name='dispatch') | |
class ExportToXeroByIdsView(ExpensifyXeroMixin, View): | |
def post(self, request): | |
reportIDs = request.POST.getlist('reportIDs[]') | |
if request.POST.get('demo'): | |
task = export_invoices_by_ids_to_xero_demo.delay(reportIDs=reportIDs) | |
else: | |
task = export_invoices_by_ids_to_xero.delay(reportIDs=reportIDs) | |
return JsonResponse({'task_id': task.id}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment