django-chelseru 1.1.7__py3-none-any.whl → 2.0.0__py3-none-any.whl
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-2.0.0.dist-info/METADATA +475 -0
- {django_chelseru-1.1.7.dist-info → django_chelseru-2.0.0.dist-info}/RECORD +17 -12
- drfchelseru/admin.py +2 -1
- drfchelseru/migrations/0018_alter_payment_ref_id.py +18 -0
- drfchelseru/migrations/0019_payment_created_at_payment_status_payment_updated_at.py +30 -0
- drfchelseru/migrations/0020_payment_paid_at.py +18 -0
- drfchelseru/migrations/0021_alter_payment_message.py +18 -0
- drfchelseru/migrations/0022_payment_pay_mode_wallet.py +48 -0
- drfchelseru/models.py +48 -3
- drfchelseru/services.py +226 -27
- drfchelseru/settings.py +2 -1
- drfchelseru/signals.py +16 -13
- drfchelseru/urls.py +4 -1
- drfchelseru/views.py +47 -3
- django_chelseru-1.1.7.dist-info/METADATA +0 -312
- {django_chelseru-1.1.7.dist-info → django_chelseru-2.0.0.dist-info}/WHEEL +0 -0
- {django_chelseru-1.1.7.dist-info → django_chelseru-2.0.0.dist-info}/licenses/LICENSE +0 -0
- {django_chelseru-1.1.7.dist-info → django_chelseru-2.0.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: django-chelseru
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Authentication system, online and real-time chat, SMS & BANK system for Iranian SMS services.
|
|
5
|
+
Home-page: https://pipdjango.chelseru.com
|
|
6
|
+
Author: Sobhan Bahman Rashnu
|
|
7
|
+
Author-email: bahmanrashnu@gmail.com
|
|
8
|
+
Project-URL: Documentation, https://github.com/Chelseru/django-chelseru-lour/
|
|
9
|
+
Project-URL: Telegram Group, https://t.me/bahmanpy
|
|
10
|
+
Project-URL: Telegram Channel, https://t.me/ChelseruCom
|
|
11
|
+
Keywords: djangochelseruchat djangochat drfchat online-chat online real-time chat iran chelseru lor lur bahman rashnu rashno lak lour sms djangoauth auth ywt otpauth otp authentication djangootp djangoiransms iransms djangosms djangokavenegar djangomelipayamak sobhan چت سبحان بهمن رشنو چلسرو جنگو پایتون لر لور آنلاین ریل تایم
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Framework :: Django
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Requires-Python: >=3.11
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: Django>=5.1.6
|
|
20
|
+
Requires-Dist: djangorestframework==3.15.2
|
|
21
|
+
Requires-Dist: djangorestframework_simplejwt==5.5.0
|
|
22
|
+
Requires-Dist: channels==4.2.2
|
|
23
|
+
Requires-Dist: channels_redis==4.2.1
|
|
24
|
+
Requires-Dist: daphne==4.1.2
|
|
25
|
+
Requires-Dist: zeep==4.3.1
|
|
26
|
+
Requires-Dist: user-agents==2.2.0
|
|
27
|
+
Dynamic: author
|
|
28
|
+
Dynamic: author-email
|
|
29
|
+
Dynamic: classifier
|
|
30
|
+
Dynamic: description
|
|
31
|
+
Dynamic: description-content-type
|
|
32
|
+
Dynamic: home-page
|
|
33
|
+
Dynamic: keywords
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
Dynamic: project-url
|
|
36
|
+
Dynamic: requires-dist
|
|
37
|
+
Dynamic: requires-python
|
|
38
|
+
Dynamic: summary
|
|
39
|
+
|
|
40
|
+
# django-chelseru Django Package
|
|
41
|
+
|
|
42
|
+
## Overview
|
|
43
|
+
|
|
44
|
+
django-chelseru is a Django package developed by Sobhan Bahman Rashnu for real-time chatting via WebSocket, OTP-based SMS verification, and SMS sending with Iranian providers. It also supports payment integrations.
|
|
45
|
+
|
|
46
|
+
Useful for building applications requiring secure authentication, messaging, real-time chat, and online payments.
|
|
47
|
+
|
|
48
|
+
## Features
|
|
49
|
+
|
|
50
|
+
- **Authentication**: OTP and PASSWD methods using rest_framework_simplejwt.
|
|
51
|
+
- **SMS Services**: PARSIAN_WEBCO_IR, MELI_PAYAMAK_COM, KAVENEGAR_COM.
|
|
52
|
+
- **Payment Gateways**: PAYPING_IR, ZARINPAL_COM.
|
|
53
|
+
- **Real-time Chat**: WebSocket/Channels for messaging.
|
|
54
|
+
- Session management and API endpoints for OTP, authentication, SMS, payments, and chat.
|
|
55
|
+
|
|
56
|
+
## Requirements
|
|
57
|
+
|
|
58
|
+
- Python 3.8+
|
|
59
|
+
- Django 4.x
|
|
60
|
+
- django-rest-framework
|
|
61
|
+
- djangorestframework-simplejwt
|
|
62
|
+
- django-channels
|
|
63
|
+
- user-agents
|
|
64
|
+
- requests
|
|
65
|
+
- Other dependencies: See `requirements.txt`
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
|
|
69
|
+
1. Install the package:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pip install django-chelseru
|
|
73
|
+
```
|
|
74
|
+
2. Add to `INSTALLED_APPS` in `settings.py`:
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
INSTALLED_APPS = [
|
|
78
|
+
...
|
|
79
|
+
'rest_framework',
|
|
80
|
+
'rest_framework_simplejwt',
|
|
81
|
+
'channels',
|
|
82
|
+
'drfchelseru',
|
|
83
|
+
]
|
|
84
|
+
```
|
|
85
|
+
3. Configure middleware and ASGI in `settings.py`.
|
|
86
|
+
4. Apply migrations:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
python manage.py makemigrations
|
|
90
|
+
python manage.py migrate
|
|
91
|
+
```
|
|
92
|
+
5. Run the server (use ASGI for WebSocket):
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
daphne -b 0.0.0.0 -p 8000 project.asgi:application
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Project Structure
|
|
99
|
+
|
|
100
|
+
- **models.py**: Defines models for users, OTP codes, sessions, SMS messages, organizations, chat rooms, chat permissions, messages, wallets, and payments.
|
|
101
|
+
- **views.py**: Handles API endpoints for OTP authentication, SMS, payments, and chat.
|
|
102
|
+
- **urls.py**: Maps URL patterns to views for API routes.
|
|
103
|
+
- **consumers.py**: Implements WebSocket consumer for real-time chat.
|
|
104
|
+
- **middlewares.py**: Includes `TakeUserSessionMiddlaware` for session management and `JWTAuthMiddleware` for WebSocket authentication.
|
|
105
|
+
|
|
106
|
+
## Models
|
|
107
|
+
|
|
108
|
+
- **User**: Extends Django's User model with mobile number and group.
|
|
109
|
+
- **OTPCode**: Stores OTP codes for authentication with expiration logic.
|
|
110
|
+
- **Session**: Tracks user sessions with IP, device, and browser info.
|
|
111
|
+
- **MessageSMS**: Logs SMS messages sent to users.
|
|
112
|
+
- **Organization**: Represents organizations owned by users.
|
|
113
|
+
- **ChatRoomPermissions**: Defines access levels for chat room actions.
|
|
114
|
+
- **ChatRoom**: Manages chat rooms with users, status, and permissions.
|
|
115
|
+
- **MessageChat**: Stores chat messages with sender and timestamp.
|
|
116
|
+
- **Wallet**: Tracks user wallet balances for payments.
|
|
117
|
+
- **Payment**: Manages payment transactions with gateway integration.
|
|
118
|
+
|
|
119
|
+
## Configuration
|
|
120
|
+
|
|
121
|
+
Update your Django `settings.py`:
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
MIDDLEWARE = [
|
|
125
|
+
...
|
|
126
|
+
'drfchelseru.middlewares.TakeUserSessionMiddlaware',
|
|
127
|
+
]
|
|
128
|
+
|
|
129
|
+
ASGI_APPLICATION = 'yourproject.asgi.application'
|
|
130
|
+
|
|
131
|
+
CHANNEL_LAYERS = {
|
|
132
|
+
'default': {
|
|
133
|
+
'BACKEND': 'channels_redis.core.RedisChannelLayer',
|
|
134
|
+
'CONFIG': {
|
|
135
|
+
'hosts': [('127.0.0.1', 6379)],
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
DJANGO_CHELSERU = {
|
|
141
|
+
'AUTH': {
|
|
142
|
+
'AUTH_METHOD': 'OTP',
|
|
143
|
+
'AUTH_SERVICE': 'rest_framework_simplejwt',
|
|
144
|
+
'OPTIONS': {
|
|
145
|
+
'OTP_LENGTH': 8,
|
|
146
|
+
'OTP_EXPIRE_PER_MINUTES': 4,
|
|
147
|
+
'OTP_SMS_TEMPLATE_ID': 5,
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
'SMS': {
|
|
151
|
+
'SMS_SERVICE': 'PARSIAN_WEBCO_IR',
|
|
152
|
+
'SETTINGS': {
|
|
153
|
+
'PARSIAN_WEBCO_IR_API_KEY': '',
|
|
154
|
+
'MELI_PAYAMAK_COM_USERNAME': '',
|
|
155
|
+
'MELI_PAYAMAK_COM_PASSWORD': '',
|
|
156
|
+
'MELI_PAYAMAK_COM_FROM': '',
|
|
157
|
+
'KAVENEGAR_COM_API_KEY': '',
|
|
158
|
+
'KAVENEGAR_COM_FROM': '',
|
|
159
|
+
},
|
|
160
|
+
'TEMPLATES': {
|
|
161
|
+
'T1': 1,
|
|
162
|
+
'T2': 2,
|
|
163
|
+
'T3': 3,
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
'BANK': {
|
|
167
|
+
'GATEWAY': 'PAYPING_IR',
|
|
168
|
+
'SETTINGS': {
|
|
169
|
+
'MERCHANT_ID': '',
|
|
170
|
+
'CALLBACK_URL': '',
|
|
171
|
+
'CURRENCY': 'IRT'
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## API Endpoints
|
|
178
|
+
|
|
179
|
+
- **POST /drfchelseru/message/send/**: Send SMS.
|
|
180
|
+
|
|
181
|
+
- Request: `{ "mobile_number": "09211892425", "message_text": "Hello", "template_id": 1 }`
|
|
182
|
+
- Response: `{ "details": "The Message was sent correctly." }` (200 OK)
|
|
183
|
+
|
|
184
|
+
- **POST /drfchelseru/otp/send/**: Request OTP code.
|
|
185
|
+
|
|
186
|
+
- Request: `{ "mobile_number": "09211892425" }`
|
|
187
|
+
- Response: `{ "details": "The OTP code was sent correctly." }` (200 OK)
|
|
188
|
+
|
|
189
|
+
- **POST /drfchelseru/authenticate/**: Authenticate with OTP.
|
|
190
|
+
|
|
191
|
+
- Request: `{ "mobile_number": "09211892425", "code": "652479", "group": 0 }`
|
|
192
|
+
- Response: `{ "access": "<access_token>", "refresh": "<refresh_token>" }` (200 OK)
|
|
193
|
+
|
|
194
|
+
- **GET /drfchelseru/sessions/**: List user sessions (authenticated users only).
|
|
195
|
+
|
|
196
|
+
- Headers: `Authorization: Bearer <access_token>`
|
|
197
|
+
- Response: List of sessions (200 OK)
|
|
198
|
+
|
|
199
|
+
- **POST /drfchelseru/payment/create/**: Initiate payment.
|
|
200
|
+
|
|
201
|
+
- Request: `{ "order_id": "123", "amount": 1000.0, "description": "Test payment", "callback_url": "http://example.com/callback", "mobile": "09211892425", "email": "user@example.com", "currency": "IRT" }`
|
|
202
|
+
- Response: `{ "details": { "gateway_url": "<url>", ... } }` (200 OK)
|
|
203
|
+
|
|
204
|
+
- **GET/POST /drfchelseru/payment/verify/**: Verify payment.
|
|
205
|
+
|
|
206
|
+
- GET Query: `?Authority=<authority>&Status=OK`
|
|
207
|
+
- POST Body: `{ "paymentCode": "<code>", "paymentRefId": "<refid>", ... }`
|
|
208
|
+
- Response: `{ "details": { "is_pay": 1, ... } }` (200 OK)
|
|
209
|
+
|
|
210
|
+
- **/drfchelseru/chat/chatrooms/**: CRUD for chat rooms (authenticated users only).
|
|
211
|
+
|
|
212
|
+
- POST Request: `{ "user": 2 }` (to create room with user ID 2)
|
|
213
|
+
- Headers: `Authorization: Bearer <access_token>`
|
|
214
|
+
- Response: Chat room details (201 Created)
|
|
215
|
+
|
|
216
|
+
- **/drfchelseru/chat/messages/**: CRUD for chat messages (authenticated users only).
|
|
217
|
+
|
|
218
|
+
- POST Request: `{ "chat_room": 1, "text": "Hello" }`
|
|
219
|
+
- GET Query: `?chat_room=1`
|
|
220
|
+
- Headers: `Authorization: Bearer <access_token>`
|
|
221
|
+
- Response: Message details or list (200 OK / 201 Created)
|
|
222
|
+
|
|
223
|
+
## WebSocket Usage
|
|
224
|
+
|
|
225
|
+
- Connect to a chat room for real-time messaging:
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
wscat -c wss://<your-domain>/drfchelseru/chat/<chat_room_id>/?token=<jwt_token>
|
|
229
|
+
```
|
|
230
|
+
- Example token: `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzYxMDE5NTY3LCJpYXQiOjE3NTU4MzU1NjcsImp0aSI6IjhhYTY1Y2I3ZDhmMjRmMzliYjFmNDFkZmJiYjcyYmVmIiwidXNlcl9pZCI6Mzl9.mHmIjbTl3X1cd3Ky5HFCD6gy4kGxMVcActo9JXtT9JQ`
|
|
231
|
+
- Replace `<chat_room_id>` (e.g., 17) with the desired room ID and provide a valid JWT token.
|
|
232
|
+
|
|
233
|
+
## Middleware
|
|
234
|
+
|
|
235
|
+
- **TakeUserSessionMiddlaware**: Logs user session data (IP, user agent, device, browser) for HTTP requests.
|
|
236
|
+
- **JWTAuthMiddleware**: Authenticates WebSocket connections using JWT tokens.
|
|
237
|
+
|
|
238
|
+
## Usage
|
|
239
|
+
|
|
240
|
+
- Access the API at `http://<your-domain>/drfchelseru/`.
|
|
241
|
+
- Connect to WebSocket at `ws://<your-domain>/drfchelseru/chat/<chat_room_id>/?token=<jwt_token>`.
|
|
242
|
+
- Admin panel: Create a superuser with `python manage.py createsuperuser`.
|
|
243
|
+
|
|
244
|
+
## Contributing
|
|
245
|
+
|
|
246
|
+
1. Fork the repository.
|
|
247
|
+
2. Create a new branch (`git checkout -b feature-branch`).
|
|
248
|
+
3. Commit your changes (`git commit -m "Add feature"`).
|
|
249
|
+
4. Push to the branch (`git push origin feature-branch`).
|
|
250
|
+
5. Open a pull request.
|
|
251
|
+
|
|
252
|
+
## License
|
|
253
|
+
|
|
254
|
+
MIT License
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
_______________________________________________________________________________________________________________________
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
# django-chelseru پکیج جنگو
|
|
262
|
+
|
|
263
|
+
## بررسی اجمالی
|
|
264
|
+
|
|
265
|
+
django-chelseru یک پکیج جنگو است که توسط سبحان بهمن رشنو توسعه یافته برای گفتگوهای همزمان از راه وبسوکت، تایید پیامکی بر پایه OTP، و فرستادن پیامک با فراهمکنندگان ایرانی. همچنین از یکپارچگی پرداخت پشتیبانی میکند.
|
|
266
|
+
|
|
267
|
+
کاربردی برای ساخت برنامههایی که نیاز به تایید امن، پیامرسانی، گفتگو همزمان، و پرداخت برخط دارند.
|
|
268
|
+
|
|
269
|
+
## ویژگیها
|
|
270
|
+
|
|
271
|
+
- **تایید**: روشهای OTP و PASSWD با بهرهگیری از rest_framework_simplejwt.
|
|
272
|
+
- **خدمات پیامک**: PARSIAN_WEBCO_IR، MELI_PAYAMAK_COM، KAVENEGAR_COM.
|
|
273
|
+
- **درگاههای پرداخت**: PAYPING_IR، ZARINPAL_COM.
|
|
274
|
+
- **گفتگو همزمان**: وبسوکت/کانالها برای پیامرسانی.
|
|
275
|
+
- مدیریت نشست و نقاط پایانی API برای OTP، تایید، پیامک، پرداختها، و گفتگو.
|
|
276
|
+
|
|
277
|
+
## نیازمندیها
|
|
278
|
+
|
|
279
|
+
- Python 3.8+
|
|
280
|
+
- Django 4.x
|
|
281
|
+
- django-rest-framework
|
|
282
|
+
- djangorestframework-simplejwt
|
|
283
|
+
- django-channels
|
|
284
|
+
- user-agents
|
|
285
|
+
- requests
|
|
286
|
+
- دیگر وابستگیها: ببینید `requirements.txt`
|
|
287
|
+
|
|
288
|
+
## نصب
|
|
289
|
+
|
|
290
|
+
1. پکیج را نصب کنید:
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
pip install django-chelseru
|
|
294
|
+
```
|
|
295
|
+
2. به `INSTALLED_APPS` در `settings.py` بیفزایید:
|
|
296
|
+
|
|
297
|
+
```python
|
|
298
|
+
INSTALLED_APPS = [
|
|
299
|
+
...
|
|
300
|
+
'rest_framework',
|
|
301
|
+
'rest_framework_simplejwt',
|
|
302
|
+
'channels',
|
|
303
|
+
'drfchelseru',
|
|
304
|
+
]
|
|
305
|
+
```
|
|
306
|
+
3. میانگیر و ASGI را در `settings.py` پیکربندی کنید.
|
|
307
|
+
4. مهاجرتها را اعمال کنید:
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
python manage.py makemigrations
|
|
311
|
+
python manage.py migrate
|
|
312
|
+
```
|
|
313
|
+
5. کارساز را اجرا کنید (برای وبسوکت از ASGI بهره ببرید):
|
|
314
|
+
|
|
315
|
+
```bash
|
|
316
|
+
daphne -b 0.0.0.0 -p 8000 project.asgi:application
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
## ساختار پروژه
|
|
320
|
+
|
|
321
|
+
- **models.py**: مدلها را برای کاربران، کدهای OTP، نشستها، پیامکها، سازمانها، اتاقهای گفتگو، دسترسیهای اتاق گفتگو، پیامها، کیفپولها، و پرداختها تعریف میکند.
|
|
322
|
+
- **views.py**: نقاط پایانی API برای تایید OTP، پیامک، پرداختها، و گفتگو را مدیریت میکند.
|
|
323
|
+
- **urls.py**: الگوهای URL را به نماها برای مسیرهای API نگاشت میکند.
|
|
324
|
+
- **consumers.py**: مصرفکننده وبسوکت را برای گفتگو همزمان پیادهسازی میکند.
|
|
325
|
+
- **middlewares.py**: شامل `TakeUserSessionMiddlaware` برای مدیریت نشست و `JWTAuthMiddleware` برای تایید وبسوکت.
|
|
326
|
+
|
|
327
|
+
## مدلها
|
|
328
|
+
|
|
329
|
+
- **User**: مدل کاربر جنگو را با شماره همراه و گروه گسترش میدهد.
|
|
330
|
+
- **OTPCode**: کدهای OTP را برای تایید با منطق انقضا ذخیره میکند.
|
|
331
|
+
- **Session**: نشستهای کاربر را با IP، دستگاه، و دادههای مرورگر پیگیری میکند.
|
|
332
|
+
- **MessageSMS**: پیامکهای فرستادهشده به کاربران را ثبت میکند.
|
|
333
|
+
- **Organization**: سازمانهایی را که مالک کاربران هستند نشان میدهد.
|
|
334
|
+
- **ChatRoomPermissions**: سطوح دسترسی برای کارهای اتاق گفتگو را تعریف میکند.
|
|
335
|
+
- **ChatRoom**: اتاقهای گفتگو را با کاربران، وضعیت، و دسترسیها مدیریت میکند.
|
|
336
|
+
- **MessageChat**: پیامهای گفتگو را با فرستنده و زماننگار ذخیره میکند.
|
|
337
|
+
- **Wallet**: مانده کیفپول کاربران را برای پرداختها پیگیری میکند.
|
|
338
|
+
- **Payment**: تراکنشهای پرداخت را با یکپارچگی درگاه مدیریت میکند.
|
|
339
|
+
|
|
340
|
+
## پیکربندی
|
|
341
|
+
|
|
342
|
+
`settings.py` جنگو را بهروزرسانی کنید:
|
|
343
|
+
|
|
344
|
+
```python
|
|
345
|
+
MIDDLEWARE = [
|
|
346
|
+
...
|
|
347
|
+
'drfchelseru.middlewares.TakeUserSessionMiddlaware',
|
|
348
|
+
]
|
|
349
|
+
|
|
350
|
+
ASGI_APPLICATION = 'yourproject.asgi.application'
|
|
351
|
+
|
|
352
|
+
CHANNEL_LAYERS = {
|
|
353
|
+
'default': {
|
|
354
|
+
'BACKEND': 'channels_redis.core.RedisChannelLayer',
|
|
355
|
+
'CONFIG': {
|
|
356
|
+
'hosts': [('127.0.0.1', 6379)],
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
DJANGO_CHELSERU = {
|
|
362
|
+
'AUTH': {
|
|
363
|
+
'AUTH_METHOD': 'OTP',
|
|
364
|
+
'AUTH_SERVICE': 'rest_framework_simplejwt',
|
|
365
|
+
'OPTIONS': {
|
|
366
|
+
'OTP_LENGTH': 8,
|
|
367
|
+
'OTP_EXPIRE_PER_MINUTES': 4,
|
|
368
|
+
'OTP_SMS_TEMPLATE_ID': 5,
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
'SMS': {
|
|
372
|
+
'SMS_SERVICE': 'PARSIAN_WEBCO_IR',
|
|
373
|
+
'SETTINGS': {
|
|
374
|
+
'PARSIAN_WEBCO_IR_API_KEY': '',
|
|
375
|
+
'MELI_PAYAMAK_COM_USERNAME': '',
|
|
376
|
+
'MELI_PAYAMAK_COM_PASSWORD': '',
|
|
377
|
+
'MELI_PAYAMAK_COM_FROM': '',
|
|
378
|
+
'KAVENEGAR_COM_API_KEY': '',
|
|
379
|
+
'KAVENEGAR_COM_FROM': '',
|
|
380
|
+
},
|
|
381
|
+
'TEMPLATES': {
|
|
382
|
+
'T1': 1,
|
|
383
|
+
'T2': 2,
|
|
384
|
+
'T3': 3,
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
'BANK': {
|
|
388
|
+
'GATEWAY': 'PAYPING_IR',
|
|
389
|
+
'SETTINGS': {
|
|
390
|
+
'MERCHANT_ID': '',
|
|
391
|
+
'CALLBACK_URL': '',
|
|
392
|
+
'CURRENCY': 'IRT'
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
## نقاط پایانی API
|
|
399
|
+
|
|
400
|
+
- **POST /drfchelseru/message/send/**: فرستادن پیامک.
|
|
401
|
+
|
|
402
|
+
- درخواست: `{ "mobile_number": "09211892425", "message_text": "Hello", "template_id": 1 }`
|
|
403
|
+
- پاسخ: `{ "details": "The Message was sent correctly." }` (200 OK)
|
|
404
|
+
|
|
405
|
+
- **POST /drfchelseru/otp/send/**: درخواست کد OTP.
|
|
406
|
+
|
|
407
|
+
- درخواست: `{ "mobile_number": "09211892425" }`
|
|
408
|
+
- پاسخ: `{ "details": "The OTP code was sent correctly." }` (200 OK)
|
|
409
|
+
|
|
410
|
+
- **POST /drfchelseru/authenticate/**: تایید با OTP.
|
|
411
|
+
|
|
412
|
+
- درخواست: `{ "mobile_number": "09211892425", "code": "652479", "group": 0 }`
|
|
413
|
+
- پاسخ: `{ "access": "<access_token>", "refresh": "<refresh_token>" }` (200 OK)
|
|
414
|
+
|
|
415
|
+
- **GET /drfchelseru/sessions/**: فهرست نشستهای کاربر (فقط کاربران تاییدشده).
|
|
416
|
+
|
|
417
|
+
- سرآیندها: `Authorization: Bearer <access_token>`
|
|
418
|
+
- پاسخ: فهرست نشستها (200 OK)
|
|
419
|
+
|
|
420
|
+
- **POST /drfchelseru/payment/create/**: آغاز پرداخت.
|
|
421
|
+
|
|
422
|
+
- درخواست: `{ "order_id": "123", "amount": 1000.0, "description": "Test payment", "callback_url": "http://example.com/callback", "mobile": "09211892425", "email": "user@example.com", "currency": "IRT" }`
|
|
423
|
+
- پاسخ: `{ "details": { "gateway_url": "<url>", ... } }` (200 OK)
|
|
424
|
+
|
|
425
|
+
- **GET/POST /drfchelseru/payment/verify/**: تایید پرداخت.
|
|
426
|
+
|
|
427
|
+
- جستجوی GET: `?Authority=<authority>&Status=OK`
|
|
428
|
+
- بدنه POST: `{ "paymentCode": "<code>", "paymentRefId": "<refid>", ... }`
|
|
429
|
+
- پاسخ: `{ "details": { "is_pay": 1, ... } }` (200 OK)
|
|
430
|
+
|
|
431
|
+
- **/drfchelseru/chat/chatrooms/**: CRUD برای اتاقهای گفتگو (فقط کاربران تاییدشده).
|
|
432
|
+
|
|
433
|
+
- درخواست POST: `{ "user": 2 }` (برای ساخت اتاق با شناسه کاربر 2)
|
|
434
|
+
- سرآیندها: `Authorization: Bearer <access_token>`
|
|
435
|
+
- پاسخ: جزئیات اتاق گفتگو (201 Created)
|
|
436
|
+
|
|
437
|
+
- **/drfchelseru/chat/messages/**: CRUD برای پیامهای گفتگو (فقط کاربران تاییدشده).
|
|
438
|
+
|
|
439
|
+
- درخواست POST: `{ "chat_room": 1, "text": "Hello" }`
|
|
440
|
+
- جستجوی GET: `?chat_room=1`
|
|
441
|
+
- سرآیندها: `Authorization: Bearer <access_token>`
|
|
442
|
+
- پاسخ: جزئیات پیام یا فهرست (200 OK / 201 Created)
|
|
443
|
+
|
|
444
|
+
## بهرهگیری از وبسوکت
|
|
445
|
+
|
|
446
|
+
- پیوستن به اتاق گفتگو برای پیامرسانی همزمان:
|
|
447
|
+
|
|
448
|
+
```bash
|
|
449
|
+
wscat -c wss://<your-domain>/drfchelseru/chat/<chat_room_id>/?token=<jwt_token>
|
|
450
|
+
```
|
|
451
|
+
- نمونه نشانه: `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzYxMDE5NTY3LCJpYXQiOjE3NTU4MzU1NjcsImp0aSI6IjhhYTY1Y2I3ZDhmMjRmMzliYjFmNDFkZmJiYjcyYmVmIiwidXNlcl9pZCI6Mzl9.mHmIjbTl3X1cd3Ky5HFCD6gy4kGxMVcActo9JXtT9JQ`
|
|
452
|
+
- <chat_room_id> (مانند 17) را با شناسه اتاق دلخواه جایگزین کنید و نشانه JWT معتبر فراهم کنید.
|
|
453
|
+
|
|
454
|
+
## میانگیرها
|
|
455
|
+
|
|
456
|
+
- **TakeUserSessionMiddlaware**: دادههای نشست کاربر (IP، عامل کاربر، دستگاه، مرورگر) را برای درخواستهای HTTP ثبت میکند.
|
|
457
|
+
- **JWTAuthMiddleware**: اتصالهای وبسوکت را با نشانههای JWT تایید میکند.
|
|
458
|
+
|
|
459
|
+
## بهرهگیری
|
|
460
|
+
|
|
461
|
+
- به API در `http://<your-domain>/drfchelseru/` دسترسی یابید.
|
|
462
|
+
- به وبسوکت در `ws://<your-domain>/drfchelseru/chat/<chat_room_id>/?token=<jwt_token>` وصل شوید.
|
|
463
|
+
- پنل مدیر: ابرکاربر را با `python manage.py createsuperuser` بسازید.
|
|
464
|
+
|
|
465
|
+
## همکاری
|
|
466
|
+
|
|
467
|
+
1. مخزن را فورک کنید.
|
|
468
|
+
2. شاخه نو بسازید (`git checkout -b feature-branch`).
|
|
469
|
+
3. تغییرات را کامیت کنید (`git commit -m "Add feature"`).
|
|
470
|
+
4. به شاخه بفرستید (`git push origin feature-branch`).
|
|
471
|
+
5. درخواست کشیدن باز کنید.
|
|
472
|
+
|
|
473
|
+
## پروانه
|
|
474
|
+
|
|
475
|
+
MIT License
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
django_chelseru-
|
|
1
|
+
django_chelseru-2.0.0.dist-info/licenses/LICENSE,sha256=VupU5KV4NteHaNQb-WH31G_WZWezxXoomjiCIAHoQJo,1089
|
|
2
2
|
drfchelseru/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
drfchelseru/admin.py,sha256=
|
|
3
|
+
drfchelseru/admin.py,sha256=uamcWPCCw9_dD00XL8Brp8A1NvfhB5FtUfF9DWQCK9c,1022
|
|
4
4
|
drfchelseru/apps.py,sha256=hOTTzFGLXiTPZeN8p_LLcSECLtsR2Q0SUo8zJzgM-qQ,211
|
|
5
5
|
drfchelseru/consumers.py,sha256=c8h9JYu5QUSKRREFrIrkjpkEQTzG5V8eg2lriaZODsc,2614
|
|
6
6
|
drfchelseru/middlewares.py,sha256=Ej_9GTlVPzfzYAUqxUn7VHJRdlywQmrbSIW43yK5q5U,3818
|
|
7
|
-
drfchelseru/models.py,sha256=
|
|
7
|
+
drfchelseru/models.py,sha256=jQ5IbS5q4GufZC9W_zgX1Qg8YU_f8V-Jusbh5hQYPhQ,11214
|
|
8
8
|
drfchelseru/routing.py,sha256=shAlgzcIwVuVPlvKeWBLCqr6PuBTHyIrWNgHEfnqrxg,165
|
|
9
9
|
drfchelseru/serializers.py,sha256=I3kS2NhzIprY8-WWhjQPShAom6R7epg7do7RnDkpnys,1421
|
|
10
|
-
drfchelseru/services.py,sha256=
|
|
11
|
-
drfchelseru/settings.py,sha256=
|
|
12
|
-
drfchelseru/signals.py,sha256=
|
|
10
|
+
drfchelseru/services.py,sha256=9sHlY-_Prd1Wl1WTddT-e1nE7rYKlDjFaYl6FGjwvTA,27142
|
|
11
|
+
drfchelseru/settings.py,sha256=zzOKwaciRMOhf5tQM4jAT4_80nggTwl_HqCby7TCUaE,11385
|
|
12
|
+
drfchelseru/signals.py,sha256=CI1mZR5RrdOddXBnPC1eMdt9iQkYFDypfgogtfTc2eQ,2714
|
|
13
13
|
drfchelseru/tests.py,sha256=mrbGGRNg5jwbTJtWWa7zSKdDyeB4vmgZCRc2nk6VY-g,60
|
|
14
|
-
drfchelseru/urls.py,sha256=
|
|
14
|
+
drfchelseru/urls.py,sha256=qD3As2gSCEaNDxgU0ejIADLUt9t2EvoaTmqeiV1LRSA,898
|
|
15
15
|
drfchelseru/validators.py,sha256=jAJASfG4kPcqrGxxIcoR8VjS4L4n_EzZuxJtQ1g9qmo,480
|
|
16
|
-
drfchelseru/views.py,sha256=
|
|
16
|
+
drfchelseru/views.py,sha256=shi3cd19Zxk-nCFr-cK40PtArS3Howu7d6t7x_dxFlE,18079
|
|
17
17
|
drfchelseru/migrations/0001_initial.py,sha256=LfkWAeQuPXNW3_igM-w_pyKafCeHQF3aReYgMXfMzEE,1034
|
|
18
18
|
drfchelseru/migrations/0002_otpcode_session_user.py,sha256=c3oyBTQo2kjsKr5r_XQrqaq-66F7pui-4H4mEyAXgJk,3126
|
|
19
19
|
drfchelseru/migrations/0003_rename_mobile_otpcode_mobile_number.py,sha256=eiD7t6etg6nOeT7BhJrSfEcR1yTPePXtATgtyu30520,377
|
|
@@ -31,8 +31,13 @@ drfchelseru/migrations/0014_payment_gateway_title_payment_gateway_url.py,sha256=
|
|
|
31
31
|
drfchelseru/migrations/0015_payment_message.py,sha256=7aysohtF5ajAGFB88IRIy4nRagSi6GOIkQb9sTZp91o,436
|
|
32
32
|
drfchelseru/migrations/0016_payment_card_hash_payment_card_pan_and_more.py,sha256=bRGD0ZMJWW3R_c3mFAHsTMC8am2Xymh-48XRPVKmgvc,887
|
|
33
33
|
drfchelseru/migrations/0017_alter_payment_callback_url_alter_payment_gateway_url.py,sha256=CzlVrPM3L7Iv1lgjM6-MSBdw38y5uaBH9Oc6PCSImCQ,574
|
|
34
|
+
drfchelseru/migrations/0018_alter_payment_ref_id.py,sha256=qNFvyHMmEOoJ_MYBVunokUCcOaX2xj9ammg65P9xaIA,439
|
|
35
|
+
drfchelseru/migrations/0019_payment_created_at_payment_status_payment_updated_at.py,sha256=jaQUgX0lnyrZqhSMwJ-UEc5NDJ-skS8D1T4P3VHlvCE,937
|
|
36
|
+
drfchelseru/migrations/0020_payment_paid_at.py,sha256=H6cr-tfjJVjN3tCsCD8ecg9JGJpLVWOXzqTp5hpnolY,432
|
|
37
|
+
drfchelseru/migrations/0021_alter_payment_message.py,sha256=g5qIvQ-wecdXGcMf7ZhyfL2u85QpgMUOADHE7t4QHog,397
|
|
38
|
+
drfchelseru/migrations/0022_payment_pay_mode_wallet.py,sha256=241lZITO1jQHqXkJKYm8DKUh7w9rmROh65LzNifP3BA,1521
|
|
34
39
|
drfchelseru/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
35
|
-
django_chelseru-
|
|
36
|
-
django_chelseru-
|
|
37
|
-
django_chelseru-
|
|
38
|
-
django_chelseru-
|
|
40
|
+
django_chelseru-2.0.0.dist-info/METADATA,sha256=EObLgGe6BtL_uteht0I9gkfDai8YPHmlsTKDhm4ea2Y,18242
|
|
41
|
+
django_chelseru-2.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
42
|
+
django_chelseru-2.0.0.dist-info/top_level.txt,sha256=fsaO1F03W3j4AYi0TfDGv5Cjb_Qrh6RSkwkWqfqaMns,12
|
|
43
|
+
django_chelseru-2.0.0.dist-info/RECORD,,
|
drfchelseru/admin.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from django.contrib import admin
|
|
2
|
-
from .models import User, OTPCode, Session, MessageSMS, ChatRoom, MessageChat, ChatRoomPermissions, Organization, Payment
|
|
2
|
+
from .models import User, OTPCode, Session, MessageSMS, ChatRoom, MessageChat, ChatRoomPermissions, Organization, Payment, Wallet
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
@admin.register(User)
|
|
@@ -32,3 +32,4 @@ admin.site.register(MessageChat)
|
|
|
32
32
|
admin.site.register(ChatRoomPermissions)
|
|
33
33
|
admin.site.register(Organization)
|
|
34
34
|
admin.site.register(Payment)
|
|
35
|
+
admin.site.register(Wallet)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Generated by Django 5.1.6 on 2025-08-28 09:21
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
("drfchelseru", "0017_alter_payment_callback_url_alter_payment_gateway_url"),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AlterField(
|
|
14
|
+
model_name="payment",
|
|
15
|
+
name="ref_id",
|
|
16
|
+
field=models.BigIntegerField(blank=True, null=True),
|
|
17
|
+
),
|
|
18
|
+
]
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Generated by Django 5.1.6 on 2025-08-28 20:03
|
|
2
|
+
|
|
3
|
+
import django.utils.timezone
|
|
4
|
+
from django.db import migrations, models
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
|
|
9
|
+
dependencies = [
|
|
10
|
+
('drfchelseru', '0018_alter_payment_ref_id'),
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
operations = [
|
|
14
|
+
migrations.AddField(
|
|
15
|
+
model_name='payment',
|
|
16
|
+
name='created_at',
|
|
17
|
+
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
|
18
|
+
preserve_default=False,
|
|
19
|
+
),
|
|
20
|
+
migrations.AddField(
|
|
21
|
+
model_name='payment',
|
|
22
|
+
name='status',
|
|
23
|
+
field=models.CharField(choices=[('paid', 'paid'), ('unpaid', 'unpaid'), ('canceled', 'canceled'), ('refounded', 'refounded')], default='unpaid', max_length=15),
|
|
24
|
+
),
|
|
25
|
+
migrations.AddField(
|
|
26
|
+
model_name='payment',
|
|
27
|
+
name='updated_at',
|
|
28
|
+
field=models.DateTimeField(auto_now=True),
|
|
29
|
+
),
|
|
30
|
+
]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Generated by Django 5.1.6 on 2025-09-01 15:45
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('drfchelseru', '0019_payment_created_at_payment_status_payment_updated_at'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AddField(
|
|
14
|
+
model_name='payment',
|
|
15
|
+
name='paid_at',
|
|
16
|
+
field=models.TextField(blank=True, null=True),
|
|
17
|
+
),
|
|
18
|
+
]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Generated by Django 5.1.6 on 2025-09-01 16:28
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('drfchelseru', '0020_payment_paid_at'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AlterField(
|
|
14
|
+
model_name='payment',
|
|
15
|
+
name='message',
|
|
16
|
+
field=models.TextField(blank=True, null=True),
|
|
17
|
+
),
|
|
18
|
+
]
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Generated by Django 5.1.6 on 2025-09-04 09:15
|
|
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", "0021_alter_payment_message"),
|
|
12
|
+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
operations = [
|
|
16
|
+
migrations.AddField(
|
|
17
|
+
model_name="payment",
|
|
18
|
+
name="pay_mode",
|
|
19
|
+
field=models.IntegerField(
|
|
20
|
+
choices=[(1, "Charge wallet"), (2, "Only pay")], default=1
|
|
21
|
+
),
|
|
22
|
+
),
|
|
23
|
+
migrations.CreateModel(
|
|
24
|
+
name="Wallet",
|
|
25
|
+
fields=[
|
|
26
|
+
(
|
|
27
|
+
"id",
|
|
28
|
+
models.BigAutoField(
|
|
29
|
+
auto_created=True,
|
|
30
|
+
primary_key=True,
|
|
31
|
+
serialize=False,
|
|
32
|
+
verbose_name="ID",
|
|
33
|
+
),
|
|
34
|
+
),
|
|
35
|
+
("amount", models.FloatField(default=0.0)),
|
|
36
|
+
("created_at", models.DateTimeField(auto_now_add=True)),
|
|
37
|
+
("updated_at", models.DateTimeField(auto_now=True)),
|
|
38
|
+
(
|
|
39
|
+
"user",
|
|
40
|
+
models.OneToOneField(
|
|
41
|
+
on_delete=django.db.models.deletion.CASCADE,
|
|
42
|
+
related_name="wallet_drf_chelseru",
|
|
43
|
+
to=settings.AUTH_USER_MODEL,
|
|
44
|
+
),
|
|
45
|
+
),
|
|
46
|
+
],
|
|
47
|
+
),
|
|
48
|
+
]
|