Exemple #1
0
 def delete_booking(self, user, booking_id):
     booking = Booking.get(booking_id)
     if not booking:
         return {"error": "No such booking"}
     if str(booking.user.key()) == str(user.key()):
         booking.delete()
         return {"success": True}
     elif business.user_owns_business(user.user_id(), booking.business_id):
         booking.delete()
         return {"success": True}
     else:
         return {"error": "insufficient permissions"}
Exemple #2
0
 def approve_booking(self, user, booking_id):
     booking = Booking.get(booking_id)
     if not booking:
         return {"error": "No such booking"}
     if str(booking.user.key()) == str(user.key()):
         booking.approved_by_customer = True
         booking.put()
         return model_to_dict(booking)
     if business.user_owns_business(user.user_id(), booking.business_id):
         booking.approved_by_contractor = True
         booking.put()
         return model_to_dict(booking)
     return {"error": "Insufficient permissions"}
Exemple #3
0
    def edit_booking(self,user, business_id, booking_id, start, end):
        booking = Booking.get(booking_id)
        that_biz = Business.get(business_id)
        if end < start:
            return {"error": "what are you doing?  You can't end before you start"}
        if not booking or not that_biz or not ( booking.user == user or that_biz.owner == user):
            return {"error": "not allowed"}

        if booking.user == user:
            booking.approved_by_customer = True
            booking.approved_by_contractor = False
        else:
            booking.approved_by_contractor = True
            booking.approved_by_customer = False

        booking.start_time = start
        booking.end_time = end
        booking.put()
        return {"success": db.to_dict()}