Esempio n. 1
0
    def get_query(self,*args,**kw):
        kind = args[0]
        lines = None
        if kind=='publication':
            publication_id = args[1]
            publication_id = int(publication_id)
            lines = MRExemptionRecord.query(MRExemptionRecord.publication_id==publication_id)
            self.single = True
        elif kind=='budget':
            budget_code = args[1]
            lines = MRExemptionRecord.query(MRExemptionRecord.prefixes==budget_code)
        elif kind=='updated':
            date_from = datetime.date(int(args[1]),int(args[2]),int(args[3]))
            date_to = datetime.date(int(args[4]),int(args[5]),int(args[6]))
            lines = MRExemptionRecord.query(MRExemptionRecord.last_update_date >= date_from, MRExemptionRecord.last_update_date <= date_to)
        elif kind=='new':
            lines = MRExemptionRecord.query().order(-MRExemptionRecord.last_update_date)

        return lines
Esempio n. 2
0
    def get_query(self,*args,**kw):
        kind = args[0]
        lines = None
        if kind=='publication':
            publication_id = args[1]
            publication_id = int(publication_id)
            lines = MRExemptionRecord.query(MRExemptionRecord.publication_id==publication_id)
            self.single = True
        elif kind=='entity':
            entity_id = args[1]
            lines = MRExemptionRecord.query(MRExemptionRecord.entity_id==entity_id)
            self.single = True
        elif kind=='budget':
            budget_code = args[1]
            lines = MRExemptionRecord.query(MRExemptionRecord.prefixes==budget_code)
        elif kind=='updated':
            date_from = datetime.date(int(args[1]),int(args[2]),int(args[3]))
            date_to = datetime.date(int(args[4]),int(args[5]),int(args[6]))
            lines = MRExemptionRecord.query(MRExemptionRecord.last_update_date >= date_from, MRExemptionRecord.last_update_date <= date_to)
        elif kind=='new':
            if len(args)>1:
                days = int(args[1])
                first_date = datetime.datetime.now() - datetime.timedelta(days=days+1)
                lines = MRExemptionRecord.query(MRExemptionRecord.last_update_date>first_date)\
                                         .order(-MRExemptionRecord.last_update_date)
            else:
                lines = MRExemptionRecord.query().order(-MRExemptionRecord.last_update_date)

        return lines
Esempio n. 3
0
    def get_query(self, *args, **kw):
        kind = args[0]
        lines = None
        if kind == 'publication':
            publication_id = args[1]
            publication_id = int(publication_id)
            lines = MRExemptionRecord.query(
                MRExemptionRecord.publication_id == publication_id)
            self.single = True
        elif kind == 'budget':
            budget_code = args[1]
            lines = MRExemptionRecord.query(
                MRExemptionRecord.prefixes == budget_code)
        elif kind == 'updated':
            date_from = datetime.date(int(args[1]), int(args[2]), int(args[3]))
            date_to = datetime.date(int(args[4]), int(args[5]), int(args[6]))
            lines = MRExemptionRecord.query(
                MRExemptionRecord.last_update_date >= date_from,
                MRExemptionRecord.last_update_date <= date_to)
        elif kind == 'new':
            lines = MRExemptionRecord.query().order(
                -MRExemptionRecord.last_update_date)

        return lines
Esempio n. 4
0
 def get_query(self,id):
     lines = []
     if ALL_DIGITS.match(id) is not None:
         lines = Entity.query(Entity.id==id).fetch(1)
     else:
         lines = Entity.query(Entity.name==id).fetch(1)
     if len(lines)>0:
         ret = lines[0].to_dict()
         id = ret['id']
         logging.debug('entity-api: id='+id)
         supports = SupportLine.query(SupportLine.entity_id==id).order(-SupportLine.year).fetch(1000)
         ret['supports'] = [x.to_dict() for x in supports]
         exemptions = MRExemptionRecord.query(MRExemptionRecord.entity_id==id).order(-MRExemptionRecord.start_date).fetch(1000)
         ret['exemptions'] = [x.to_dict() for x in exemptions]
         return ret
     else:
         return {}
Esempio n. 5
0
 def get_query(self, id):
     lines = []
     if ALL_DIGITS.match(id) is not None:
         lines = Entity.query(Entity.id == id).fetch(1)
     else:
         lines = Entity.query(Entity.name == id).fetch(1)
     if len(lines) > 0:
         ret = lines[0].to_dict()
         id = ret['id']
         logging.debug('entity-api: id=' + id)
         supports = SupportLine.query(SupportLine.entity_id == id).order(
             -SupportLine.year).fetch(1000)
         ret['supports'] = [x.to_dict() for x in supports]
         exemptions = MRExemptionRecord.query(
             MRExemptionRecord.entity_id == id).order(
                 -MRExemptionRecord.start_date).fetch(1000)
         ret['exemptions'] = [x.to_dict() for x in exemptions]
         return ret
     else:
         return {}