From ada7c209e25fdc13564ed50a49bae0822f8535c0 Mon Sep 17 00:00:00 2001 From: emile Date: Sun, 21 Jul 2024 20:06:29 +0300 Subject: [PATCH] new --- .DS_Store | Bin 8196 -> 8196 bytes osinaweb/db.sqlite3 | Bin 1654784 -> 1675264 bytes .../osichat/__pycache__/admin.cpython-310.pyc | Bin 482 -> 511 bytes .../__pycache__/consumers.cpython-310.pyc | Bin 1525 -> 3278 bytes .../__pycache__/models.cpython-310.pyc | Bin 2108 -> 2758 bytes .../__pycache__/routing.cpython-310.pyc | Bin 342 -> 359 bytes osinaweb/osichat/admin.py | 3 +- osinaweb/osichat/consumers.py | 95 ++++++++++++++++-- ...sion_alter_chatroom_created_by_and_more.py | 31 ++++++ ...roomguest_remove_chatroom_guest_session.py | 26 +++++ .../migrations/0004_chatroomguest_room.py | 19 ++++ .../0005_alter_chatmessage_member.py | 21 ++++ .../0006_alter_chatmessage_content.py | 18 ++++ .../migrations/0007_chatmessage_room.py | 19 ++++ .../migrations/0008_alter_chatmessage_room.py | 19 ++++ osinaweb/osichat/migrations/0009_visitor.py | 23 +++++ ...10_visitor_left_date_visitor_visit_date.py | 23 +++++ ...atroom_created_by_and_more.cpython-310.pyc | Bin 0 -> 1024 bytes ...ove_chatroom_guest_session.cpython-310.pyc | Bin 0 -> 945 bytes .../0004_chatroomguest_room.cpython-310.pyc | Bin 0 -> 782 bytes ...5_alter_chatmessage_member.cpython-310.pyc | Bin 0 -> 856 bytes ..._alter_chatmessage_content.cpython-310.pyc | Bin 0 -> 660 bytes .../0007_chatmessage_room.cpython-310.pyc | Bin 0 -> 760 bytes ...008_alter_chatmessage_room.cpython-310.pyc | Bin 0 -> 756 bytes .../__pycache__/0009_visitor.cpython-310.pyc | Bin 0 -> 812 bytes ...ft_date_visitor_visit_date.cpython-310.pyc | Bin 0 -> 689 bytes osinaweb/osichat/models.py | 25 ++++- osinaweb/osichat/routing.py | 2 +- osinaweb/osichat/templates/chat-widget.html | 28 ++++++ osinaweb/osichat/templates/conversation.html | 73 ++++++++++++++ .../osichat/templates/partials/message.html | 13 +++ .../osichat/templates/start-conversation.html | 66 ++++++++++++ osinaweb/osichat/templates/test.html | 3 - osinaweb/osinacore/templates/index.html | 21 ---- .../__pycache__/settings.cpython-310.pyc | Bin 3129 -> 3129 bytes osinaweb/osinaweb/settings.py | 1 - osinaweb/static/js/osichat/chat-toggle.js | 18 ++++ osinaweb/static/js/osichat/conversation.js | 87 ++++++++++++++++ osinaweb/support/.DS_Store | Bin 6148 -> 6148 bytes osinaweb/support/templates/.DS_Store | Bin 8196 -> 8196 bytes .../templates/details_templates/.DS_Store | Bin 6148 -> 6148 bytes 41 files changed, 593 insertions(+), 41 deletions(-) create mode 100644 osinaweb/osichat/migrations/0002_chatroom_guest_session_alter_chatroom_created_by_and_more.py create mode 100644 osinaweb/osichat/migrations/0003_chatroomguest_remove_chatroom_guest_session.py create mode 100644 osinaweb/osichat/migrations/0004_chatroomguest_room.py create mode 100644 osinaweb/osichat/migrations/0005_alter_chatmessage_member.py create mode 100644 osinaweb/osichat/migrations/0006_alter_chatmessage_content.py create mode 100644 osinaweb/osichat/migrations/0007_chatmessage_room.py create mode 100644 osinaweb/osichat/migrations/0008_alter_chatmessage_room.py create mode 100644 osinaweb/osichat/migrations/0009_visitor.py create mode 100644 osinaweb/osichat/migrations/0010_visitor_left_date_visitor_visit_date.py create mode 100644 osinaweb/osichat/migrations/__pycache__/0002_chatroom_guest_session_alter_chatroom_created_by_and_more.cpython-310.pyc create mode 100644 osinaweb/osichat/migrations/__pycache__/0003_chatroomguest_remove_chatroom_guest_session.cpython-310.pyc create mode 100644 osinaweb/osichat/migrations/__pycache__/0004_chatroomguest_room.cpython-310.pyc create mode 100644 osinaweb/osichat/migrations/__pycache__/0005_alter_chatmessage_member.cpython-310.pyc create mode 100644 osinaweb/osichat/migrations/__pycache__/0006_alter_chatmessage_content.cpython-310.pyc create mode 100644 osinaweb/osichat/migrations/__pycache__/0007_chatmessage_room.cpython-310.pyc create mode 100644 osinaweb/osichat/migrations/__pycache__/0008_alter_chatmessage_room.cpython-310.pyc create mode 100644 osinaweb/osichat/migrations/__pycache__/0009_visitor.cpython-310.pyc create mode 100644 osinaweb/osichat/migrations/__pycache__/0010_visitor_left_date_visitor_visit_date.cpython-310.pyc create mode 100644 osinaweb/osichat/templates/chat-widget.html create mode 100644 osinaweb/osichat/templates/conversation.html create mode 100644 osinaweb/osichat/templates/partials/message.html create mode 100644 osinaweb/osichat/templates/start-conversation.html delete mode 100644 osinaweb/osichat/templates/test.html create mode 100644 osinaweb/static/js/osichat/chat-toggle.js create mode 100644 osinaweb/static/js/osichat/conversation.js diff --git a/.DS_Store b/.DS_Store index be998a0d67daa99356f32428a17b86dddf78be96..f9c1890a7cbfd7d996382cdf7cd0489f81efc91b 100644 GIT binary patch delta 87 zcmZp1XmQwZMUY8aa`H97JJJ!E$@zJ~nN_Lr0{q1p`Q@HKZa`6LS!QbazVKWtpkv5t%@CaAsBNZo5shZJMNQPSTuhX_9j`ZSx@8oStpEJ-h#% zu|`iyE$08x%>BOm&%OV>|God!xpV$=SH>=^t`9RR750!y`O|#=;ysi)%shFj+oGr7 z*}5hB^=BfF1p+Gzyh=j4k@}KYdHWs`7T$59c4KDv|JE0lWGs}8nP^<6IGuKZNuj;&3?V2?? zzL`Kgkch+vo!T{b=k67~%)ol>8anqx{Pjhv_4Xgc_I4gto9Y`npp?8&t&$T zf9jVQTxz&9aB1PHf=dUN9xel1Mz~CHRl`-2ed?EHP2F09ks>IjiSRT*dr^d!BE1yj zCZV+iHv7tlX8MY21na{rzpy;5dBgH~%cNzmWj+20{&V~Z{ImEN-iGyw8!q4%R%3J8 zLshfd>8d`pr>d#SpnVJbo%Y*W5qnsC=>q;h=O)czH5p_5v&ms%Zg_?n_QjHkKs+@y z7EO+YWAP~=l*D$TQX}I+k{l*EZahc`^w?Y=H9``xi8*RAo{A?c%j7_}c6XSMWwmsxc6r6ojNOAK@pGo;iAYDn2^K#>g2@oK4UP zDu%V88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+?|Kh=?i zuSrwO(G4U3+;&`2aIsljOz0P_V)6dkg`63X;=$og zTP0CGme#WnSV{XsNdn}9lTxjV6V8Lr*;xjES!TIH>L;ZHh-asy0bKS#szvi!li6u0 z%%l18z!@so3E5Lr-;guKQ@-}&e zj?U(Cw#_c+Ux~pEYK=axY{9kjKR&TdPQ}N(@-oueAs>MM@1km?+bsvOIGe)(_f+8z zeX@klwaF&n$EFr~P@+%P;h8o$3s+8SMI7s8E%@Ff9Vy%8H^?84wZPavQ`SFIOrOQd k+HuS!+jFQ6VJ#WYuxF}xC`1@>LWo37krM)m6xqw*pR_^h$^ZZW diff --git a/osinaweb/osichat/__pycache__/admin.cpython-310.pyc b/osinaweb/osichat/__pycache__/admin.cpython-310.pyc index ff08f7b4a8e9a055f8a5520670130816444730eb..6e0809cbffe766321e4b83202be34c9e49422a0b 100644 GIT binary patch delta 97 zcmaFF{GXXOpO=@50SM-o%}y(v$SccOF;P34Bb70Wc>zl*&%{Y8jJy-KTk!EZXC#&c p<>%+Rm!=k%OnjHdCIHk_BrrLOu}DG$$mC(*VB}%uVMIUyMgSBu75e}H delta 72 zcmey*{D_%1pO=@50SMmsOiS~f$Scd3Gf_Kx;vxk`o{5JoCUY^Svhf3Di})v(G8Tym S0hv4u9E?27Jd7|Xzz6`9?+x|< diff --git a/osinaweb/osichat/__pycache__/consumers.cpython-310.pyc b/osinaweb/osichat/__pycache__/consumers.cpython-310.pyc index 9b2cb8d77d466c2e4484a285084f0c230252f89e..2bcaa00f5b47bf7cfd72999af2a0fbf44c8bda33 100644 GIT binary patch literal 3278 zcmZ`*TW=f372esMy^6GDTS+6Q7o~LzFm1@Bb%Mr8gP;zQmqrEZ6b1OQSnZ5xO3Phl zW@uFc_2j(z7t{fyNB^aH%~SqD+Qj|NEJ;zaO=8Ym&d%+8=R0SbZa4Grd*j}>`+vUX zdEZfI{m0Sy6h(gpAw0nagOIa2P`8iKvPu@i2DnxJoAJ zFlF8so=8OcjVDsc9tXor@CRNm`yM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^*5Q?-&a6p5^f{^-RdE4GeZ`|F3?ID@b z?rC$)3m^`O#3k>*llaOhufQQoRrd_ctRmcU`KR3Fud2RsH<@Gv+Mj>?b{=y={=&t6 zgFW&9y89M{B8nQ)(2`Q3n2HSh5%;)>$_U2T@Fp%}&=HlGq#2bXO1>d#q|&EErJ7zx zWvcioDaNnB8YyVF`?EfCUG+%&ldg5EM%!0((9qB4pg*#@RoV*Q3FmFyE?{pW-MX#% zEf_1bwBHyk9zb_rfY79*ij+)I#hwyC87U4USFuW9j0bFGqQ-zK3wOSEwXeG7XVdpu2LHaSqQIS*flFdWj4VFa(ri;WT z@PC-VqHVPiMy|CD3OCgmC`A*ZyMu$XJm0tQVaS#pRb+a_mYX}8*+MK^6_6V%~ zeKz~aY3pXXsg2gg)N4KaTDwQSTh30Ushdx}lS^D|oty!rR?b@exSyyC*)FVPX4i$UD&Rd{{?jcbQyGs-BZ>Fdq$ zZOH!}K1lrm>W{zz@~Ng*bPs)WNs$1Ez2Nh}{d%dxy@QMiNVhWD+A)|YqCMZT!8bg; z^C{N9>ekm0xW5yU(aJKlA2sG4=!CY#h$UN z2wCmfb10TeD3{;a3##I0Sn}vvGT)57c7FQMHwGw(jPUx2FFCTMU?J;qi{5>{Jp_L| z@j^*2A)_%|iOg+P;1{lIL#$TK(t!qZY2Qb2jN$_nhv~HF`^V57rk~S1N+Fkw9=+at z`o9s_g??U)LMjB7l@K8lqUqGi;5--Nmz6Yw#=ebr-$Q{B@2}m1(t|=e*%1iLW}lCg zq%<9+NuKum#kf4)*0Gx|bgOM$O`)`g2hSp@LIU?|<1G3V-W_Uix~uT1=_D|Eh*&P& jqPF^cim%^59lZQas6zVX;MQ08X7!=U5gN_mdx!r6Dkyeo diff --git a/osinaweb/osichat/__pycache__/models.cpython-310.pyc b/osinaweb/osichat/__pycache__/models.cpython-310.pyc index 52e4d923eeeb93bd558d3dd14d6cd90a5d58203c..2323309b27deb332d8372d7bb2d35f000eeab31d 100644 GIT binary patch literal 2758 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yc index a6a9cf3ccfaa0aa70d51ae59363cc069a3891300..52d7d75fc20fb768349939d39420fa6ed3d46b9f 100644 GIT binary patch delta 53 zcmcb{^qh$|pO=@50SNv!%ubs*kvCaJro31`zc@2FBe6u^rnscYsyMZ{I5R&lJ~PE` HV)bnR&IS_+ delta 36 qcmaFPbd8BOpO=@50SKNfo|V=ykvEx}yS!LGzc@2FBe7&+&usw82MmM& diff --git a/osinaweb/osichat/admin.py b/osinaweb/osichat/admin.py index a615015f..44f8b1bf 100644 --- a/osinaweb/osichat/admin.py +++ b/osinaweb/osichat/admin.py @@ -3,9 +3,10 @@ from .models import * # Register your models here. admin.site.register(ChatRoom) +admin.site.register(ChatRoomGuest) admin.site.register(ChatMember) admin.site.register(ChatProject) admin.site.register(ChatMessage) admin.site.register(ChatMessageAttachment) admin.site.register(ChatMessageReaction) -admin.site.register(ChatMessageSeen) \ No newline at end of file +admin.site.register(ChatMessageSeen) diff --git a/osinaweb/osichat/consumers.py b/osinaweb/osichat/consumers.py index 30bf1bd5..f0c070e8 100644 --- a/osinaweb/osichat/consumers.py +++ b/osinaweb/osichat/consumers.py @@ -3,38 +3,113 @@ from .models import * import json from django.template.loader import render_to_string from asgiref.sync import async_to_sync +from django.shortcuts import get_object_or_404 class OsitcomChatRoom(WebsocketConsumer): def connect(self): + self.session_id = self.scope['url_route']['kwargs']['session_id'] async_to_sync(self.channel_layer.group_add)( - 'ositcom_chat', self.channel_name + self.session_id, self.channel_name ) self.accept() - self.send_template() + self.load_chat() def disconnect(self, close_code): async_to_sync(self.channel_layer.group_discard)( - "ositcom_chat", - self.channel_name + self.session_id, self.channel_name ) - def send_template(self): + + def load_chat(self): event = { - 'type': 'send_template_handler', + 'type': 'load_chat_handler', } async_to_sync(self.channel_layer.group_send)( - 'ositcom_chat', event + self.session_id, event ) - def send_template_handler(self, event): + def receive(self, text_data): + text_data_json = json.loads(text_data) + event_type = text_data_json.get('event_type') + + if event_type == 'start_conversation': + event = { + 'type': 'start_conversation_handler', + 'guest_name': text_data_json.get('guest_name'), + 'guest_mobile_number': text_data_json.get('guest_mobile_number'), + } + async_to_sync(self.channel_layer.group_send)( + self.session_id, event + ) + + if event_type == 'send_message': + event = { + 'type': 'send_message_handler', + 'body': text_data_json['message'] + } + async_to_sync(self.channel_layer.group_send)( + self.session_id, event + ) + + + + def load_chat_handler(self, event): + chat_room = None + chat_room_messages = None + chat_room_guest = ChatRoomGuest.objects.filter(session_id=self.session_id).last() + if chat_room_guest: + chat_room = chat_room_guest.room + self.chat_room = chat_room + chat_room_messages = ChatMessage.objects.filter(room=chat_room).order_by('date_sent') + context = { + 'chat_room': chat_room, + 'chat_room_messages': chat_room_messages, + } + html = render_to_string("chat-widget.html", context=context) + self.send(text_data=json.dumps({ + 'event_type': 'load_chat', + 'html': html, + })) + + + def start_conversation_handler(self, event): + chat_room = ChatRoom.objects.create( + name=f"Support: {self.session_id}", + date_created = datetime.now() + ) + chat_room_guest = ChatRoomGuest.objects.create( + room=chat_room, + name=event['guest_name'], + mobile_number= event['guest_mobile_number'], + session_id=self.session_id + ) context = { + 'chat_room': chat_room, + 'session_id':self.session_id + } + html = render_to_string("conversation.html", context=context) + self.send(text_data=json.dumps({ + 'event_type': 'start_conversation', + 'html': html, + })) + + def send_message_handler(self, event): + chat_message = ChatMessage.objects.create( + room = self.chat_room, + content=event['body'], + date_sent = datetime.now() + ) + context = { + 'chat_message': chat_message, } - html = render_to_string("test.html", context=context) + print('lokf') + html = render_to_string("partials/message.html", context=context) self.send(text_data=json.dumps({ - 'event_type': 'chat', + 'event_type': 'send_message', 'html': html, })) + diff --git a/osinaweb/osichat/migrations/0002_chatroom_guest_session_alter_chatroom_created_by_and_more.py b/osinaweb/osichat/migrations/0002_chatroom_guest_session_alter_chatroom_created_by_and_more.py new file mode 100644 index 00000000..8151bdcb --- /dev/null +++ b/osinaweb/osichat/migrations/0002_chatroom_guest_session_alter_chatroom_created_by_and_more.py @@ -0,0 +1,31 @@ +# Generated by Django 4.2.5 on 2024-07-20 08:19 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('osichat', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='chatroom', + name='guest_session', + field=models.CharField(blank=True, max_length=300, null=True), + ), + migrations.AlterField( + model_name='chatroom', + name='created_by', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL), + ), + migrations.AlterField( + model_name='chatroom', + name='name', + field=models.CharField(max_length=300), + ), + ] diff --git a/osinaweb/osichat/migrations/0003_chatroomguest_remove_chatroom_guest_session.py b/osinaweb/osichat/migrations/0003_chatroomguest_remove_chatroom_guest_session.py new file mode 100644 index 00000000..6c011c6f --- /dev/null +++ b/osinaweb/osichat/migrations/0003_chatroomguest_remove_chatroom_guest_session.py @@ -0,0 +1,26 @@ +# Generated by Django 4.2.5 on 2024-07-20 08:28 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('osichat', '0002_chatroom_guest_session_alter_chatroom_created_by_and_more'), + ] + + operations = [ + migrations.CreateModel( + name='ChatRoomGuest', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=300)), + ('mobile_number', models.CharField(max_length=100)), + ('session_id', models.CharField(max_length=300)), + ], + ), + migrations.RemoveField( + model_name='chatroom', + name='guest_session', + ), + ] diff --git a/osinaweb/osichat/migrations/0004_chatroomguest_room.py b/osinaweb/osichat/migrations/0004_chatroomguest_room.py new file mode 100644 index 00000000..c8401fcf --- /dev/null +++ b/osinaweb/osichat/migrations/0004_chatroomguest_room.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.5 on 2024-07-20 08:29 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('osichat', '0003_chatroomguest_remove_chatroom_guest_session'), + ] + + operations = [ + migrations.AddField( + model_name='chatroomguest', + name='room', + field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, to='osichat.chatroom'), + ), + ] diff --git a/osinaweb/osichat/migrations/0005_alter_chatmessage_member.py b/osinaweb/osichat/migrations/0005_alter_chatmessage_member.py new file mode 100644 index 00000000..2b06a3a8 --- /dev/null +++ b/osinaweb/osichat/migrations/0005_alter_chatmessage_member.py @@ -0,0 +1,21 @@ +# Generated by Django 4.2.5 on 2024-07-20 12:36 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('osichat', '0004_chatroomguest_room'), + ] + + operations = [ + migrations.AlterField( + model_name='chatmessage', + name='member', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/osinaweb/osichat/migrations/0006_alter_chatmessage_content.py b/osinaweb/osichat/migrations/0006_alter_chatmessage_content.py new file mode 100644 index 00000000..bb152113 --- /dev/null +++ b/osinaweb/osichat/migrations/0006_alter_chatmessage_content.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.5 on 2024-07-20 12:45 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('osichat', '0005_alter_chatmessage_member'), + ] + + operations = [ + migrations.AlterField( + model_name='chatmessage', + name='content', + field=models.TextField(blank=True, null=True), + ), + ] diff --git a/osinaweb/osichat/migrations/0007_chatmessage_room.py b/osinaweb/osichat/migrations/0007_chatmessage_room.py new file mode 100644 index 00000000..0b87e7cc --- /dev/null +++ b/osinaweb/osichat/migrations/0007_chatmessage_room.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.5 on 2024-07-20 13:04 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('osichat', '0006_alter_chatmessage_content'), + ] + + operations = [ + migrations.AddField( + model_name='chatmessage', + name='room', + field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, to='osichat.chatroom'), + ), + ] diff --git a/osinaweb/osichat/migrations/0008_alter_chatmessage_room.py b/osinaweb/osichat/migrations/0008_alter_chatmessage_room.py new file mode 100644 index 00000000..bdf29a24 --- /dev/null +++ b/osinaweb/osichat/migrations/0008_alter_chatmessage_room.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.5 on 2024-07-20 13:44 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('osichat', '0007_chatmessage_room'), + ] + + operations = [ + migrations.AlterField( + model_name='chatmessage', + name='room', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='osichat.chatroom'), + ), + ] diff --git a/osinaweb/osichat/migrations/0009_visitor.py b/osinaweb/osichat/migrations/0009_visitor.py new file mode 100644 index 00000000..3d3703b5 --- /dev/null +++ b/osinaweb/osichat/migrations/0009_visitor.py @@ -0,0 +1,23 @@ +# Generated by Django 4.2.5 on 2024-07-21 16:48 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('osichat', '0008_alter_chatmessage_room'), + ] + + operations = [ + migrations.CreateModel( + name='Visitor', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('session_id', models.CharField(max_length=300)), + ('ip_address', models.CharField(max_length=300)), + ('url', models.URLField()), + ('reference', models.URLField()), + ], + ), + ] diff --git a/osinaweb/osichat/migrations/0010_visitor_left_date_visitor_visit_date.py b/osinaweb/osichat/migrations/0010_visitor_left_date_visitor_visit_date.py new file mode 100644 index 00000000..7bfd2f64 --- /dev/null +++ b/osinaweb/osichat/migrations/0010_visitor_left_date_visitor_visit_date.py @@ -0,0 +1,23 @@ +# Generated by Django 4.2.5 on 2024-07-21 16:49 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('osichat', '0009_visitor'), + ] + + operations = [ + migrations.AddField( + model_name='visitor', + name='left_date', + field=models.DateTimeField(null=True), + ), + migrations.AddField( + model_name='visitor', + name='visit_date', + field=models.DateTimeField(null=True), + ), + ] diff --git a/osinaweb/osichat/migrations/__pycache__/0002_chatroom_guest_session_alter_chatroom_created_by_and_more.cpython-310.pyc b/osinaweb/osichat/migrations/__pycache__/0002_chatroom_guest_session_alter_chatroom_created_by_and_more.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..217651fc10b2a72695488b621420e87b900619ac GIT binary patch literal 1024 zcmY*YOK;Oa5cc|!*lyAmgpfcScwC5t;=&Oj)QYwsk+u?PF21Zb*{N%HZHHZlk~3WM z3%CF$_)B}`#1G(t1Y*{1nqp~3-^}den{UQtw;NjcJy4%czB!il!#Gzz7oBZf>M0s- zaU!go#Do}Z3p;mWCwF7F_8sBHt(O*ex%biH9ynS1gA=#8GqifGpLpKt5$!9esj{CX!WYSt#AgOAbOEPRzcmpW(NSOT9w_R!q1R+u(e5!OL1-2q%dhxA85X+uVU5 z3(fnuS__A_7Y=6DFymvUgHac{*?Jaa8`-8g&x3_~Wmj0A_xRd^m}ug}*LVlncXe>E zq>8-TrAjBKtkRvWt*ys2Ez&AwBKA#8mSwKH$qZCQ6)1(p9jA{7*6wI;ELd@dWwZBG zK#^3Z+AU^6U@EN3rv=LaW5#+XDG08^i3C;wr{j6gl>urX*U;#oEGP;F6==IEWfx;T zB8^ywz3bYi^;MMWkW##QCIE4V(zi1v%=MH?Y`3LvsB<=*vN7g4OrhXVOy<%ysg0e{ z@hdtS?!BQ0N4t9i-MQS6g3|sD=lh1DG&7=u7pF|tz7BUp1xvhNN=TF9HOzI3XRJs{ zZS%4AYwjqH_J@1N^l&s7=&+o^#W;Mo%7b<^TWy literal 0 HcmV?d00001 diff --git a/osinaweb/osichat/migrations/__pycache__/0003_chatroomguest_remove_chatroom_guest_session.cpython-310.pyc b/osinaweb/osichat/migrations/__pycache__/0003_chatroomguest_remove_chatroom_guest_session.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..053bd14b046efd7b0e86316d8ed1cf21dcdd9122 GIT binary patch literal 945 zcmY*YOK;RL5VoD{cC(LC9^wY-329N)tl)~OLaSCtv`8&naV3W4Z zNgzu&utWgQcoJYZZukJ$94|pgUjv%3G!KsiwCJn_5wz!=P^U)SOVqn<%R*S53wkMn zd$0oc=OPnH8y--a4_&l(l^-R$q^%kqr&Y2s7z|!WuNtijnN87F(xSCghfMPd&5dzn zFs%^ea3<3dWT6eZ-WItYkn67ZbV9+09Vgyy_e0lBr^SZ39+>lJ#aa=JAwhG@=#_;c;6JQehX>G`AP zk-{8o(z>cB>D?)*?vw9L9j^A-?{{2F)>ul{mQ)u^DUx(uDL+lq+^6Ib-~>y+a-`52 z;iGl7YDV__gN6o*x$Ya4y{58vd>Sqya?C>Q9AKeOaRJ(Tf|sN6lbI*vSc^a3~XjHwg5KD;{u>yw%Be?^nFT_w?CA_)J54Z$CYW$r)mH@pZV!37U5TEFYt n`_%ntkRPWBtZz`~ne`D@#N*&UN#GbC literal 0 HcmV?d00001 diff --git a/osinaweb/osichat/migrations/__pycache__/0004_chatroomguest_room.cpython-310.pyc b/osinaweb/osichat/migrations/__pycache__/0004_chatroomguest_room.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..867efa3a7dbb1ef8f576754fd1dc1345e5e8dde4 GIT binary patch literal 782 zcmY*X&2G~`5Z)i#aY7?iNK^tYTywFJ;J^W)MlEoG_K4_GN!lFxl=-qzme`)^2EO zMU!ERPPB&TQ8%fo^9m`&`|!L#4JVVai&e)f)VjFD^cd~O)~wQ5u8Zo?n|$TLsV&-tsZx@l&eIw%x}a~`lNUJm zf!8LzdGnOCf4Y--qdlpatS%e>zXr7IU2-uKGPn*x!396y!Qc40+n+>k*mp@_-U-o< oe}6|N{ijN{LpS&QbiVe@oPG3=I2S+fC4a#Q*@)b}i1~s12bGlMZvX%Q literal 0 HcmV?d00001 diff --git a/osinaweb/osichat/migrations/__pycache__/0005_alter_chatmessage_member.cpython-310.pyc b/osinaweb/osichat/migrations/__pycache__/0005_alter_chatmessage_member.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bb09fc97270baf74f0993db3772c99297ef6a278 GIT binary patch literal 856 zcmYjPJ8#rL5Z?9ce9ncWhB|w(vH3vf2*1KKCAWhh~RnoIE@;*xS!pLmAn9?*yx{TAjQ#e z(}b+8GiD;jkhhe8c)-|)C6|`VSncA*W=o&*s^W9}E}()^K)G1e=oK*=d$W_*Y&IRg zWrxT6}WQb zm`GJ{>CJaiKf>p2`28`SX{dD!MJ55H%vKQZgFb6i6;HX$iYF6Z+2mMf%|aD1YFqNS zg!2}3UAy8r%q_6e#y5XLj2`STZbxsOxKy2WqK~Ro?c*>ZUcJ?V$aSdq*9#o#(1+Cf z6aH%%X!2UuZM0D3X{T8KvLfcKxScEyu8X7YCmdbrQQx8S%5Z*tZeI}6*M07}0NNK!s2uA!tZaBs3P%YR@}4eA!(auTLQ@(59u~ z2`G7;ZBy|INGQzuf^r38&1mME(R?%GZFhHbg7W_7_p@)5kn0$1i@;zX)jvg}iKd2F zT2ad?M#&qZndV=K=0I2c3$M5qC!|PzVJ#_G$ZfOi)zGxghly=97+=TKwxk&Bqxu;d zAQjc5Vwx^##X+o+NC1;nss(<@71NU|j=4;yNR)-?;XekXOIzR6AJkAip3mpcq%s5a zG6EL7S4)r<>;n4g-WC?px^)A%;S?Jr3!~h55N>Tu!EyXJvUJJfjN5cNlr&8A(cLZT8NA+CE#_5>Ud>Z&bVpgnB4)klyyx*u=EY_-N(ip+-@csxqJ;eLWP1fj4shEPK@v$7 zscBAYmNV)(Q#=n|6Uk+8Nn`-D3P1Balx#-E;ZM9n#>^#kxonEIG}^kTHWHLQS@^T< z6(c#oZJ#3m$*CkclXOXQ4nc(#C5NaQV2`*OR#BByJ2I5f6_KQxt>W_ftH{b zCD?|c11_FQ`O4R5xTm924QB?S(_AF0LNASDa_-{pQ_x*EIGoN7r$@&wF)O%n{3~f5 zVu22RZ?bn58k<2~DgdR*4P-}PKeT3*%?ef4Pu>(OPfl&wE=--F1-i&ITy#O-v==X6 z?gQ^lcK3fX^!eF;4twL$)u!<;X@J|_Lx>6E!F3Qa%IH1~{>0ba`8aaJzDFwOoell) p5B`a1|9sNhk(>K|HedU0%07C8nu}lbhQGwOO>Bg)$6~tA{{nu!+))4k literal 0 HcmV?d00001 diff --git a/osinaweb/osichat/migrations/__pycache__/0008_alter_chatmessage_room.cpython-310.pyc b/osinaweb/osichat/migrations/__pycache__/0008_alter_chatmessage_room.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..632f6a639ed66a2d87e11f5f345d7d4eb607c515 GIT binary patch literal 756 zcmZWn&2H2%5cW@!&8A(c0#VT$*IbglQ3-^)YAFYx92PFQSlRV7BslRl&Z=529N^j~ z;0bsN-osbKfmc96Wt_BhB`kR~^Uc^Z-)HN|BqF$;eE)j>lM?d71>4KR;0U)#&`2Vw zA~nru%`!$^%oNYO7esRDeIe2VTKS)O=1VpwvHuItkeJ!1E{itrO5GS6)LMcvXG@pc zULgiYxXmFNAQ_b;W0Dp$0{yC8jQ&c5UtjAwzGv;&p~fL?%kY8T+Tr;w_dYW%8qp-aCqpz zvQ8r$^<+eo*MKF?`sXDmc@|G>D0*B78wr7RYX#`<3URT{m8*4;gcURrnq>*5Wk}pc zGu1(R>TYRy51i^2%A$D*8ymYx15VgIVWOtL69uNnRfD=+A)a?-jLWNdENNtfQ<&cZzW+q#w`-Qz}30Ju0 zCm_L*8^6a_PW%8aAW_B}sur(2dT%^Co_XVHWhG&>em?p%`6d|q?#a~^64|6}?~wrp zJZA+T@j{FQXU`c32tG0hkWYgT!6<<6fDJo8D3%R{OA4JC)#$3Uu3J=qxgGnXt1Bk5 zN!w1yARBRDBLO_)qX5Hc$6tWmX%9mBI?#pQBAf__$QMBj$$}H>|HlT{{TzQ`m@R$+1DzAh>>QbfL^#p5WZY7L8W9evfW&isq=YC`(nKODv@&O{4~W zpOa9Wgi`Nhj%C&yyF}Mg0T>E$!OY|?HaJ0p`(V!iYb=3MXtajL%v^t~t$EK6#RT3nc&4+b)Xk1h?c%LtWtK2He6_no zNmb*&d46T)HvQF_Uv+v&&Dsq%)a59R4{0PFSK_-EOrZEuo^m8S%5Z)jA?6YzbO;S-%A-Rc7i4>uLB4|P=0*#xMb2E4BvHrp9OOzVgdxSgy zue2={uMi2r>>ig3E6wPe*_r)jKD(REGDfF7xmz3x#(w(X@rfunC9}`T0RwJW!z;H6t(!C*ps{m*_4p(doRZl$dQRYU>6m=Y71;XuxHmFVtTURjNXbQZ7@9de#OB zA1L*8T^rx$BfuV8z;>?D4x}-2>1%+u{=Gr^aCYYDb%P=2vaZK}s{LTYAyou-zbQUh z9BhG&Hi*XPTP)7dei^&IxU7wCo}Jgd4?fV2^R6jq^|mfrya@nSb-V1g$s4@#zzb9C zzfn<^FUp-n>Oq)?%zpRd{&w(x#)Qm1C6_WGqd!qBxZoL&e(zCwA1W{M$W6B+9K%(R cAuJy*_e*Zk5xwZrldYhyxF_*!PsEY@3%(w{D*ylh literal 0 HcmV?d00001 diff --git a/osinaweb/osichat/models.py b/osinaweb/osichat/models.py index 80a5eab8..16b4eaf4 100644 --- a/osinaweb/osichat/models.py +++ b/osinaweb/osichat/models.py @@ -2,12 +2,28 @@ from django.db import models from osinacore.models import * # Create your models here. +class Visitor(models.Model): + session_id = models.CharField(max_length=300) + ip_address = models.CharField(max_length=300) + url = models.URLField() + reference = models.URLField() + visit_date = models.DateTimeField(null=True) + left_date = models.DateTimeField(null=True) + class ChatRoom(models.Model): - name = models.CharField(max_length=50) - created_by = models.ForeignKey(User, null=True, on_delete=models.SET_NULL) + name = models.CharField(max_length=300) + created_by = models.ForeignKey(User, null=True, on_delete=models.SET_NULL, blank=True) date_created = models.DateTimeField() +class ChatRoomGuest(models.Model): + room = models.OneToOneField(ChatRoom, on_delete=models.CASCADE, null=True) + name = models.CharField(max_length=300) + mobile_number = models.CharField(max_length=100) + session_id = models.CharField(max_length=300) + + + class ChatMember(models.Model): member = models.ForeignKey(User, on_delete=models.CASCADE) room = models.ForeignKey(ChatRoom, on_delete=models.CASCADE) @@ -21,8 +37,9 @@ class ChatProject(models.Model): class ChatMessage(models.Model): - member = models.ForeignKey(User, null=True, on_delete=models.SET_NULL) - content = models.TimeField(null=True, blank=True) + room = models.ForeignKey(ChatRoom, on_delete=models.CASCADE, null=True) + member = models.ForeignKey(User, null=True, on_delete=models.SET_NULL, blank=True) + content = models.TextField(null=True, blank=True) date_sent = models.DateTimeField() diff --git a/osinaweb/osichat/routing.py b/osinaweb/osichat/routing.py index cb07f4a8..1d4d14d1 100644 --- a/osinaweb/osichat/routing.py +++ b/osinaweb/osichat/routing.py @@ -2,6 +2,6 @@ from django.urls import path from .consumers import * websocket_urlpatterns = [ - path("ws/osichat/", OsitcomChatRoom.as_asgi()), + path("ws/osichat//", OsitcomChatRoom.as_asgi()), ] \ No newline at end of file diff --git a/osinaweb/osichat/templates/chat-widget.html b/osinaweb/osichat/templates/chat-widget.html new file mode 100644 index 00000000..172ed99f --- /dev/null +++ b/osinaweb/osichat/templates/chat-widget.html @@ -0,0 +1,28 @@ +
+ {% if chat_room %} + {% include 'conversation.html' %} + {% else %} + {% include 'start-conversation.html' %} + {% endif %} +
+ + + +
+ + + + + +

