django-chelseru 2.0.4__py3-none-any.whl → 2.0.6__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: django-chelseru
3
- Version: 2.0.4
3
+ Version: 2.0.6
4
4
  Summary: Authentication system, online and real-time chat, SMS & BANK system for Iranian SMS services.
5
5
  Home-page: https://pipdjango.chelseru.com
6
6
  Author: Sobhan Bahman Rashnu
@@ -1,4 +1,4 @@
1
- django_chelseru-2.0.4.dist-info/licenses/LICENSE,sha256=VupU5KV4NteHaNQb-WH31G_WZWezxXoomjiCIAHoQJo,1089
1
+ django_chelseru-2.0.6.dist-info/licenses/LICENSE,sha256=VupU5KV4NteHaNQb-WH31G_WZWezxXoomjiCIAHoQJo,1089
2
2
  drfchelseru/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  drfchelseru/admin.py,sha256=uamcWPCCw9_dD00XL8Brp8A1NvfhB5FtUfF9DWQCK9c,1022
4
4
  drfchelseru/apps.py,sha256=hOTTzFGLXiTPZeN8p_LLcSECLtsR2Q0SUo8zJzgM-qQ,211
@@ -6,14 +6,14 @@ drfchelseru/consumers.py,sha256=c8h9JYu5QUSKRREFrIrkjpkEQTzG5V8eg2lriaZODsc,2614
6
6
  drfchelseru/middlewares.py,sha256=Ej_9GTlVPzfzYAUqxUn7VHJRdlywQmrbSIW43yK5q5U,3818
7
7
  drfchelseru/models.py,sha256=jQ5IbS5q4GufZC9W_zgX1Qg8YU_f8V-Jusbh5hQYPhQ,11214
8
8
  drfchelseru/routing.py,sha256=shAlgzcIwVuVPlvKeWBLCqr6PuBTHyIrWNgHEfnqrxg,165
9
- drfchelseru/serializers.py,sha256=I3kS2NhzIprY8-WWhjQPShAom6R7epg7do7RnDkpnys,1421
9
+ drfchelseru/serializers.py,sha256=YaotF1ee6kzgNuqjRX72HsNlteSLKV7DybpmPhy4lOU,2383
10
10
  drfchelseru/services.py,sha256=K-VzisPliuKv0BL6Z3U6Tz0ewiVwhUkxt7yn08pemCk,29024
11
11
  drfchelseru/settings.py,sha256=LhdRLmUJnNlET0JYnHqRdFzmBD_nEX18qU1C1j0qN0E,11466
12
12
  drfchelseru/signals.py,sha256=CI1mZR5RrdOddXBnPC1eMdt9iQkYFDypfgogtfTc2eQ,2714
13
13
  drfchelseru/tests.py,sha256=mrbGGRNg5jwbTJtWWa7zSKdDyeB4vmgZCRc2nk6VY-g,60
14
- drfchelseru/urls.py,sha256=qD3As2gSCEaNDxgU0ejIADLUt9t2EvoaTmqeiV1LRSA,898
14
+ drfchelseru/urls.py,sha256=nT_rYVCeaBzRX_EboAssKGWfPtPHGixtNVeOUcWcy8U,1120
15
15
  drfchelseru/validators.py,sha256=jAJASfG4kPcqrGxxIcoR8VjS4L4n_EzZuxJtQ1g9qmo,480
16
- drfchelseru/views.py,sha256=KMEfY1HLQB9QK9wvJ-LOEU57BSwe8ZNBDJ9hqNDa9vs,19821
16
+ drfchelseru/views.py,sha256=-3dk7R4GH6TqPvMq7sX2NTNoyEbFJMV8tDvH7Sb67Zg,20108
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
@@ -37,7 +37,7 @@ drfchelseru/migrations/0020_payment_paid_at.py,sha256=H6cr-tfjJVjN3tCsCD8ecg9JGJ
37
37
  drfchelseru/migrations/0021_alter_payment_message.py,sha256=g5qIvQ-wecdXGcMf7ZhyfL2u85QpgMUOADHE7t4QHog,397
38
38
  drfchelseru/migrations/0022_payment_pay_mode_wallet.py,sha256=241lZITO1jQHqXkJKYm8DKUh7w9rmROh65LzNifP3BA,1521
39
39
  drfchelseru/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
- django_chelseru-2.0.4.dist-info/METADATA,sha256=GsPMOCPssvGFooiGKka7EXRrhnM1n1vVUTZRWWq4o1c,18242
41
- django_chelseru-2.0.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
42
- django_chelseru-2.0.4.dist-info/top_level.txt,sha256=fsaO1F03W3j4AYi0TfDGv5Cjb_Qrh6RSkwkWqfqaMns,12
43
- django_chelseru-2.0.4.dist-info/RECORD,,
40
+ django_chelseru-2.0.6.dist-info/METADATA,sha256=tdas5tqKCLoENgehYaatYTllimZm2ScX5E18pA3eEXo,18242
41
+ django_chelseru-2.0.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
42
+ django_chelseru-2.0.6.dist-info/top_level.txt,sha256=fsaO1F03W3j4AYi0TfDGv5Cjb_Qrh6RSkwkWqfqaMns,12
43
+ django_chelseru-2.0.6.dist-info/RECORD,,
@@ -1,10 +1,12 @@
1
- from rest_framework.serializers import ModelSerializer
1
+ from rest_framework.serializers import ModelSerializer, CharField, ValidationError
2
2
  from django.contrib.auth.models import User
3
+ from django.contrib.auth.password_validation import validate_password
4
+ from django.contrib.auth import get_user_model
3
5
  from .models import User as mobile, OTPCode, Session, MessageSMS, ChatRoom, MessageChat, Payment
4
6
 
