diff --git a/osinaweb/billing/add/__pycache__/urls.cpython-312.pyc b/osinaweb/billing/add/__pycache__/urls.cpython-312.pyc index 52594b5a..25716f6e 100644 Binary files a/osinaweb/billing/add/__pycache__/urls.cpython-312.pyc and b/osinaweb/billing/add/__pycache__/urls.cpython-312.pyc differ diff --git a/osinaweb/billing/add/__pycache__/views.cpython-312.pyc b/osinaweb/billing/add/__pycache__/views.cpython-312.pyc index c835632a..66eb6500 100644 Binary files a/osinaweb/billing/add/__pycache__/views.cpython-312.pyc and b/osinaweb/billing/add/__pycache__/views.cpython-312.pyc differ diff --git a/osinaweb/billing/add/views.py b/osinaweb/billing/add/views.py index 5d552753..0e2d4384 100644 --- a/osinaweb/billing/add/views.py +++ b/osinaweb/billing/add/views.py @@ -272,56 +272,6 @@ def add_invoice_pdf(request, order_id): -def add_payment_pdf(request, order_id): - order = get_object_or_404(Order, id=order_id) - payments = OrderPayment.objects.filter(order = order) - paid_amount = OrderPayment.objects.filter(order=order, date_paid__isnull=False).aggregate(total_paid=Sum('amount'))['total_paid'] or 0 - cart_total = order.get_cart_total - remaining_amount = cart_total - paid_amount - - - invoice = order.invoice - - # Render both invoice and payment details templates to HTML - invoice_template = get_template('details_templates/invoice-details.html') - payment_template = get_template('details_templates/payment-details.html') - invoice_html = invoice_template.render({'order': order}) - payment_html = payment_template.render({'order': order, 'payments':payments, 'remaining_amount':remaining_amount,}) - - # Combine the HTML content of both templates - combined_html = f"{invoice_html}
{payment_html}" - - # Define CSS - css_string = ''' - @font-face { - font-family: 'Poppins'; - src: url('path_to_poppins_font_file.ttf') format('truetype'); /* Update the path to the font file */ - } - - body { - font-family: 'Poppins', sans-serif; /* Use Poppins font for the entire document */ - } - - /* Your existing CSS styles */ - /* Add or modify styles as needed */ - ''' - - # Generate PDF - pdf = HTML(string=combined_html).write_pdf( - stylesheets=[ - CSS(string=css_string), - CSS(string='@page { margin: 30px; }') - ], - presentational_hints=True - ) - - # Return PDF - response = HttpResponse(pdf, content_type='application/pdf') - response['Content-Disposition'] = 'attachment; filename="my_pdf.pdf"' - return response - - - diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3 index 7c5aca4c..333d73cc 100644 Binary files a/osinaweb/db.sqlite3 and b/osinaweb/db.sqlite3 differ diff --git a/osinaweb/osichat/__pycache__/consumers.cpython-312.pyc b/osinaweb/osichat/__pycache__/consumers.cpython-312.pyc index 20287640..4523018b 100644 Binary files a/osinaweb/osichat/__pycache__/consumers.cpython-312.pyc and b/osinaweb/osichat/__pycache__/consumers.cpython-312.pyc differ diff --git a/osinaweb/osichat/__pycache__/models.cpython-312.pyc b/osinaweb/osichat/__pycache__/models.cpython-312.pyc index 70b972c2..57cef328 100644 Binary files a/osinaweb/osichat/__pycache__/models.cpython-312.pyc and b/osinaweb/osichat/__pycache__/models.cpython-312.pyc differ diff --git a/osinaweb/osichat/api/__pycache__/serializers.cpython-312.pyc b/osinaweb/osichat/api/__pycache__/serializers.cpython-312.pyc index 79d700c4..6099e94f 100644 Binary files a/osinaweb/osichat/api/__pycache__/serializers.cpython-312.pyc and b/osinaweb/osichat/api/__pycache__/serializers.cpython-312.pyc differ diff --git a/osinaweb/osichat/api/serializers.py b/osinaweb/osichat/api/serializers.py index 4da619e4..b55694fd 100644 --- a/osinaweb/osichat/api/serializers.py +++ b/osinaweb/osichat/api/serializers.py @@ -2,7 +2,13 @@ from osichat.models import * from rest_framework import serializers +class ChatRoomGuestSerializer(serializers.ModelSerializer): + class Meta: + model = ChatRoomGuest + fields = '__all__' + class ChatRoomSerializer(serializers.ModelSerializer): + chatroomguest = ChatRoomGuestSerializer() class Meta: model = ChatRoom fields = '__all__' \ No newline at end of file diff --git a/osinaweb/osichat/consumers.py b/osinaweb/osichat/consumers.py index 4cc09754..696c0c6c 100644 --- a/osinaweb/osichat/consumers.py +++ b/osinaweb/osichat/consumers.py @@ -5,6 +5,8 @@ from django.template.loader import render_to_string from asgiref.sync import async_to_sync from django.shortcuts import get_object_or_404 import requests +from django.forms.models import model_to_dict +from django.core.serializers.json import DjangoJSONEncoder class OsitcomVisitor(WebsocketConsumer): @@ -67,12 +69,7 @@ class OsitcomChatRoom(WebsocketConsumer): if event_type == 'load_chat': self.client_type = text_data_json.get('client_type') - event = { - 'type': 'load_chat_handler', - } - async_to_sync(self.channel_layer.group_send)( - self.session_id, event - ) + self.load_chat_handler() if event_type == 'start_conversation': chat_room = ChatRoom.objects.create( @@ -115,7 +112,7 @@ class OsitcomChatRoom(WebsocketConsumer): - def load_chat_handler(self, event): + def load_chat_handler(self): if self.chat_room: chat_room = self.chat_room chat_room_messages = ChatMessage.objects.filter(room=chat_room).order_by('date_sent') @@ -127,9 +124,18 @@ class OsitcomChatRoom(WebsocketConsumer): 'chat_room_messages': chat_room_messages, } if self.client_type == 'mobile_admin': + chat_room_data = model_to_dict(chat_room) + chat_room_messages_data = [model_to_dict(message) for message in chat_room_messages] self.send(text_data=json.dumps({ 'event_type': 'load_chat', - 'context': context, + 'chat_room_data': chat_room_data, + 'chat_room_messages_data': chat_room_messages_data + },cls=DjangoJSONEncoder)) + elif self.client_type == 'website_admin': + html = render_to_string("chat_templates/chat-widget.html", context=context) + self.send(text_data=json.dumps({ + 'event_type': 'load_chat', + 'html': html, })) else: html = render_to_string("chat-widget.html", context=context) @@ -163,9 +169,16 @@ class OsitcomChatRoom(WebsocketConsumer): 'chat_message': chat_message, } if self.client_type == 'mobile_admin': + chat_message_data = model_to_dict(chat_message) self.send(text_data=json.dumps({ 'event_type': 'send_message', - 'context': context, + 'chat_message_data': chat_message_data, + },cls=DjangoJSONEncoder)) + elif self.client_type == 'website_admin': + html = render_to_string("chat_templates/message.html", context=context) + self.send(text_data=json.dumps({ + 'event_type': 'send_message', + 'html': html, })) else: html = render_to_string("partials/message.html", context=context) diff --git a/osinaweb/osichat/migrations/__pycache__/0014_alter_chatmessageattachment_message.cpython-312.pyc b/osinaweb/osichat/migrations/__pycache__/0014_alter_chatmessageattachment_message.cpython-312.pyc new file mode 100644 index 00000000..58b7859b Binary files /dev/null and b/osinaweb/osichat/migrations/__pycache__/0014_alter_chatmessageattachment_message.cpython-312.pyc differ diff --git a/osinaweb/osichat/templates/chat-room.html b/osinaweb/osichat/templates/chat-room.html index b4ab7ffc..d884682e 100644 --- a/osinaweb/osichat/templates/chat-room.html +++ b/osinaweb/osichat/templates/chat-room.html @@ -94,7 +94,7 @@ {% else %} {% if message.chatmessageattachment.is_image %}{{guest_session_id}}
+{{chat_room.id}}
+{{guest_session_id}}
-{{message.content}}
-nn
-{{message.content}}
-{{message.content}}