Ejemplo n.º 1
0
 def get(self, uuid):
     try:
         self.metadata = reports.get_metadata(uuid)
     except DataRequestException as e:
         return render_template(self.template, data_type='report',
                                uuid=uuid, errors=e.errors)
     return super().get()
Ejemplo n.º 2
0
 def set_metadata(self, uuid):
     """Loads all necessary data for loading a
     `solarforecastarbiter.datamodel.Report` with processed forecasts and
     observations.
     """
     metadata = reports.get_metadata(uuid)
     metadata['report_parameters']['object_pairs'] = []
     self.metadata = metadata
Ejemplo n.º 3
0
 def set_template_args(self, uuid):
     self.template_args = {}
     self.template_args['page_title'] = "Add Report Outage"
     try:
         report = reports.get_metadata(uuid)
     except DataRequestException as e:
         self.flash_api_errors(e.errors)
     else:
         self.template_args['metadata'] = report
Ejemplo n.º 4
0
    def get(self, uuid):
        try:
            self.metadata = reports.get_metadata(uuid)
        except DataRequestException as e:
            self.flash_api_errors(e.errors)
            return redirect(url_for('data_dashboard.report_view', uuid=uuid))

        else:
            self.set_report_type()
            self.set_template()
            self.set_template_args()
            return render_template(self.template, **self.template_args)
Ejemplo n.º 5
0
 def set_template_args(self, uuid=None):
     self.template_args = {}
     try:
         report = reports.get_metadata(uuid)
     except DataRequestException as e:
         self.flash_api_errors(e.errors)
     else:
         self.template_args['page_title'] = "Report Outages"
         outages = report['outages']
         system_outages = list(filter(
             lambda x: x['report_id'] is None,
             outages
         ))
         report_outages = list(filter(
             lambda x: x['report_id'] is not None,
             outages
         ))
         self.template_args['system_outages'] = system_outages
         self.template_args['report_outages'] = report_outages
         self.template_args['metadata'] = report
Ejemplo n.º 6
0
 def set_template_args(self, uuid, outage_id):
     self.template_args = {}
     try:
         report = reports.get_metadata(uuid)
     except DataRequestException as e:
         self.flash_api_errors(e.errors)
     else:
         outage = None
         for report_outage in report['outages']:
             if report_outage['outage_id'] == outage_id:
                 outage = report_outage
                 break
         if outage is None:
             self.flash_api_errors({
                 "404": [
                     "The requested object could not be found. "
                     "You may need to request access from the "
                     "data owner."
                 ],
             })
         else:
             self.template_args['metadata'] = report
             self.template_args['outage'] = outage