5
7
  # from django.contrib.auth import get_user_model
6
8
 
7
- # UserGet = get_user_model()
9
+ UserGet = get_user_model()
8
10
 
9
11
  class DefaultUserSerializer(ModelSerializer):
10
12
  class Meta:
@@ -58,3 +60,27 @@ class PaymentSerializer(MobileSerializer):
58
60
  class Meta:
59
61
  model = Payment
60
62
  fields = '__all__'
63
+
64
+
65
+ # Authentication method : Passwd
66
+ class RegisterSerializer(ModelSerializer):
67
+ password = CharField(write_only=True, required=True, validators=[validate_password])
68
+ password2 = CharField(write_only=True, required=True)
69
+
70
+ class Meta:
71
+ model = UserGet
72
+ fields = ('username', 'password', 'password2', 'email')
73
+
74
+ def validate(self, attrs):
75
+ if attrs['password'] != attrs['password2']:
76
+ raise ValidationError({"password": "رمز عبور و تکرار آن برابر نیستند."})
77
+ return attrs
78
+
79
+ def create(self, validated_data):
80
+ user = UserGet.objects.create(
81
+ username=validated_data['username'],
82
+ email=validated_data['email'],
83
+ )
84
+ user.set_password(validated_data['password'])
85
+ user.save()
86
+ return user
drfchelseru/urls.py CHANGED
@@ -1,6 +1,8 @@
1
1
  from django.urls import path, include
2
2
  from rest_framework.routers import DefaultRouter
3
- from .views import MessageSend, OTPCodeSend ,Authentication, SessionList, MessageViewSet, ChatRoomViewSet, PaymentCreate, PaymentCallback
3
+ from rest_framework_simplejwt.views import TokenObtainPairView
4
+
5
+ from .views import MessageSend, OTPCodeSend ,Authentication, SessionList, MessageViewSet, ChatRoomViewSet, PaymentCreate, PaymentCallback, RegisterView
4
6
 
5
7
  app_name = 'drfchelseru'
6
8
 
@@ -14,6 +16,9 @@ urlpatterns = [
14
16
  path('otp/send/', OTPCodeSend.as_view(), name='otp-send'),
15
17
  path('authenticate/', Authentication.as_view(), name='auth'),
16
18
 
19
+ path('register/', RegisterView.as_view(), name='register-passwd'),
20
+ path('login/', TokenObtainPairView.as_view(), name='login-passwd'),
21
+
17
22
  path('sessions/', SessionList.as_view(), name='sessions'),
18
23
 
19
24
  path('payment/create/', PaymentCreate.as_view(), name='payment-create'),
drfchelseru/views.py CHANGED
@@ -1,16 +1,19 @@
1
1
  from rest_framework.viewsets import ModelViewSet
2
2
  from rest_framework.views import APIView
3
3
  from rest_framework.permissions import AllowAny, IsAuthenticated
4
- from rest_framework.generics import ListAPIView
4
+ from rest_framework.generics import ListAPIView, CreateAPIView
5
5
  from rest_framework.response import Response
6
6
  from rest_framework.status import HTTP_200_OK, HTTP_204_NO_CONTENT, HTTP_500_INTERNAL_SERVER_ERROR, HTTP_502_BAD_GATEWAY, HTTP_401_UNAUTHORIZED, HTTP_400_BAD_REQUEST, HTTP_409_CONFLICT, HTTP_404_NOT_FOUND
7
7
  from rest_framework.exceptions import NotFound, ValidationError
8
+ from rest_framework import status
9
+
8
10
  from django.contrib.auth.models import User as UserDefault
11
+ from django.contrib.auth import get_user_model
9
12
 
10
13
  from .services import send_message, create_payment, verify_payment
11
14
  from .settings import sms_init_check, auth_init_check
12
15
  from .validators import mobile_number as mobile_validator
13
- from .serializers import MessageSerializer, OTPCodeSerializer, SessionSerializer, ChatRoomSerializer, MessageChatSerializer, PaymentSerializer
16
+ from .serializers import MessageSerializer, OTPCodeSerializer, SessionSerializer, ChatRoomSerializer, MessageChatSerializer, PaymentSerializer, RegisterSerializer
14
17
  from .models import User, ChatRoom
15
18
  from django.utils.timezone import now, timedelta
16
19
  from django.db import transaction, IntegrityError, OperationalError
@@ -22,6 +25,7 @@ import traceback
22
25
  import time
23
26
  import logging
24
27
 
28
+ UserGet = get_user_model()
25
29
 
26
30
  logger = logging.getLogger(__name__)
27
31
 
@@ -238,7 +242,7 @@ class Authentication(APIView):
238
242
  return Response({'error': str(e)}, status=HTTP_204_NO_CONTENT)
239
243
  except Exception:
240
244
  logger.exception("Error while creating tokens for user (mobile=%s). user object: %r", mobile_number, user)
241
- return Response({'error': 'Token generation failed.'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
245
+ return Response({'error': 'Token generation failed.'}, status=HTTP_500_INTERNAL_SERVER_ERROR)
242
246
  # return Response({'error': 'An error occurred while generating or sending the otpcode, please contact the www.chelseru.com support team.'}, status=HTTP_500_INTERNAL_SERVER_ERROR)
243
247
 
244
248
 
@@ -433,4 +437,10 @@ class PaymentCallback(APIView):
433
437
 
434
438
  except self.model.DoesNotExist:
435
439
  return Response({'error': 'payment not found.'}, status=HTTP_404_NOT_FOUND)
436
- return Response({})
440
+ return Response({})
441
+
442
+
443
+ # Authentication method : Passwd
444
+ class RegisterView(CreateAPIView):
445
+ queryset = UserGet.objects.all()
446
+ serializer_class = RegisterSerializer