def load_from_web(self, txt, value): tmp = txt.split('_') tmp2 = tmp[3].split('.') this_date = load_date(tmp2[2], fmt='%d.%m.%Y') registry = int(tmp[2]) qry = Query(self) qry.get(date=this_date, registry=registry, result_type=T_DICT) if len(qry) > 0: self.load_data(qry[0]) try: self.date = this_date self.registry = registry self.has_meal = value == 'Y' except BadRequestKeyError as ke: abort(403)
def update_data(self, rid=None): report = Report() report.load(replace_when_none(rid, self.widget)) connection = report.report_connection() rset = connection.query_with_columns(report.script) Query(self).get(widget=report.id).delete_all() if rset[1]: data = [] for row in rset[1]: data.append(dict(zip(rset[0], all_as_str(row)))) self.widget = report.id self.data = json.dumps(data) self.rows_count = len(data) self.last_update = datetime.now() self.save()
def last_update(self): qry = Query(WidgetsData) qry.get(widget=self.id) if len(qry) > 0: return qry[0].last_update
def rows_count(self): qry = Query(WidgetsData) qry.get(widget=self.id) if len(qry) > 0: return qry[0].rows_count
def parameters(self): qry = Query(ReportParameter) return qry.get(report=self.id)