-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(deps): remove drfaddons dependency (Sourcery refactored) #209
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,19 +190,17 @@ def validate(self, attrs: dict) -> dict: | |
else: | ||
attrs["prop"] = EMAIL | ||
|
||
user = self.get_user(attrs.get("prop"), attrs.get("destination")) | ||
if user := self.get_user(attrs.get("prop"), attrs.get("destination")): | ||
attrs["email"] = user.email | ||
attrs["user"] = user | ||
|
||
if not user: | ||
else: | ||
if attrs["is_login"]: | ||
raise NotFound(_("No user exists with provided details")) | ||
if "email" not in attrs.keys() and "verify_otp" not in attrs.keys(): | ||
raise serializers.ValidationError( | ||
_("Email field is compulsory while verifying a non-existing user's OTP.") | ||
) | ||
else: | ||
attrs["email"] = user.email | ||
attrs["user"] = user | ||
|
||
Comment on lines
-193
to
-205
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
return attrs | ||
|
||
|
||
|
@@ -328,13 +326,11 @@ def validate(self, attrs: dict) -> dict: | |
""" | ||
validator = EmailValidator() | ||
validator(attrs.get("email")) | ||
user = self.get_user(attrs.get("email")) | ||
|
||
if not user: | ||
if user := self.get_user(attrs.get("email")): | ||
return attrs | ||
else: | ||
raise NotFound(_("User with the provided email does not exist.")) | ||
|
||
return attrs | ||
Comment on lines
-331
to
-336
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
class ImageSerializer(serializers.ModelSerializer): | ||
"""This serializer is for Image Upload API. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,8 +40,7 @@ def get_client_ip(request: HttpRequest) -> Optional[str]: | |
------- | ||
ip: str or None | ||
""" | ||
x_forwarded_for = request.META.get("HTTP_X_FORWARDED_FOR") | ||
if x_forwarded_for: | ||
if x_forwarded_for := request.META.get("HTTP_X_FORWARDED_FOR"): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
return x_forwarded_for.split(",")[0] | ||
else: | ||
return request.META.get("REMOTE_ADDR") | ||
|
@@ -251,7 +250,7 @@ def is_mobile_valid(mobile: str) -> bool: | |
>>> print(is_mobile_valid('9999999999')) | ||
True | ||
""" | ||
match = re.match(r"^[6-9]\d{9}$", str(mobile)) | ||
match = re.match(r"^[6-9]\d{9}$", mobile) | ||
Comment on lines
-254
to
+253
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
if match is None: | ||
raise ValidationError("Enter a valid mobile number.") | ||
return True | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
update_user_settings
refactored with the following changes:use-named-expression
)