def find_by_id(cls, id, abort_404 = True, published = True): if published: result = Session.query(Schedule).filter_by(id=id).filter_by(published=published).first() else: result = Session.query(Schedule).filter_by(id=id).first() if result is None and abort_404: abort(404, "No such Schedule") return result
def find_by_id(cls, id, abort_404=True, published=True): if published: result = Session.query(Schedule).filter_by(id=id).filter_by( published=published).first() else: result = Session.query(Schedule).filter_by(id=id).first() if result is None and abort_404: abort(404, "No such Schedule") return result
def find_by_id(cls, id, abort_404 = True, published = True): if published: #I can't see why this exists as events as published, not schedules #Original: result = Session.query(Schedule).filter_by(id=id).filter_by(published=published).first() result = Session.query(Schedule).filter_by(id=id).first() else: result = Session.query(Schedule).filter_by(id=id).first() if result is None and abort_404: abort(404, "No such Schedule") return result
def find_by_date(cls, date, primary=False): start = datetime.combine(date, time(0, 0, 0)) end = datetime.combine(date, time(23, 59, 59)) if primary == True: return Session.query(TimeSlot).filter( TimeSlot.start_time.between( start, end)).filter(TimeSlot.primary == primary).order_by( TimeSlot.start_time).all() else: return Session.query(TimeSlot).filter( TimeSlot.start_time.between(start, end)).order_by( TimeSlot.start_time).all()
def find_accepted_by_id(cls, id): #status = ProposalStatus.find_by_name('Accepted') #result = Session.query(Proposal).filter_by(id=id,status_id=status.id) # Optimisation: assume that ProposalStatus of ID=1 is Accepted result = Session.query(Proposal).filter_by(id=id,status_id=1).one() return result
def find_accepted_by_id(cls, id): #status = ProposalStatus.find_by_name('Accepted') #result = Session.query(Proposal).filter_by(id=id,status_id=status.id) # Optimisation: assume that ProposalStatus of ID=1 is Accepted result = Session.query(Proposal).filter_by(id=id, status_id=1).one() return result
def find_next_proposal(cls, id, type_id, signed_in_person_id): withdrawn = FundingStatus.find_by_name('Withdrawn') next = Session.query(Funding).from_statement(""" SELECT f.id FROM (SELECT id FROM funding WHERE id <> %d AND status_id <> %d AND funding_type_id = %d EXCEPT SELECT funding_id AS id FROM funding_review WHERE funding_review.reviewer_id = %d) AS f LEFT JOIN funding_review AS r ON(f.id=r.funding_id) GROUP BY f.id ORDER BY COUNT(r.reviewer_id), RANDOM() LIMIT 1 """ % (id, withdrawn.id, type_id, signed_in_person_id)) next = next.first() if next is not None: return next.id else: # looks like you've reviewed everything! return None
def select_values(self): streams = Session.query(Stream).order_by(Stream.name).all() values = [ (None, '(none)') ] for stream in streams: v = (stream.id, stream.name) values.append(v) return values
def find_all_by_type_id(cls, type_id, abort_404=True): result = Session.query(DbContent).filter_by( type_id=type_id, published=True).order_by( DbContent.creation_timestamp.desc()).all() if result is None and abort_404: abort(404, "No such db_content object") return result
def select_values(self): streams = Session.query(Stream).order_by(Stream.name).all() values = [(None, '(none)')] for stream in streams: v = (stream.id, stream.name) values.append(v) return values
def find_scheduled_by_date_and_type(cls, date, event_type): from zookeepr.model.schedule import Schedule from zookeepr.model.event import Event from zookeepr.model.time_slot import TimeSlot start = datetime.combine(date,time(0,0,0)) end = datetime.combine(date,time(23,59,59)) return Session.query(Location).join(Schedule).join(Event).join(TimeSlot).filter(Event.type==event_type).filter(TimeSlot.start_time.between(start, end)).order_by(Location.display_order).all()
def find_by_date(cls, date, primary=False): start = datetime.combine(date, time(0, 0, 0)) end = datetime.combine(date, time(23, 59, 59)) if primary == True: return ( Session.query(TimeSlot) .filter(TimeSlot.start_time.between(start, end)) .filter(TimeSlot.primary == primary) .order_by(TimeSlot.start_time) .all() ) else: return ( Session.query(TimeSlot) .filter(TimeSlot.start_time.between(start, end)) .order_by(TimeSlot.start_time) .all() )
def find_all_by_proposal_type_id(cls, id, abort_404 = True, include_withdrawn=True): result = Session.query(Proposal).filter_by(proposal_type_id=id) if not include_withdrawn: withdrawn = ProposalStatus.find_by_name('Withdrawn') result = result.filter(Proposal.status_id != withdrawn.id) result = result.all() if result is None and abort_404: abort(404, "No such proposal object") return result
def find_all_by_funding_type_id(cls, id, abort_404 = True, include_withdrawn=True): result = Session.query(Funding).filter_by(funding_type_id=id) if not include_withdrawn: withdrawn = FundingStatus.find_by_name('Withdrawn') result = result.filter(Funding.status_id != withdrawn.id) result = result.all() if result is None and abort_404: abort(404, "No such funding object") return result
def find_by_date(cls, date, primary=False): from zookeepr.model.time_slot import TimeSlot start = datetime.combine(date, time(0, 0, 0)) end = datetime.combine(date, time(23, 59, 59)) return Session.query(Schedule).options( sa.orm.eagerload_all('time_slot.schedule'), sa.orm.eagerload('location'), sa.orm.eagerload_all('event.proposal.people')).join( TimeSlot).filter(TimeSlot.start_time.between( start, end)).order_by(TimeSlot.start_time).all()
def find_scheduled_by_date_and_type(cls, date, event_type): from zookeepr.model.schedule import Schedule from zookeepr.model.event import Event from zookeepr.model.time_slot import TimeSlot start = datetime.combine(date, time(0, 0, 0)) end = datetime.combine(date, time(23, 59, 59)) return Session.query(Location).join(Schedule).join(Event).join( TimeSlot).filter(Event.type == event_type).filter( TimeSlot.start_time.between(start, end)).order_by( Location.display_order).all()
def find_all_by_proposal_type_id(cls, id, abort_404=True, include_withdrawn=True): result = Session.query(Proposal).filter_by(proposal_type_id=id) if not include_withdrawn: withdrawn = ProposalStatus.find_by_name('Withdrawn') result = result.filter(Proposal.status_id != withdrawn.id) result = result.all() if result is None and abort_404: abort(404, "No such proposal object") return result
def find_by_id(cls, id): return Session.query(Product).filter_by(id=id).first()
def find_by_category(cls, id): return Session.query(Product).filter_by(category_id=id)
def find_all(self): return Session.query(Product).order_by(Product.cost).all()
def find_all(self): return Session.query(ProductCategory).order_by(ProductCategory.display_order).order_by(ProductCategory.name).all()
def find_by_id(cls, id): return Session.query(SpecialOffer).filter_by(id=id).first()
def find_all(self): return Session.query(Role).order_by(Role.name).all()
def find_by_id(cls, id, abort_404 = True): result = Session.query(RegoRoom).filter_by(id=id).first() if result is None and abort_404: abort(404, "No such rego room object") return result
def find_by_event(cls,id): result = Session.query(Vote).filter_by(event_id=id) return result
def find_by_id(self, id, abort_404 = True): result = Session.query(Role).filter_by(id=id).first() if result is None and abort_404: abort(404, "No such role object") return result
def find_by_rego(cls,id): result = Session.query(Vote).filter_by(rego_id=id) return result
def find_all(self): return Session.query(SpecialOffer).order_by(SpecialOffer.name).all()
def find_all(cls): return Session.query(Vote).order_by(Vote.id).all()
def find_by_name(cls, name): return Session.query(SpecialOffer).filter_by(name=name).first()
def find_all(cls): return Session.query(Ceiling).order_by(Ceiling.id).all()
def find_by_name(cls, name): return Session.query(ProductCategory).filter_by(name=name).first()
def find_by_name(cls, name): return Session.query(Ceiling).filter_by(name=name).first()
def find_by_id(cls, id): return Session.query(Voucher).filter_by(id=id).first()
def find_all(cls): return Session.query(VoucherProduct).order_by(VoucherProduct.id).all()
def find_by_ids(cls, id_list): return Session.query(Registration).filter( Registration.id.in_(id_list)).all()
def find_by_id(cls, id): return Session.query(Ceiling).filter_by(id=id).first()
def find_by_filename(cls, filename): return Session.query(Attachment).filter_by(filename=filename).first()
def find_all(cls): return Session.query(Voucher).order_by(Voucher.id).all()
def find_by_id(cls, id): return Session.query(Attachment).filter_by(id=id).first()
def find_by_code(cls, code): return Session.query(Voucher).filter_by(code=code).first()
def find_all(cls): return Session.query(Attachment).order_by(Attachment.id).all()
def find_by_id(cls, id, abort_404=True): result = Session.query(Registration).filter_by(id=id).first() if result is None and abort_404: abort(404, "No such Registration object") return result
def find_by_id(cls, id): return Session.query(FundingReview).filter_by(id=id).first()
def find_all(cls): return Session.query(Registration).order_by(Registration.id).all()
def find_all(cls): return Session.query(FundingReview).order_by(FundingReview.id).all()
def find_all(cls): return Session.query(RegoRoom).order_by(RegoRoom.id).all()
def find_by_name(self, name, abort_404 = True): result = Session.query(Role).filter_by(name=name).first() return result