コード例 #1
0
ファイル: schedule.py プロジェクト: alexhughson/copilot
 def get_schedule(self, user, business_id):
     if not user:
         return
     # TODO: not permissions...Just kidding, it IS permissions
     db = ScheduleAvailability.gql("WHERE business_id = :1", business_id)
     ret = gql_to_raw(db)
     return ret
コード例 #2
0
ファイル: contact.py プロジェクト: alexhughson/copilot
    def get_client_messages(self, user, business_id, client_id):
        if not user or not business.user_owns_business(user.user_id(), business_id):
            return {"error": "permissions"}
        interaction = InteractionRecord.gql("WHERE business_id = :1 AND user = :2", business_id, Key(client_id)).get()

        if not interaction:
            return []

        messages = Solicitation.gql("WHERE interaction = :1 ORDER BY when", interaction)
        return gql_to_raw(messages)
コード例 #3
0
ファイル: contact.py プロジェクト: alexhughson/copilot
    def get_messages(self, user, business_id, user_id = None):
        if user_id:
            if not business.user_owns_business(user.user_id(), business_id):
                return {"error": "You do not own that business"}
            user = CoUser.get(user_id)
            if not user:
                return {"error": "What are you doing?"}

        interaction = InteractionRecord.gql("WHERE business_id = :1 AND user = :2", business_id, user).get()
        if not interaction:
            return []
        messages = Solicitation.gql("WHERE interaction = :1 ORDER BY when", interaction)
        return gql_to_raw(messages)
コード例 #4
0
ファイル: schedule.py プロジェクト: alexhughson/copilot
    def get_bookings(self, user, business_id, user_id=None):
        # My intuition tells me that this is bad design
        # My laziness told it to shut up
        if user_id:
            if not business.user_owns_business(user.user_id(), business_id):
                return {"error": "You don't own that business"}

            # At this point, permissions are good
            user = CoUser.get(user_id)

        if not user:
            return []

        bookings = Booking.gql("WHERE user = :1 AND business_id = :2", user, business_id)
        return gql_to_raw(bookings)