django-chelseru 1.0.3__tar.gz → 1.0.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {django_chelseru-1.0.3/django_chelseru.egg-info → django_chelseru-1.0.5}/PKG-INFO +3 -2
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/README_PA.md +2 -1
- {django_chelseru-1.0.3 → django_chelseru-1.0.5/django_chelseru.egg-info}/PKG-INFO +3 -2
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/django_chelseru.egg-info/SOURCES.txt +5 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/drfchelseru/admin.py +6 -2
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/drfchelseru/consumers.py +2 -0
- django_chelseru-1.0.5/drfchelseru/migrations/0007_chatroom_pinned_for_chatroom_status_chatroom_users_and_more.py +131 -0
- django_chelseru-1.0.5/drfchelseru/migrations/0008_alter_chatroompermissions_user.py +25 -0
- django_chelseru-1.0.5/drfchelseru/migrations/0009_alter_chatroom_status.py +20 -0
- django_chelseru-1.0.5/drfchelseru/migrations/0010_chatroom_banneds_chatroom_descriptions_chatroom_name_and_more.py +41 -0
- django_chelseru-1.0.5/drfchelseru/migrations/0011_alter_chatroom_user_1_alter_chatroom_user_2.py +26 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/drfchelseru/models.py +69 -2
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/drfchelseru/services.py +1 -1
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/drfchelseru/settings.py +1 -1
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/drfchelseru/signals.py +39 -1
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/setup.py +1 -1
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/LICENSE +0 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/MANIFEST.in +0 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/README.md +0 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/django_chelseru.egg-info/dependency_links.txt +0 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/django_chelseru.egg-info/requires.txt +0 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/django_chelseru.egg-info/top_level.txt +0 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/drfchelseru/__init__.py +0 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/drfchelseru/apps.py +0 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/drfchelseru/middlewares.py +0 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/drfchelseru/migrations/0001_initial.py +0 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/drfchelseru/migrations/0002_otpcode_session_user.py +0 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/drfchelseru/migrations/0003_rename_mobile_otpcode_mobile_number.py +0 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/drfchelseru/migrations/0004_rename_message_message_sms.py +0 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/drfchelseru/migrations/0005_rename_message_sms_messagesms_chatroom_messagechat.py +0 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/drfchelseru/migrations/0006_alter_chatroom_user_1_alter_chatroom_user_2_and_more.py +0 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/drfchelseru/migrations/__init__.py +0 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/drfchelseru/routing.py +0 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/drfchelseru/serializers.py +0 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/drfchelseru/tests.py +0 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/drfchelseru/urls.py +0 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/drfchelseru/validators.py +0 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/drfchelseru/views.py +0 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/pyproject.toml +0 -0
- {django_chelseru-1.0.3 → django_chelseru-1.0.5}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: django-chelseru
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.5
|
|
4
4
|
Summary: Authentication system, online and real-time chat, SMS system for Iranian SMS services.
|
|
5
5
|
Home-page: https://pipdjango.chelseru.com
|
|
6
6
|
Author: Sobhan Bahman|Rashnu
|
|
@@ -59,9 +59,10 @@ pip install django-chelseru
|
|
|
59
59
|
|
|
60
60
|
INSTALLED_APPS = [
|
|
61
61
|
...
|
|
62
|
-
'
|
|
62
|
+
'channels',
|
|
63
63
|
'rest_framework',
|
|
64
64
|
'rest_framework_simplejwt',
|
|
65
|
+
'drfchelseru',
|
|
65
66
|
...
|
|
66
67
|
]
|
|
67
68
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: django-chelseru
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.5
|
|
4
4
|
Summary: Authentication system, online and real-time chat, SMS system for Iranian SMS services.
|
|
5
5
|
Home-page: https://pipdjango.chelseru.com
|
|
6
6
|
Author: Sobhan Bahman|Rashnu
|
|
@@ -59,9 +59,10 @@ pip install django-chelseru
|
|
|
59
59
|
|
|
60
60
|
INSTALLED_APPS = [
|
|
61
61
|
...
|
|
62
|
-
'
|
|
62
|
+
'channels',
|
|
63
63
|
'rest_framework',
|
|
64
64
|
'rest_framework_simplejwt',
|
|
65
|
+
'drfchelseru',
|
|
65
66
|
...
|
|
66
67
|
]
|
|
67
68
|
|
|
@@ -30,4 +30,9 @@ drfchelseru/migrations/0003_rename_mobile_otpcode_mobile_number.py
|
|
|
30
30
|
drfchelseru/migrations/0004_rename_message_message_sms.py
|
|
31
31
|
drfchelseru/migrations/0005_rename_message_sms_messagesms_chatroom_messagechat.py
|
|
32
32
|
drfchelseru/migrations/0006_alter_chatroom_user_1_alter_chatroom_user_2_and_more.py
|
|
33
|
+
drfchelseru/migrations/0007_chatroom_pinned_for_chatroom_status_chatroom_users_and_more.py
|
|
34
|
+
drfchelseru/migrations/0008_alter_chatroompermissions_user.py
|
|
35
|
+
drfchelseru/migrations/0009_alter_chatroom_status.py
|
|
36
|
+
drfchelseru/migrations/0010_chatroom_banneds_chatroom_descriptions_chatroom_name_and_more.py
|
|
37
|
+
drfchelseru/migrations/0011_alter_chatroom_user_1_alter_chatroom_user_2.py
|
|
33
38
|
drfchelseru/migrations/__init__.py
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from django.contrib import admin
|
|
2
|
-
from .models import User, OTPCode, Session, MessageSMS, ChatRoom, MessageChat
|
|
2
|
+
from .models import User, OTPCode, Session, MessageSMS, ChatRoom, MessageChat, ChatRoomPermissions, Organization
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
@admin.register(User)
|
|
@@ -24,6 +24,10 @@ class MessageAdmin(admin.ModelAdmin):
|
|
|
24
24
|
ordering = ('-created_at', )
|
|
25
25
|
|
|
26
26
|
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
27
30
|
admin.site.register(ChatRoom)
|
|
28
31
|
admin.site.register(MessageChat)
|
|
29
|
-
|
|
32
|
+
admin.site.register(ChatRoomPermissions)
|
|
33
|
+
admin.site.register(Organization)
|
|
@@ -10,6 +10,8 @@ User = get_user_model()
|
|
|
10
10
|
class ChatConsumer(AsyncWebsocketConsumer):
|
|
11
11
|
@sync_to_async
|
|
12
12
|
def is_user_in_chat_room(self, user, chat_room):
|
|
13
|
+
if chat_room.users.filter(user__id=user.id).exists():
|
|
14
|
+
return True
|
|
13
15
|
return user == chat_room.user_1 or user == chat_room.user_2
|
|
14
16
|
|
|
15
17
|
async def connect(self):
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# Generated by Django 5.1.6 on 2025-08-16 09:02
|
|
2
|
+
|
|
3
|
+
import django.db.models.deletion
|
|
4
|
+
import django.utils.timezone
|
|
5
|
+
from django.conf import settings
|
|
6
|
+
from django.db import migrations, models
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Migration(migrations.Migration):
|
|
10
|
+
|
|
11
|
+
dependencies = [
|
|
12
|
+
("drfchelseru", "0006_alter_chatroom_user_1_alter_chatroom_user_2_and_more"),
|
|
13
|
+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
operations = [
|
|
17
|
+
migrations.AddField(
|
|
18
|
+
model_name="chatroom",
|
|
19
|
+
name="pinned_for",
|
|
20
|
+
field=models.ManyToManyField(
|
|
21
|
+
blank=True,
|
|
22
|
+
related_name="pinned_drf_chelseru",
|
|
23
|
+
to=settings.AUTH_USER_MODEL,
|
|
24
|
+
),
|
|
25
|
+
),
|
|
26
|
+
migrations.AddField(
|
|
27
|
+
model_name="chatroom",
|
|
28
|
+
name="status",
|
|
29
|
+
field=models.IntegerField(
|
|
30
|
+
default=1, verbose_name=[(1, "Open"), (2, "Close")]
|
|
31
|
+
),
|
|
32
|
+
),
|
|
33
|
+
migrations.AddField(
|
|
34
|
+
model_name="chatroom",
|
|
35
|
+
name="users",
|
|
36
|
+
field=models.ManyToManyField(
|
|
37
|
+
blank=True,
|
|
38
|
+
related_name="users_drf_chelseru",
|
|
39
|
+
to=settings.AUTH_USER_MODEL,
|
|
40
|
+
),
|
|
41
|
+
),
|
|
42
|
+
migrations.AddField(
|
|
43
|
+
model_name="messagechat",
|
|
44
|
+
name="created_at",
|
|
45
|
+
field=models.DateTimeField(
|
|
46
|
+
auto_now_add=True, default=django.utils.timezone.now
|
|
47
|
+
),
|
|
48
|
+
preserve_default=False,
|
|
49
|
+
),
|
|
50
|
+
migrations.CreateModel(
|
|
51
|
+
name="ChatRoomPermissions",
|
|
52
|
+
fields=[
|
|
53
|
+
(
|
|
54
|
+
"id",
|
|
55
|
+
models.BigAutoField(
|
|
56
|
+
auto_created=True,
|
|
57
|
+
primary_key=True,
|
|
58
|
+
serialize=False,
|
|
59
|
+
verbose_name="ID",
|
|
60
|
+
),
|
|
61
|
+
),
|
|
62
|
+
(
|
|
63
|
+
"access",
|
|
64
|
+
models.IntegerField(
|
|
65
|
+
choices=[
|
|
66
|
+
(0, "Read Only"),
|
|
67
|
+
(1, "Member"),
|
|
68
|
+
(2, "Can Add Members"),
|
|
69
|
+
(3, "Can Kick Members"),
|
|
70
|
+
(4, "Can Ban Members"),
|
|
71
|
+
(5, "Can Add Access"),
|
|
72
|
+
(6, "Can Remove Accessa"),
|
|
73
|
+
(7, "Can Kick Admins"),
|
|
74
|
+
(8, "Can Close Chat Room"),
|
|
75
|
+
(9, "Can ReOpen Chat Room"),
|
|
76
|
+
(10, "Can Rename Chat Room"),
|
|
77
|
+
(11, "Can Update Chatroom Avatar"),
|
|
78
|
+
(12, "Can Delete Chat Room"),
|
|
79
|
+
],
|
|
80
|
+
default=1,
|
|
81
|
+
),
|
|
82
|
+
),
|
|
83
|
+
("user", models.ManyToManyField(to=settings.AUTH_USER_MODEL)),
|
|
84
|
+
],
|
|
85
|
+
),
|
|
86
|
+
migrations.AddField(
|
|
87
|
+
model_name="chatroom",
|
|
88
|
+
name="permissions",
|
|
89
|
+
field=models.ManyToManyField(
|
|
90
|
+
blank=True,
|
|
91
|
+
related_name="permissions_drf_chelseru",
|
|
92
|
+
to="drfchelseru.chatroompermissions",
|
|
93
|
+
),
|
|
94
|
+
),
|
|
95
|
+
migrations.CreateModel(
|
|
96
|
+
name="Organization",
|
|
97
|
+
fields=[
|
|
98
|
+
(
|
|
99
|
+
"id",
|
|
100
|
+
models.BigAutoField(
|
|
101
|
+
auto_created=True,
|
|
102
|
+
primary_key=True,
|
|
103
|
+
serialize=False,
|
|
104
|
+
verbose_name="ID",
|
|
105
|
+
),
|
|
106
|
+
),
|
|
107
|
+
("name", models.CharField(max_length=45)),
|
|
108
|
+
("uname", models.CharField(max_length=45, unique=True)),
|
|
109
|
+
("created_at", models.DateTimeField(auto_now_add=True)),
|
|
110
|
+
(
|
|
111
|
+
"owner",
|
|
112
|
+
models.OneToOneField(
|
|
113
|
+
on_delete=django.db.models.deletion.DO_NOTHING,
|
|
114
|
+
related_name="organization_drf_chelseru",
|
|
115
|
+
to=settings.AUTH_USER_MODEL,
|
|
116
|
+
),
|
|
117
|
+
),
|
|
118
|
+
],
|
|
119
|
+
),
|
|
120
|
+
migrations.AddField(
|
|
121
|
+
model_name="chatroom",
|
|
122
|
+
name="organization",
|
|
123
|
+
field=models.ForeignKey(
|
|
124
|
+
blank=True,
|
|
125
|
+
null=True,
|
|
126
|
+
on_delete=django.db.models.deletion.DO_NOTHING,
|
|
127
|
+
related_name="chatroom_drf_chelseru",
|
|
128
|
+
to="drfchelseru.organization",
|
|
129
|
+
),
|
|
130
|
+
),
|
|
131
|
+
]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Generated by Django 5.1.6 on 2025-08-16 09:02
|
|
2
|
+
|
|
3
|
+
from django.conf import settings
|
|
4
|
+
from django.db import migrations, models
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
|
|
9
|
+
dependencies = [
|
|
10
|
+
(
|
|
11
|
+
"drfchelseru",
|
|
12
|
+
"0007_chatroom_pinned_for_chatroom_status_chatroom_users_and_more",
|
|
13
|
+
),
|
|
14
|
+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
operations = [
|
|
18
|
+
migrations.AlterField(
|
|
19
|
+
model_name="chatroompermissions",
|
|
20
|
+
name="user",
|
|
21
|
+
field=models.ManyToManyField(
|
|
22
|
+
related_name="user_drf_chelseru", to=settings.AUTH_USER_MODEL
|
|
23
|
+
),
|
|
24
|
+
),
|
|
25
|
+
]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Generated by Django 5.1.6 on 2025-08-16 09:26
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
("drfchelseru", "0008_alter_chatroompermissions_user"),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AlterField(
|
|
14
|
+
model_name="chatroom",
|
|
15
|
+
name="status",
|
|
16
|
+
field=models.IntegerField(
|
|
17
|
+
default=1, verbose_name=[(1, "Open"), (2, "Close"), (3, "Hold")]
|
|
18
|
+
),
|
|
19
|
+
),
|
|
20
|
+
]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Generated by Django 5.1.6 on 2025-08-16 09:30
|
|
2
|
+
|
|
3
|
+
from django.conf import settings
|
|
4
|
+
from django.db import migrations, models
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
|
|
9
|
+
dependencies = [
|
|
10
|
+
("drfchelseru", "0009_alter_chatroom_status"),
|
|
11
|
+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
operations = [
|
|
15
|
+
migrations.AddField(
|
|
16
|
+
model_name="chatroom",
|
|
17
|
+
name="banneds",
|
|
18
|
+
field=models.ManyToManyField(
|
|
19
|
+
blank=True,
|
|
20
|
+
related_name="bans_drf_chelseru",
|
|
21
|
+
to=settings.AUTH_USER_MODEL,
|
|
22
|
+
),
|
|
23
|
+
),
|
|
24
|
+
migrations.AddField(
|
|
25
|
+
model_name="chatroom",
|
|
26
|
+
name="descriptions",
|
|
27
|
+
field=models.TextField(blank=True, null=True),
|
|
28
|
+
),
|
|
29
|
+
migrations.AddField(
|
|
30
|
+
model_name="chatroom",
|
|
31
|
+
name="name",
|
|
32
|
+
field=models.CharField(blank=True, max_length=45, null=True),
|
|
33
|
+
),
|
|
34
|
+
migrations.AlterField(
|
|
35
|
+
model_name="chatroom",
|
|
36
|
+
name="status",
|
|
37
|
+
field=models.IntegerField(
|
|
38
|
+
choices=[(1, "Open"), (2, "Close"), (3, "Hold")], default=1
|
|
39
|
+
),
|
|
40
|
+
),
|
|
41
|
+
]
|
django_chelseru-1.0.5/drfchelseru/migrations/0011_alter_chatroom_user_1_alter_chatroom_user_2.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Generated by Django 5.1.6 on 2025-08-16 19:49
|
|
2
|
+
|
|
3
|
+
import django.db.models.deletion
|
|
4
|
+
from django.conf import settings
|
|
5
|
+
from django.db import migrations, models
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Migration(migrations.Migration):
|
|
9
|
+
|
|
10
|
+
dependencies = [
|
|
11
|
+
('drfchelseru', '0010_chatroom_banneds_chatroom_descriptions_chatroom_name_and_more'),
|
|
12
|
+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
operations = [
|
|
16
|
+
migrations.AlterField(
|
|
17
|
+
model_name='chatroom',
|
|
18
|
+
name='user_1',
|
|
19
|
+
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='user1_chats_drf_chelseru', to=settings.AUTH_USER_MODEL),
|
|
20
|
+
),
|
|
21
|
+
migrations.AlterField(
|
|
22
|
+
model_name='chatroom',
|
|
23
|
+
name='user_2',
|
|
24
|
+
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='user2_chats_drf_chelseru', to=settings.AUTH_USER_MODEL),
|
|
25
|
+
),
|
|
26
|
+
]
|
|
@@ -79,10 +79,75 @@ class MessageSMS(models.Model):
|
|
|
79
79
|
return f'to: {self.mobile_number} , at: {self.created_at}'
|
|
80
80
|
|
|
81
81
|
|
|
82
|
+
class Organization(models.Model):
|
|
83
|
+
owner = models.OneToOneField(UserGet, related_name='organization_drf_chelseru', on_delete=models.DO_NOTHING)
|
|
84
|
+
name = models.CharField(max_length=45)
|
|
85
|
+
uname = models.CharField(max_length=45, unique=True)
|
|
86
|
+
created_at = models.DateTimeField(auto_now_add=True)
|
|
87
|
+
|
|
88
|
+
def __str__(self):
|
|
89
|
+
return f'owner: {self.owner} - unique name: {self.uname}'
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class ChatRoomPermissions(models.Model):
|
|
93
|
+
READ_ONLY = 0
|
|
94
|
+
MEMBER = 1
|
|
95
|
+
CAN_ADD_MEMBER = 2
|
|
96
|
+
CAN_KICK_MEMBER = 3
|
|
97
|
+
CAN_BAN_MEMBER = 4
|
|
98
|
+
CAN_ADD_ACCESS = 5
|
|
99
|
+
CAN_REMOVE_ACCESS = 6
|
|
100
|
+
CAN_KICK_ADMIN = 7
|
|
101
|
+
CAN_CLOSE_CHAT = 8
|
|
102
|
+
CAN_REOPEN_CHAT = 9
|
|
103
|
+
CAN_RENAME_CHAT = 10
|
|
104
|
+
CAN_UPDATE_AVATAR = 11
|
|
105
|
+
CAN_DELETE_CHAT = 12
|
|
106
|
+
|
|
107
|
+
ACCESS_CHOICES = [
|
|
108
|
+
(READ_ONLY, 'Read Only'),
|
|
109
|
+
(MEMBER, 'Member'),
|
|
110
|
+
(CAN_ADD_MEMBER, 'Can Add Members'),
|
|
111
|
+
(CAN_KICK_MEMBER, 'Can Kick Members'),
|
|
112
|
+
(CAN_BAN_MEMBER, 'Can Ban Members'),
|
|
113
|
+
(CAN_ADD_ACCESS, 'Can Add Access'),
|
|
114
|
+
(CAN_REMOVE_ACCESS, 'Can Remove Accessa'),
|
|
115
|
+
(CAN_KICK_ADMIN, 'Can Kick Admins'),
|
|
116
|
+
(CAN_CLOSE_CHAT, 'Can Close Chat Room'),
|
|
117
|
+
(CAN_REOPEN_CHAT, 'Can ReOpen Chat Room'),
|
|
118
|
+
(CAN_RENAME_CHAT, 'Can Rename Chat Room'),
|
|
119
|
+
(CAN_UPDATE_AVATAR, 'Can Update Chatroom Avatar'),
|
|
120
|
+
(CAN_DELETE_CHAT, 'Can Delete Chat Room'),
|
|
121
|
+
]
|
|
122
|
+
user = models.ManyToManyField(UserGet, related_name='user_drf_chelseru')
|
|
123
|
+
access = models.IntegerField(choices=ACCESS_CHOICES, default=MEMBER)
|
|
124
|
+
|
|
125
|
+
def __str__(self):
|
|
126
|
+
return f'user: {self.user} - access: {self.access}'
|
|
127
|
+
|
|
82
128
|
|
|
83
129
|
class ChatRoom(models.Model):
|
|
84
|
-
|
|
85
|
-
|
|
130
|
+
STATUS_OPEN = 1
|
|
131
|
+
STATUS_CLOSE = 2
|
|
132
|
+
STATUS_HOLD = 3
|
|
133
|
+
|
|
134
|
+
STATUS_CHOICES = [
|
|
135
|
+
(STATUS_OPEN, 'Open'),
|
|
136
|
+
(STATUS_CLOSE, 'Close'),
|
|
137
|
+
(STATUS_HOLD, 'Hold')
|
|
138
|
+
]
|
|
139
|
+
|
|
140
|
+
user_1 = models.ForeignKey(UserGet, on_delete=models.CASCADE, related_name='user1_chats_drf_chelseru', blank=True, null=True)
|
|
141
|
+
user_2 = models.ForeignKey(UserGet, on_delete=models.CASCADE, related_name='user2_chats_drf_chelseru', blank=True, null=True)
|
|
142
|
+
|
|
143
|
+
users = models.ManyToManyField(UserGet, blank=True, related_name='users_drf_chelseru')
|
|
144
|
+
organization = models.ForeignKey(Organization, on_delete=models.DO_NOTHING, related_name='chatroom_drf_chelseru', blank=True, null=True)
|
|
145
|
+
pinned_for = models.ManyToManyField(UserGet, blank=True, related_name='pinned_drf_chelseru')
|
|
146
|
+
permissions = models.ManyToManyField(ChatRoomPermissions, blank=True, related_name='permissions_drf_chelseru')
|
|
147
|
+
status = models.IntegerField(choices=STATUS_CHOICES, default=STATUS_OPEN)
|
|
148
|
+
banneds = models.ManyToManyField(UserGet, blank=True, related_name='bans_drf_chelseru')
|
|
149
|
+
name = models.CharField(max_length=45, blank=True, null=True)
|
|
150
|
+
descriptions = models.TextField(blank=True, null=True)
|
|
86
151
|
|
|
87
152
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
88
153
|
|
|
@@ -96,5 +161,7 @@ class MessageChat(models.Model):
|
|
|
96
161
|
text = models.TextField()
|
|
97
162
|
timestamp = models.DateTimeField(auto_now_add=True)
|
|
98
163
|
|
|
164
|
+
created_at = models.DateTimeField(auto_now_add=True)
|
|
165
|
+
|
|
99
166
|
def __str__(self):
|
|
100
167
|
return f"iD: {self.id} | Message from {self.sender.username} at {self.timestamp} | Chatroom ID: {self.chat_room.id}"
|
|
@@ -152,7 +152,7 @@ class KavenegarCom:
|
|
|
152
152
|
|
|
153
153
|
|
|
154
154
|
|
|
155
|
-
def send_message(mobile_number, message_text, data, template_id=None):
|
|
155
|
+
def send_message(mobile_number, message_text, data=None, template_id=None):
|
|
156
156
|
try:
|
|
157
157
|
icheck = sms_init_check()
|
|
158
158
|
if not (icheck and isinstance(icheck, dict) and 'SMS_SERVICE' in icheck and 'SETTINGS' in icheck):
|
|
@@ -4,6 +4,16 @@ from django.db.models.signals import post_save, pre_save
|
|
|
4
4
|
from django.dispatch import receiver
|
|
5
5
|
import requests
|
|
6
6
|
|
|
7
|
+
from urllib.parse import parse_qs
|
|
8
|
+
from channels.middleware import BaseMiddleware
|
|
9
|
+
from django.contrib.auth.models import AnonymousUser
|
|
10
|
+
from rest_framework_simplejwt.tokens import AccessToken
|
|
11
|
+
from django.contrib.auth import get_user_model
|
|
12
|
+
from asgiref.sync import sync_to_async
|
|
13
|
+
|
|
14
|
+
UserGet = get_user_model()
|
|
15
|
+
|
|
16
|
+
|
|
7
17
|
# @receiver(post_save, sender=User)
|
|
8
18
|
# def create_user_profile(sender, instance, created, **kwargs):
|
|
9
19
|
# if created:
|
|
@@ -35,4 +45,32 @@ def send_email_after_create(sender, instance, **kwargs):
|
|
|
35
45
|
except:
|
|
36
46
|
pass
|
|
37
47
|
|
|
38
|
-
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@sync_to_async
|
|
54
|
+
def get_user(validated_token):
|
|
55
|
+
try:
|
|
56
|
+
user_id = validated_token["user_id"]
|
|
57
|
+
return UserGet.objects.get(id=user_id)
|
|
58
|
+
except UserGet.DoesNotExist:
|
|
59
|
+
return AnonymousUser()
|
|
60
|
+
|
|
61
|
+
class JWTAuthMiddleware(BaseMiddleware):
|
|
62
|
+
async def __call__(self, scope, receive, send):
|
|
63
|
+
query_string = scope.get("query_string", b"").decode()
|
|
64
|
+
query_params = parse_qs(query_string)
|
|
65
|
+
token = query_params.get("token")
|
|
66
|
+
|
|
67
|
+
if token:
|
|
68
|
+
try:
|
|
69
|
+
access_token = AccessToken(token[0])
|
|
70
|
+
scope["user"] = await get_user(access_token)
|
|
71
|
+
except Exception as e:
|
|
72
|
+
scope["user"] = AnonymousUser()
|
|
73
|
+
else:
|
|
74
|
+
scope["user"] = AnonymousUser()
|
|
75
|
+
|
|
76
|
+
return await super().__call__(scope, receive, send)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_chelseru-1.0.3 → django_chelseru-1.0.5}/django_chelseru.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_chelseru-1.0.3 → django_chelseru-1.0.5}/drfchelseru/migrations/0002_otpcode_session_user.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|