def booking_list(request): response = views_template.obj_list(request, Booking, BookingSerializer) if request.method == 'POST': if response.status_code == status.HTTP_201_CREATED: send_confirmation_email(json.loads(response.content.decode("utf-8"))) return response else: return response
def create(self, request, *args, **kwargs): response = views_template.obj_list(request, Booking, BookingSerializer) if response.status_code == status.HTTP_201_CREATED: try: send_confirmation_email( json.loads(response.content.decode("utf-8"))) except SMTPException: return JsonResponse( {"message": "Problem with email sending"}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) return response
def email_template_list(request): return views_template.obj_list(request, EmailTemplate, EmailtemplateSerializer)
def booked_item_list(request): return views_template.obj_list(request, BookedItem, BookedItemSerializer)
def item_list(request): return views_template.obj_list(request, Item, ItemSerializer)
def confirmation_template_list(request): return views_template.obj_list(request, ConfirmationEmail, ConfirmationEmailSerializer)