Skip to content

Commit 7471c2f

Browse files
committed
fix lint: fix all lint issues
1 parent 4c94c16 commit 7471c2f

File tree

5 files changed

+24
-14
lines changed

5 files changed

+24
-14
lines changed

zserver/admin.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
from django.contrib import admin
22

3-
from zserver.models import Message, Session, SignUpOTP, UserProfile, VerifyUserOTP, UnverifiedUserProfile
3+
from zserver.models import (
4+
Message,
5+
Session,
6+
SignUpOTP,
7+
UnverifiedUserProfile,
8+
UserProfile,
9+
VerifyUserOTP,
10+
)
411

512
# Register your models here.
613
admin.site.register(UserProfile)

zserver/models/user_profile.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class BaseUserProfile(models.Model):
1414
updated_at = models.DateTimeField(auto_now=True, blank=False, null=False)
1515

1616
class Meta:
17+
"""make this model abstract so that it doesn't create a table."""
18+
1719
abstract = True # don't create a table for this model
1820

1921
def __str__(self) -> str:
@@ -40,7 +42,7 @@ def generate_otp(self) -> str:
4042
# Model for unverified user profiles
4143
class UnverifiedUserProfile(BaseUserProfile):
4244
email = models.EmailField(max_length=100, blank=False, null=False, unique=False)
43-
45+
4446
def generate_otp(self) -> str:
4547
"""Generate a 6-digit OTP for the user."""
4648
generated_opt = "".join(random.choices(string.digits, k=6))
@@ -65,9 +67,10 @@ class VerifyUserOTP(models.Model):
6567
user = models.ForeignKey(UnverifiedUserProfile, on_delete=models.CASCADE)
6668
otp = models.CharField(max_length=6, blank=False, null=False)
6769
created_at = models.DateTimeField(auto_now_add=True, blank=False, null=False)
68-
70+
6971
def __str__(self) -> str:
70-
return self.user.email + ' ' + self.otp
72+
"""Return the email of the user associated with the OTP."""
73+
return self.user.email + " " + self.otp
7174

7275

7376
# let's create a modle for login sessions

zserver/serializers/user_profile.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from rest_framework import serializers
22

3-
from zserver.models import Session, SignUpOTP, UserProfile, UnverifiedUserProfile, VerifyUserOTP
3+
from zserver.models import Session, SignUpOTP, UnverifiedUserProfile, UserProfile, VerifyUserOTP
44

55

66
# Serializer class for the UserProfile model
@@ -42,7 +42,7 @@ class Meta:
4242
extra_kwargs = {
4343
"password": {"write_only": True}, # Make the password field write-only
4444
}
45-
45+
4646
def validate_email(self, value: str) -> str:
4747
"""Validate that the email is not already in use."""
4848
if UserProfile.objects.filter(email=value).exists():
@@ -63,13 +63,13 @@ def create(self, validated_data: dict) -> UnverifiedUserProfile:
6363
# serializer for VerifyUserOTP model
6464
class VerifyUserOTPSerializer(serializers.ModelSerializer):
6565
email = serializers.EmailField(max_length=100)
66-
66+
6767
class Meta:
6868
"""Meta class to specify the model and fields to be serialized."""
6969

7070
model = VerifyUserOTP
7171
fields = ["otp", "email"]
72-
72+
7373
def validate(self, data: dict) -> dict:
7474
"""Validate the OTP and email."""
7575
email = data.get("email")
@@ -91,9 +91,9 @@ def validate(self, data: dict) -> dict:
9191
data["user"] = user
9292
data["user_otp"] = user_otp
9393
return data
94-
94+
9595
def signup_user(self) -> None:
96-
""" add user to UserProfile table and delete the OTP."""
96+
"""Add user to UserProfile table and delete the OTP."""
9797
user = self.validated_data["user"]
9898
user_profile = UserProfile(
9999
fullname=user.fullname,

zserver/tests/user_profile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from rest_framework import status
44
from rest_framework.test import APIClient
55

6-
from zserver.models import Session, SignUpOTP, UserProfile, UnverifiedUserProfile, VerifyUserOTP
6+
from zserver.models import Session, SignUpOTP, UnverifiedUserProfile, UserProfile, VerifyUserOTP
77

88

99
class UserProfileViewTest(TestCase):

zserver/views/user_profile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
ForgotPasswordSerializer,
1616
ResetPasswordSerializer,
1717
SessionSerializer,
18-
UserProfileSerializer,
1918
UnverifiedUserProfileSerializer,
19+
UserProfileSerializer,
2020
VerifyUserOTPSerializer,
2121
)
2222
from zserver.utils import get_env_var
@@ -102,9 +102,9 @@ def post(self, request: Request) -> Response:
102102

103103

104104
class VerifyUserOTPView(APIView):
105-
105+
106106
def post(self, request: Request) -> Response:
107-
"""verify OTP and signup user"""
107+
"""Verify OTP and signup user."""
108108
serializer = VerifyUserOTPSerializer(data=request.data)
109109
if serializer.is_valid():
110110
serializer.signup_user()

0 commit comments

Comments
 (0)