Chat with us

+
+ + \ No newline at end of file diff --git a/osinaweb/osichat/templates/conversation.html b/osinaweb/osichat/templates/conversation.html new file mode 100644 index 00000000..aaf6cc0a --- /dev/null +++ b/osinaweb/osichat/templates/conversation.html @@ -0,0 +1,73 @@ +{%load static%} +
+
+
+ +
+
+
+ + + + + + + + + + + + + +
+
+
+

Hello {{chat_room.chatroomguest.name}}, the support department is notified about your request to start a conversation. It usually takes few minutes for you to receieve a reply.

+
+
+ +
+ {% for message in chat_room_messages %} +
+

{{message.content}}

+
+ {% endfor %} +
+ +
+ +
+ + +
+ + +
+
+ +
+ + + + + +

Chat with us

+
+ + + + diff --git a/osinaweb/osichat/templates/partials/message.html b/osinaweb/osichat/templates/partials/message.html new file mode 100644 index 00000000..5a52ee30 --- /dev/null +++ b/osinaweb/osichat/templates/partials/message.html @@ -0,0 +1,13 @@ +
+

{{chat_message.content}}

+
+ + diff --git a/osinaweb/osichat/templates/start-conversation.html b/osinaweb/osichat/templates/start-conversation.html new file mode 100644 index 00000000..07ffa6ef --- /dev/null +++ b/osinaweb/osichat/templates/start-conversation.html @@ -0,0 +1,66 @@ +{% load static %} +
+
+ +
+
+ +

