Skip to content

Commit

Permalink
add booking detail stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
btb committed Jul 19, 2024
1 parent b7158e5 commit 62e62da
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 8 deletions.
19 changes: 18 additions & 1 deletion uw_mazevo/api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from uw_mazevo import DAO, get_resource, post_resource
from uw_mazevo.models import Booking, Building, Room, Status
from uw_mazevo.models import Booking, BookingDetail, Building, Room, Status


class PublicConfiguration(object):
Expand Down Expand Up @@ -72,3 +72,20 @@ def get_events(self, **kwargs):
for data in post_resource(url, body):
events.append(Booking.from_json(data))
return events

def get_events_with_booking_details(self, booking_ids):
"""
Returns all event information and resource details
"""
url = self.URL.format("GetEventsWithBookingDetails")
body = {"bookingIds": booking_ids}

events = []
for data in post_resource(url, body):
event = Booking.from_json(data)
event.booking_details = []
for detail in data["bookingDetails"]:
event.booking_details.append(BookingDetail.from_json(detail))
events.append(event)
return events
32 changes: 25 additions & 7 deletions uw_mazevo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,29 @@ def from_json(data):
return booking


class ServiceOrderDetail(models.Model):
booking_date = models.DateField()
service_order_start_time = models.TimeField(null=True)
service_order_end_time = models.TimeField(null=True)
resource_description = models.CharField(max_length=50)
resource_external_reference = models.CharField(max_length=255, blank=True)
service_order_id = models.PositiveIntegerField()
class BookingDetail(models.Model):
booking = models.ForeignKey(Booking)
id = models.PositiveIntegerField(primary_key=True)
resource_id = models.PositiveIntegerField()
resource = models.CharField()
service_provider = models.CharField()
quantity = models.PositiveIntegerField()
notes = models.TextField()
special_instructions = models.TextField()
service_start_time = models.TimeField(null=True)
service_end_time = models.TimeField(null=True)

@staticmethod
def from_json(data):
detail = BookingDetail()
detail.booking_id = data["bookingId"]
detail.id = data["bookingDetailId"]
detail.resource_id = data["resourceId"]
detail.resource_description = data["resource"]
detail.service_provider = data["serviceProvier"]
detail.quantity = data["quantity"]
detail.notes = data["notes"]
detail.special_instructions = data["specialInstructions"]
detail.service_start_time = data["serviceStartTime"]
detail.service_end_time = data["serviceEndTime"]
return detail

0 comments on commit 62e62da

Please sign in to comment.