Ejemplo n.º 1
0
 def get_context_data(self, **kwargs):
     context = super(FMUploadView, self).get_context_data(**kwargs)
     context['page_title'] = ' | '.join([T, 'FM Upload'])
     context['download_period'] = get_download_period()
     context['title'] = 'FM Upload'
     links = [(reverse('site_home'), 'Home'), (None, 'FM Output Report')]
     context['breadcrumb_trail'] = breadcrumb_trail(links)
     context['sfmupload_page'] = True
     if self.request.user.is_superuser:
         context['superuser'] = True
     return context
Ejemplo n.º 2
0
 def get_context_data(self, **kwargs):
     context = super(FMUploadView, self).get_context_data(**kwargs)
     context['page_title'] = ' | '.join([T, 'FM Upload'])
     context['download_period'] = get_download_period()
     context['title'] = 'FM Upload'
     links = [(reverse('site_home'), 'Home'), (None, 'FM Output Report')]
     context['breadcrumb_trail'] = breadcrumb_trail(links)
     context['sfmupload_page'] = True
     if self.request.user.is_superuser:
         context['superuser'] = True
     return context
Ejemplo n.º 3
0
 def get_context_data(self, **kwargs):
     context = super(FMOutputsView, self).get_context_data(**kwargs)
     context['page_title'] = ' | '.join([T, 'FM Outputs'])
     context['download_period'] = get_download_period()
     context['title'] = 'FM Outputs'
     links = [(reverse('site_home'), 'Home'), (None, 'FM Outputs')]
     context['breadcrumb_trail'] = breadcrumb_trail(links)
     if self.request.user.is_superuser:
         context['superuser'] = True
     # Context variable to allow mapping of MeasurementType fields.
     mt = [(i.pk, i.unit.lower()) for i in MeasurementType.objects.all()]
     context['measurement_types'] = json.dumps(mt)
     return context
Ejemplo n.º 4
0
 def get_context_data(self, **kwargs):
     context = super(FMOutputsView, self).get_context_data(**kwargs)
     context['page_title'] = ' | '.join([T, 'FM Outputs'])
     context['download_period'] = get_download_period()
     context['title'] = 'FM Outputs'
     links = [(reverse('site_home'), 'Home'), (None, 'FM Outputs')]
     context['breadcrumb_trail'] = breadcrumb_trail(links)
     if self.request.user.is_superuser:
         context['superuser'] = True
     # Context variable to allow mapping of MeasurementType fields.
     mt = [(i.pk, i.unit.lower()) for i in MeasurementType.objects.all()]
     context['measurement_types'] = json.dumps(mt)
     return context
Ejemplo n.º 5
0
    def form_valid(self, form):
        d = form.cleaned_data
        fy = d['financial_year']
        qtr = d['quarter']
        cc = d['cost_centre']
        sfm = SFMMetric.objects.filter(financialYear=fy).order_by('servicePriorityNo', 'metricID')
        # Ordered list of service priority numbers.
        spn = sorted(set(sfm.values_list('servicePriorityNo', flat=True)))
        # Current download period.
        dp = datetime.strftime(get_download_period(), '%d/%m/%Y')
        fpath = os.path.join(
            settings.STATIC_ROOT, 'excel', 'fm_outputs.xlsx')
        book = load_workbook(fpath)

        # Style & populate the worksheet.
        outputs_report(book, sfm, spn, dp, fy, qtr, cc)
        response = HttpResponse(
            content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
        response['Content-Disposition'] = 'attachment; filename=fm_outputs.xlsx'
        book.save(response)  # Save the worksheet contents to the response.
        return response
Ejemplo n.º 6
0
    def form_valid(self, form):
        d = form.cleaned_data
        fy = d['financial_year']
        qtr = d['quarter']
        cc = d['cost_centre']
        sfm = SFMMetric.objects.filter(financialYear=fy).order_by(
            'servicePriorityNo', 'metricID')
        # Ordered list of service priority numbers.
        spn = sorted(set(sfm.values_list('servicePriorityNo', flat=True)))
        # Current download period.
        dp = datetime.strftime(get_download_period(), '%d/%m/%Y')
        fpath = os.path.join(settings.STATIC_ROOT, 'excel', 'fm_outputs.xlsx')
        book = load_workbook(fpath)

        # Style & populate the worksheet.
        outputs_report(book, sfm, spn, dp, fy, qtr, cc)
        response = HttpResponse(
            content_type=
            'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
        )
        response[
            'Content-Disposition'] = 'attachment; filename=fm_outputs.xlsx'
        book.save(response)  # Save the worksheet contents to the response.
        return response
Ejemplo n.º 7
0
 def get_context_data(self, **kwargs):
     context = super(IbmsFormView, self).get_context_data(**kwargs)
     context['download_period'] = get_download_period()
     if self.request.user.is_superuser:
         context['superuser'] = True
     return context
Ejemplo n.º 8
0
 def get_context_data(self, **kwargs):
     context = super(IbmsFormView, self).get_context_data(**kwargs)
     context['download_period'] = get_download_period()
     if self.request.user.is_superuser:
         context['superuser'] = True
     return context