diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3
index fa8120b5..3ba7f9f4 100644
Binary files a/osinaweb/db.sqlite3 and b/osinaweb/db.sqlite3 differ
diff --git a/osinaweb/osichat/__pycache__/admin.cpython-310.pyc b/osinaweb/osichat/__pycache__/admin.cpython-310.pyc
index 7306fde1..935cc9d7 100644
Binary files a/osinaweb/osichat/__pycache__/admin.cpython-310.pyc and b/osinaweb/osichat/__pycache__/admin.cpython-310.pyc differ
diff --git a/osinaweb/osichat/__pycache__/consumers.cpython-310.pyc b/osinaweb/osichat/__pycache__/consumers.cpython-310.pyc
index 24fe4200..5c2392fa 100644
Binary files a/osinaweb/osichat/__pycache__/consumers.cpython-310.pyc and b/osinaweb/osichat/__pycache__/consumers.cpython-310.pyc differ
diff --git a/osinaweb/osichat/__pycache__/models.cpython-310.pyc b/osinaweb/osichat/__pycache__/models.cpython-310.pyc
index 5c8ded38..6b63d8db 100644
Binary files a/osinaweb/osichat/__pycache__/models.cpython-310.pyc and b/osinaweb/osichat/__pycache__/models.cpython-310.pyc differ
diff --git a/osinaweb/osichat/admin.py b/osinaweb/osichat/admin.py
index 7f28068c..5d0fe1d5 100644
--- a/osinaweb/osichat/admin.py
+++ b/osinaweb/osichat/admin.py
@@ -11,3 +11,4 @@ admin.site.register(ChatMessage)
admin.site.register(ChatMessageAttachment)
admin.site.register(ChatMessageReaction)
admin.site.register(ChatMessageSeen)
+admin.site.register(ChatRoomReview)
diff --git a/osinaweb/osichat/consumers.py b/osinaweb/osichat/consumers.py
index 7103c6a1..2381d4d4 100644
--- a/osinaweb/osichat/consumers.py
+++ b/osinaweb/osichat/consumers.py
@@ -53,6 +53,7 @@ class OsitcomVisitor(WebsocketConsumer):
class OsitcomChatRoom(WebsocketConsumer):
def connect(self):
self.session_id = self.scope['url_route']['kwargs']['session_id']
+ self.domain = 'https://osina.ositcom.com'
async_to_sync(self.channel_layer.group_add)(
self.session_id, self.channel_name
)
@@ -224,6 +225,28 @@ class OsitcomChatRoom(WebsocketConsumer):
self.session_id, event
)
+ if event_type == 'submit_review':
+ if ChatRoomReview.objects.filter(room=self.chat_room).last():
+ review = ChatRoomReview.objects.filter(room=self.chat_room).last()
+ if text_data_json.get('reaction'):
+ review.reaction = text_data_json.get('reaction')
+ if text_data_json.get('details'):
+ review.details = text_data_json.get('details')
+ review.save()
+ else:
+ review = ChatRoomReview.objects.create(
+ room = self.chat_room,
+ reaction = text_data_json.get('reaction'),
+ details = text_data_json.get('details'),
+ )
+ event = {
+ 'type': 'submit_review_handler',
+ 'review_id': review.id
+ }
+ async_to_sync(self.channel_layer.group_send)(
+ self.session_id, event
+ )
+
@@ -233,14 +256,18 @@ class OsitcomChatRoom(WebsocketConsumer):
if self.chat_room:
chat_room = self.chat_room
chat_room_messages = ChatMessage.objects.filter(room=chat_room).order_by('date_sent')
+ review = ChatRoomReview.objects.filter(room=chat_room).last()
else:
chat_room = None
chat_room_messages = None
+ review = None
context = {
'chat_room': chat_room,
'chat_room_messages': chat_room_messages,
+ 'review': review,
+ 'domain': self.domain
}
if self.client_type == 'mobile_admin':
@@ -293,7 +320,8 @@ class OsitcomChatRoom(WebsocketConsumer):
chat_room = get_object_or_404(ChatRoom, id=event['chat_room_id'])
context = {
'chat_room': chat_room,
- 'session_id':self.session_id
+ 'session_id':self.session_id,
+ 'domain': self.domain
}
if self.client_type == 'mobile_admin':
self.send(text_data=json.dumps({
@@ -316,6 +344,7 @@ class OsitcomChatRoom(WebsocketConsumer):
context = {
'member': member,
+ 'domain': self.domain
}
html = render_to_string("partials/typing.html", context=context)
@@ -332,6 +361,7 @@ class OsitcomChatRoom(WebsocketConsumer):
chat_message = get_object_or_404(ChatMessage, id=event['chat_message_id'])
context = {
'chat_message': chat_message,
+ 'domain': self.domain
}
if self.client_type == 'mobile_admin':
chat_message_data = model_to_dict(chat_message)
@@ -357,7 +387,8 @@ class OsitcomChatRoom(WebsocketConsumer):
message_attachment = get_object_or_404(ChatMessageAttachment, id=event['message_attachment_id'])
context = {
'message_attachment': message_attachment,
- 'file_type': event['file_type']
+ 'file_type': event['file_type'],
+ 'domain': self.domain
}
if self.client_type == 'mobile_admin':
message_attachment_data = model_to_dict(message_attachment)
@@ -382,7 +413,8 @@ class OsitcomChatRoom(WebsocketConsumer):
latest_unread_message = get_object_or_404(ChatMessage, id=latest_unread_message_id)
context = {
'number_of_unread' : event['number_of_unread'],
- 'latest_unread_message': latest_unread_message
+ 'latest_unread_message': latest_unread_message,
+ 'domain': self.domain
}
html = render_to_string("partials/unread-messages.html", context=context)
self.send(text_data=json.dumps({
@@ -403,9 +435,22 @@ class OsitcomChatRoom(WebsocketConsumer):
context = {
'chat_room': self.chat_room,
'chat_room_messages': ChatMessage.objects.filter(room=self.chat_room).order_by('date_sent'),
+ 'domain': self.domain
}
html = render_to_string("ended-chat.html", context=context)
self.send(text_data=json.dumps({
'event_type': 'ended_chat',
'html': html,
+ }))
+
+ def submit_review_handler(self, event):
+ review = get_object_or_404(ChatRoomReview, id=event['review_id'])
+ context = {
+ 'review': review,
+ 'chat_room': self.chat_room,
+ }
+ html = render_to_string("partials/submitted-review.html", context=context)
+ self.send(text_data=json.dumps({
+ 'event_type': 'submit_review',
+ 'html': html,
}))
\ No newline at end of file
diff --git a/osinaweb/osichat/migrations/0020_chatroomreview.py b/osinaweb/osichat/migrations/0020_chatroomreview.py
new file mode 100644
index 00000000..e5e00716
--- /dev/null
+++ b/osinaweb/osichat/migrations/0020_chatroomreview.py
@@ -0,0 +1,22 @@
+# Generated by Django 4.2.5 on 2024-08-03 08:33
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('osichat', '0019_visitorlog_visitor'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='ChatRoomReview',
+ fields=[
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('reaction', models.CharField(choices=[('Happy', 'Happy'), ('Indifferent', 'Indifferent'), ('Sad', 'Sad')], max_length=50, null=True)),
+ ('room', models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, to='osichat.chatroom')),
+ ],
+ ),
+ ]
diff --git a/osinaweb/osichat/migrations/0021_chatroomreview_details.py b/osinaweb/osichat/migrations/0021_chatroomreview_details.py
new file mode 100644
index 00000000..c15385cd
--- /dev/null
+++ b/osinaweb/osichat/migrations/0021_chatroomreview_details.py
@@ -0,0 +1,18 @@
+# Generated by Django 4.2.5 on 2024-08-03 08:34
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('osichat', '0020_chatroomreview'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='chatroomreview',
+ name='details',
+ field=models.TextField(blank=True, null=True),
+ ),
+ ]
diff --git a/osinaweb/osichat/migrations/__pycache__/0020_chatroomreview.cpython-310.pyc b/osinaweb/osichat/migrations/__pycache__/0020_chatroomreview.cpython-310.pyc
new file mode 100644
index 00000000..d9607679
Binary files /dev/null and b/osinaweb/osichat/migrations/__pycache__/0020_chatroomreview.cpython-310.pyc differ
diff --git a/osinaweb/osichat/migrations/__pycache__/0021_chatroomreview_details.cpython-310.pyc b/osinaweb/osichat/migrations/__pycache__/0021_chatroomreview_details.cpython-310.pyc
new file mode 100644
index 00000000..250333b3
Binary files /dev/null and b/osinaweb/osichat/migrations/__pycache__/0021_chatroomreview_details.cpython-310.pyc differ
diff --git a/osinaweb/osichat/models.py b/osinaweb/osichat/models.py
index 55c4b464..ec523149 100644
--- a/osinaweb/osichat/models.py
+++ b/osinaweb/osichat/models.py
@@ -46,6 +46,17 @@ class ChatRoomGuest(models.Model):
room = models.OneToOneField(ChatRoom, on_delete=models.CASCADE, null=True)
visitor = models.ForeignKey(Visitor, null=True, on_delete=models.CASCADE)
+
+class ChatRoomReview(models.Model):
+ REACTION_CHOICES = (
+ ('Happy', 'Happy'),
+ ('Indifferent', 'Indifferent'),
+ ('Sad', 'Sad'),
+ )
+ room = models.OneToOneField(ChatRoom, on_delete=models.CASCADE, null=True)
+ reaction = models.CharField(max_length=50, choices=REACTION_CHOICES, null=True)
+ details = models.TextField(null=True, blank=True)
+
class ChatMember(models.Model):
member = models.ForeignKey(User, on_delete=models.CASCADE)
room = models.ForeignKey(ChatRoom, on_delete=models.CASCADE)
diff --git a/osinaweb/osichat/templates/chat-room.html b/osinaweb/osichat/templates/chat-room.html
index 406a1706..f4f31c84 100644
--- a/osinaweb/osichat/templates/chat-room.html
+++ b/osinaweb/osichat/templates/chat-room.html
@@ -49,7 +49,7 @@
class="w-[25px] h-[25px] rounded-full shadow-md text-white flex justify-center items-center bg-osiblue uppercase text-xs">
{% if message.member.staffprofile.image %}
+ src="{{domain}}{{message.member.staffprofile.image.url}}">
{% else %}
{{message.member.first_name.0}}{{message.member.last_name.0}}
{% endif %} @@ -64,7 +64,7 @@ {% if message.chatmessageattachment.is_image %}Osichat 2.0 by Ositcom
diff --git a/osinaweb/osichat/templates/ended-chat.html b/osinaweb/osichat/templates/ended-chat.html index 577927a8..c2458fd5 100644 --- a/osinaweb/osichat/templates/ended-chat.html +++ b/osinaweb/osichat/templates/ended-chat.html @@ -45,7 +45,7 @@ class="w-[25px] h-[25px] rounded-full shadow-md text-white flex justify-center items-center bg-osiblue uppercase text-xs"> {% if message.member.staffprofile.image %}{{message.member.first_name.0}}{{message.member.last_name.0}}
{% endif %} @@ -60,7 +60,7 @@ {% if message.chatmessageattachment.is_image %}Rate your conversation
- -Osichat 2.0 by Ositcom
diff --git a/osinaweb/osichat/templates/partials/message-attachment.html b/osinaweb/osichat/templates/partials/message-attachment.html index ce0c2812..48df8823 100644 --- a/osinaweb/osichat/templates/partials/message-attachment.html +++ b/osinaweb/osichat/templates/partials/message-attachment.html @@ -5,7 +5,7 @@ class="w-[25px] h-[25px] rounded-full shadow-md text-white flex justify-center items-center bg-osiblue uppercase text-xs"> {% if message_attachment.message.member.staffprofile.image %}{{message_attachment.message.member.first_name.0}}{{message_attachment.message.member.last_name.0}}
{% endif %} @@ -14,7 +14,7 @@ {% if file_type == 'image' %}{{chat_message.member.first_name.0}}{{chat_message.member.last_name.0}}
{% endif %} @@ -20,7 +20,7 @@ {% if chat_message.chatmessageattachment.is_image %}Thank you for submitting the rating
+ +{{member.first_name.0}}{{member.last_name.0}}
{% endif %} diff --git a/osinaweb/osichat/templates/partials/unread-messages.html b/osinaweb/osichat/templates/partials/unread-messages.html index 8d2159c2..64a859c2 100644 --- a/osinaweb/osichat/templates/partials/unread-messages.html +++ b/osinaweb/osichat/templates/partials/unread-messages.html @@ -7,7 +7,7 @@ class="w-[30px] h-[30px] rounded-full shadow-md text-white flex justify-center items-center bg-osiblue uppercase text-xs"> {% if latest_unread_message.member.staffprofile.image %}{{latest_unread_message.member.first_name.0}}{{latest_unread_message.member.last_name.0}}
{% endif %} @@ -45,7 +45,7 @@Osichat 2.0 by Ositcom
diff --git a/osinaweb/osinacore/__pycache__/custom_context.cpython-310.pyc b/osinaweb/osinacore/__pycache__/custom_context.cpython-310.pyc index 04de05ac..283e1124 100644 Binary files a/osinaweb/osinacore/__pycache__/custom_context.cpython-310.pyc and b/osinaweb/osinacore/__pycache__/custom_context.cpython-310.pyc differ diff --git a/osinaweb/osinacore/__pycache__/views.cpython-310.pyc b/osinaweb/osinacore/__pycache__/views.cpython-310.pyc index a279a3af..1a3fc79d 100644 Binary files a/osinaweb/osinacore/__pycache__/views.cpython-310.pyc and b/osinaweb/osinacore/__pycache__/views.cpython-310.pyc differ diff --git a/osinaweb/osinacore/custom_context.py b/osinaweb/osinacore/custom_context.py index 8de6cdfe..0a1f0278 100644 --- a/osinaweb/osinacore/custom_context.py +++ b/osinaweb/osinacore/custom_context.py @@ -9,6 +9,9 @@ from osichat.models import * def utilities(request): + # Combine protocol and domain + current_url = 'https://osina.ositcom.com' + notes = None recent_note = None user_offline=None @@ -119,5 +122,6 @@ def utilities(request): 'open_tickets': open_tickets, 'closed_tickets': closed_tickets, 'today': today, - 'latest_chat_rooms': latest_chat_rooms + 'latest_chat_rooms': latest_chat_rooms, + 'current_url': current_url } \ No newline at end of file diff --git a/osinaweb/osinacore/templates/index.html b/osinaweb/osinacore/templates/index.html index ee79f345..865cc123 100644 --- a/osinaweb/osinacore/templates/index.html +++ b/osinaweb/osinacore/templates/index.html @@ -48,7 +48,6 @@