class ExemptionUpdated(Resource): @api.marshal_with(page_of(exemption_item)) @api.response(404, 'Exemption item not found.') def get(self, from_date, to_date): """ Returns exemptions updated between 'from' and 'to'. """ return paginate(page_args, Exemption.query.filter( Exemption.last_update_date >= from_date & Exemption.last_update_date <= to_date))
class ExemptionNewBy(Resource): @api.marshal_with(page_of(exemption_item)) @api.response(404, 'Exemption item not found.') def get(self, days): """ Returns exemptions since the last given 'days'. """ first_date = datetime.datetime.now() - datetime.timedelta(days=days + 1) return paginate(page_args, Exemption.query.filter( Exemption.last_update_date >= first_date).order_by(Exemption.last_update_date.desc))
class ProcurementBudget(Resource): @api.marshal_with(page_of(procurement_item)) @api.response(404, 'Procurement item not found.') def get(self, code): """ Returns procurements for code. """ return paginate( page_args, Procurement.query.filter(Procurement.budget_code == code))
class ProcurementEntity(Resource): @api.marshal_with(page_of(procurement_item)) @api.response(404, 'Procurement item not found.') def get(self, entity_id): """ Returns procurements for entity. """ return paginate( page_args, Procurement.query.filter(Procurement.entity_id == entity_id))
class ChangesCode(Resource): @api.marshal_with(page_of(changes_item)) @api.response(404, 'Changes not found.') def get(self, code): """ Returns changes for code """ return paginate( page_args, Changes.query.filter(Changes.budget_code == code).order_by( Changes.year.desc(), Changes.date.desc()))
class SupportEntity(Resource): @api.marshal_with(page_of(support_item)) @api.response(404, 'Support item not found.') def get(self, entity_id): """ Returns supports for entity. """ return paginate( page_args, Support.query.filter(Support.entity_id == entity_id).order_by( Support.year.desc))
class SupportCode(Resource): @api.marshal_with(page_of(support_item)) @api.response(404, 'Support item not found.') def get(self, code): """ Returns supports for code prefix. """ return paginate( page_args, Support.query.filter(Support.code.like(code + '%')).order_by( Support.year))
class ProcurementCodeKids(Resource): @api.marshal_with(page_of(procurement_item)) @api.response(404, 'Procurement item not found.') def get(self, code): """ Returns procurements for code prefix. """ return paginate( page_args, Procurement.query.filter( Procurement.budget_code.like(code + '%')).order_by( Procurement.order_date))
class SupportKindCode(Resource): @api.marshal_with(page_of(support_item)) @api.response(404, 'Support item not found.') def get(self, kind, code): """ Returns supports for kind and code prefix. """ return paginate( page_args, Support.query.filter(Support.kind == kind, Support.code.like(code + '%'), func.length(Support.code) == len(code) + 2))
class ChangesLeadingReqYear(Resource): @api.marshal_with(page_of(changes_item)) @api.response(404, 'Changes not found.') def get(self, leading_item, req_code, year): """ Returns changes by leading item, required code and year """ return paginate( page_args, Changes.query.filter(Changes.leading_item == leading_item, Changes.req_code == req_code, Changes.year == year).order_by( Changes.date.desc()))
class ExemptionNew(Resource): @api.marshal_with(page_of(exemption_item)) @api.response(404, 'Exemption item not found.') def get(self): """ Returns exemption last updated. """ return paginate(page_args, Exemption.query.order_by(Exemption.last_update_date.desc))
class ExemptionBudget(Resource): @api.marshal_with(page_of(exemption_item)) @api.response(404, 'Exemption item not found.') def get(self, code): """ Returns exemptions for budget code. """ return paginate(page_args, Exemption.query.filter(Exemption.budget_code == code))
class SupportKind(Resource): @api.marshal_with(page_of(support_item)) @api.response(404, 'Support item not found.') def get(self, kind): """ Returns supports for kind. """ return paginate(page_args, Support.query.filter(Support.kind == kind))
class SupportRecipientYear(Resource): @api.marshal_with(page_of(support_item)) @api.response(404, 'Support item not found.') def get(self, recipient, year): """ Returns supports for recipient. """ raise NotImplementedError