Example #1
0
    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
Example #2
0
    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
Example #3
0
    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
Example #4
0
    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()
Example #5
0
    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
Example #6
0
    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
Example #7
0
 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
Example #8
0
 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
Example #9
0
 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
Example #10
0
 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
Example #11
0
    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()
Example #12
0
    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()
            )
Example #13
0
    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
Example #14
0
    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
Example #15
0
    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()
Example #16
0
    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()
Example #17
0
    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
Example #18
0
 def find_by_id(cls, id):
     return Session.query(Product).filter_by(id=id).first()
Example #19
0
 def find_by_category(cls, id):
     return Session.query(Product).filter_by(category_id=id)
Example #20
0
 def find_all(self):
     return Session.query(Product).order_by(Product.cost).all()
Example #21
0
 def find_all(self):
     return Session.query(ProductCategory).order_by(ProductCategory.display_order).order_by(ProductCategory.name).all()
Example #22
0
 def find_by_id(cls, id):
     return Session.query(SpecialOffer).filter_by(id=id).first()
Example #23
0
 def find_all(self):
     return Session.query(Role).order_by(Role.name).all()
Example #24
0
 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
Example #25
0
 def find_by_event(cls,id):
     result = Session.query(Vote).filter_by(event_id=id)
     return result
Example #26
0
 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
Example #27
0
 def find_by_rego(cls,id):
     result = Session.query(Vote).filter_by(rego_id=id)
     return result
Example #28
0
 def find_all(self):
     return Session.query(SpecialOffer).order_by(SpecialOffer.name).all()
Example #29
0
 def find_all(cls):
     return Session.query(Vote).order_by(Vote.id).all()
Example #30
0
 def find_by_name(cls, name):
     return Session.query(SpecialOffer).filter_by(name=name).first()
Example #31
0
 def find_all(cls):
     return Session.query(Ceiling).order_by(Ceiling.id).all()
Example #32
0
 def find_by_name(cls, name):
     return Session.query(ProductCategory).filter_by(name=name).first()
Example #33
0
 def find_by_name(cls, name):
     return Session.query(Ceiling).filter_by(name=name).first()
Example #34
0
 def find_by_id(cls, id):
     return Session.query(Product).filter_by(id=id).first()
Example #35
0
 def find_by_id(cls, id):
     return Session.query(Voucher).filter_by(id=id).first()
Example #36
0
 def find_all(self):
     return Session.query(Product).order_by(Product.cost).all()
Example #37
0
 def find_all(cls):
     return Session.query(VoucherProduct).order_by(VoucherProduct.id).all()
Example #38
0
 def find_by_category(cls, id):
     return Session.query(Product).filter_by(category_id=id)
Example #39
0
 def find_by_ids(cls, id_list):
     return Session.query(Registration).filter(
         Registration.id.in_(id_list)).all()
Example #40
0
 def find_by_id(cls, id):
     return Session.query(Ceiling).filter_by(id=id).first()
Example #41
0
 def find_by_filename(cls, filename):
     return Session.query(Attachment).filter_by(filename=filename).first()
Example #42
0
 def find_all(cls):
     return Session.query(Voucher).order_by(Voucher.id).all()
Example #43
0
 def find_by_id(cls, id):
     return Session.query(Attachment).filter_by(id=id).first()
Example #44
0
 def find_by_code(cls, code):
     return Session.query(Voucher).filter_by(code=code).first()
Example #45
0
 def find_all(cls):
     return Session.query(Attachment).order_by(Attachment.id).all()
Example #46
0
 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
Example #47
0
 def find_by_id(cls, id):
     return Session.query(FundingReview).filter_by(id=id).first()
Example #48
0
 def find_all(cls):
     return Session.query(Registration).order_by(Registration.id).all()
Example #49
0
 def find_all(cls):
     return Session.query(FundingReview).order_by(FundingReview.id).all()
Example #50
0
 def find_all(cls):
     return Session.query(RegoRoom).order_by(RegoRoom.id).all()
Example #51
0
 def find_by_name(self, name, abort_404 = True):
     result = Session.query(Role).filter_by(name=name).first()
     return result