Welcome to Ositcom

+
+ +
+

+ We are here 24/7/365 to help with sales or support queries. To start your conversation enter your + name + and mobile number below. +

+ +
+ + +
+
+
+ +
+
+

We are online

+ +

Typically replies in a few minutes

+ + +
+
+
+
+ + + +
+ + + + + +

Chat with us

+
+ + \ No newline at end of file diff --git a/osinaweb/osichat/templates/test.html b/osinaweb/osichat/templates/test.html deleted file mode 100644 index 28ab7384..00000000 --- a/osinaweb/osichat/templates/test.html +++ /dev/null @@ -1,3 +0,0 @@ -
- Hiiii -
\ No newline at end of file diff --git a/osinaweb/osinacore/templates/index.html b/osinaweb/osinacore/templates/index.html index ff9c2d12..22c74995 100644 --- a/osinaweb/osinacore/templates/index.html +++ b/osinaweb/osinacore/templates/index.html @@ -361,27 +361,6 @@ - - - diff --git a/osinaweb/osinaweb/__pycache__/settings.cpython-310.pyc b/osinaweb/osinaweb/__pycache__/settings.cpython-310.pyc index ddc7ebc0afe5fa257e1ead1cae64990feb188393..e0b061125dd9bef54752b35ce7e699e96318b7bc 100644 GIT binary patch delta 28 hcmdlfu~ULKpO=@50R#$Xr>)z_`;?nebn<6zHvnlp2mSy6 delta 28 icmdlfu~ULKpO=@50SGQQO-tLok@qP#quAun+-?AKE(oXq diff --git a/osinaweb/osinaweb/settings.py b/osinaweb/osinaweb/settings.py index 74450788..3eb4444b 100644 --- a/osinaweb/osinaweb/settings.py +++ b/osinaweb/osinaweb/settings.py @@ -79,7 +79,6 @@ TEMPLATES = [ 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ - 'osinacore.custom_context.utilities', 'customercore.custom_context.utilities', 'django.template.context_processors.debug', diff --git a/osinaweb/static/js/osichat/chat-toggle.js b/osinaweb/static/js/osichat/chat-toggle.js new file mode 100644 index 00000000..5bba29b7 --- /dev/null +++ b/osinaweb/static/js/osichat/chat-toggle.js @@ -0,0 +1,18 @@ +console.log('toggle me'); +document.addEventListener('DOMContentLoaded', function() { + const openChatButton = document.getElementById('openChatContainer'); + const chatContainer = document.getElementById('chatContainer'); + const closeChatButton = document.getElementById('closeChatContainer'); + + openChatButton.addEventListener('click', function() { + chatContainer.classList.remove('hidden'); + openChatButton.classList.add('hidden'); + closeChatButton.classList.remove('hidden'); + }); + + closeChatButton.addEventListener('click', function() { + chatContainer.classList.add('hidden'); + openChatButton.classList.remove('hidden'); + closeChatButton.classList.add('hidden'); + }); +}) \ No newline at end of file diff --git a/osinaweb/static/js/osichat/conversation.js b/osinaweb/static/js/osichat/conversation.js new file mode 100644 index 00000000..a09e4ad3 --- /dev/null +++ b/osinaweb/static/js/osichat/conversation.js @@ -0,0 +1,87 @@ + +const chat_ws_scheme = window.location.protocol === "https:" ? "wss" : "ws"; +const domain = "192.168.1.111:8000"; +const sessionId = document.getElementById('session_id').textContent.trim(); +console.log(sessionId); +const osichatSocketUrl = `${chat_ws_scheme}://${domain}/ws/osichat/${sessionId}/`; +const osichatSocket = new WebSocket(osichatSocketUrl); + + +osichatSocket.onopen = () => { + console.log('WebSocket connection to osichat established'); +}; + +osichatSocket.onmessage = function(e) { + const data = JSON.parse(e.data); + if (data.event_type === 'load_chat') { + const chatDiv = document.getElementById('osichat'); + const html = data.html; + chatDiv.innerHTML = html; + + // Append the toggle tag + const script = document.createElement('script'); + script.type = 'text/javascript'; + script.src = `http://${domain}/static/js/osichat/chat-toggle.js`; + chatDiv.appendChild(script); + + const startChatContainer = document.getElementById('startChat'); + // If this container exists then the template returned was start-conversation.html, no conversation yet. + if (startChatContainer) { + startChatContainer.addEventListener('submit', function(event) { + event.preventDefault(); + + const guestName = event.target.elements.guest_name.value; + const guestMobileNumber = event.target.elements.guest_mobile_number.value; + + const eventMessage = { + 'event_type': 'start_conversation', + 'guest_name': guestName, + 'guest_mobile_number': guestMobileNumber, + }; + + osichatSocket.send(JSON.stringify(eventMessage)); + + event.target.reset(); + }); + } + + const sendMessageContainer = document.getElementById('sendMessage'); + if (sendMessageContainer) { + sendMessageContainer.addEventListener('submit', function(event) { + event.preventDefault(); + + const message = event.target.elements.message.value; + + const eventMessage = { + 'event_type': 'send_message', + 'message': message, + + }; + + osichatSocket.send(JSON.stringify(eventMessage)); + + event.target.reset(); + }); + } + + } else if (data.event_type === 'start_conversation') { + const chatDiv = document.getElementById('startChatContainer'); + const html = data.html; + chatDiv.innerHTML = html; + + } else if (data.event_type === 'send_message') { + const messagesDiv = document.getElementById('messages'); + const html = data.html; + messagesDiv.insertAdjacentHTML('beforeend', html); + + } +}; + +osichatSocket.onclose = () => { + console.log('WebSocket connection to osichat closed'); +}; + +osichatSocket.onerror = (error) => { + console.log('WebSocket error:', error); +}; + diff --git a/osinaweb/support/.DS_Store b/osinaweb/support/.DS_Store index 34733c742364ff4a8068d0e883bd84ecddc6b798..9685a61a9241699935f737ed6b2a0eba956aab77 100644 GIT binary patch delta 31 ncmZoMXfc@J&&abeU^g=(&tx8!&zpl;w=hj?2-(ce@s}R}rL+pG delta 102 zcmZoMXfc@J&&aniU^g=(-(((^&z@`yDGaF$IY3;(km{L}pPZDFpTxkxAOOUUKs@h1 h7ywxe3@kuZDGZqmC1~o_gVb&Q!m^)fGdss$egMOX9P3dD>jR9V*?x0 VW_F2hER#IXR4s-^u3PUDC3Dhb4tm}a$>P^lO(E=(G-kdEmjd3%(#5b1B#=>ljL@1xk2mlC_Je>dl diff --git a/osinaweb/support/templates/details_templates/.DS_Store b/osinaweb/support/templates/details_templates/.DS_Store index 097fe15c4fc320fa01fa8673202f05c6adcfe30d..c35889ce2d19cee4815ac8651af75bb65c4aa220 100644 GIT binary patch delta 401 zcmZoMXfc=|#>B)qu~2NHo+2ab!~pBf0*noeKvs`&JqJSpLn1>FLkUABkj`N!PAV@h zNXp4iVqjp{o>Y*NSzKaZaE+0PnT3^&or9f&nXr1w@?l^GXsk^HPhz8ZuK-fl6Y+GxJjN%boH|^HPd|dh3BkL1Z{MIXL45 z#H*`~EX{NjEDUOO6sj%EjDbuuliFHN4pC)&>!A4ToZP(pPN3U>fRPbGGw?!b7}W)2 zVEC&nxF|0tKQA392ht}1_HpvWW0uY$5GF%5Ln@G^%TNraK>?D-kPhVOF=PP6a~X0x zbMlj+K_dV(MHXm`-hVLI%*g1+vYDNOp92`sK+bpO$^0UQ0w9YTfEY-F-MTqIWD7F@ DzawL! delta 70 zcmZoMXfc=|#>CJ*u~2NHo+2aD!~pBb1|lqz`I!tRn=w0VKE~|GviSn@ai-1e9Q+(W ag_{pDe`lV|FJj2ZFxiGjdUK4(3T6Py+!Of#