Hotfix before deadline

This commit is contained in:
ITQ
2024-03-04 23:21:51 +03:00
parent 9a4b18b4c1
commit 79f0aaaaa6
9 changed files with 40 additions and 29 deletions
@@ -1,4 +1,4 @@
# Generated by Django 4.2.10 on 2024-03-03 15:01
# Generated by Django 4.2.10 on 2024-03-04 19:15
import api.users.validators
import django.core.validators
@@ -30,7 +30,7 @@ class Migration(migrations.Migration):
('password', models.CharField(max_length=100, validators=[django.core.validators.RegexValidator('^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9]).{6,100}$')])),
('countryCode', models.CharField(max_length=2, validators=[django.core.validators.RegexValidator('[a-zA-Z]{2}'), api.users.validators.CountryCodeValidator()])),
('isPublic', models.BooleanField()),
('phone', models.CharField(max_length=20, null=True, validators=[django.core.validators.MaxLengthValidator(20), django.core.validators.RegexValidator('\\+[\\d]+')])),
('phone', models.CharField(max_length=20, null=True, validators=[django.core.validators.MaxLengthValidator(20), django.core.validators.RegexValidator('^\\+\\d+')])),
('image', models.URLField(null=True)),
('friends', models.ManyToManyField(blank=True, through='users.Friendship', to='users.profile')),
],
+2 -3
View File
@@ -27,7 +27,7 @@ class Profile(models.Model):
isPublic = models.BooleanField()
phone = models.CharField(
max_length=20,
validators=[MaxLengthValidator(20), RegexValidator(r"\+[\d]+")],
validators=[MaxLengthValidator(20), RegexValidator(r"^\+\d+")],
null=True,
)
image = models.URLField(max_length=200, null=True)
@@ -56,7 +56,6 @@ class Profile(models.Model):
return self.liked_posts.add(post)
def dislike_post(self, post):
print(self, post)
self.liked_posts.remove(post)
return self.disliked_posts.add(post)
@@ -82,7 +81,7 @@ class Profile(models.Model):
cls.objects.filter(phone=validated_data.get("phone"))
.exclude(id=user_id)
.exists()
):
) and validated_data.get("phone") is not None:
errors["phone"] = {"User with this phone already exists"}
return errors
-2
View File
@@ -22,8 +22,6 @@ class UpdateProfileSerializer(serializers.ModelSerializer):
class Meta:
model = Profile
fields = [
"login",
"email",
"countryCode",
"isPublic",
"phone",
+4 -4
View File
@@ -116,7 +116,7 @@ class ProfileMeApiView(APIView):
)
serializer.save()
return Response(serializer.data)
return Response(self._get_profile_data(user))
raise ValidationError(serializer.errors)
@@ -202,9 +202,9 @@ class FriendsListApiView(ListAPIView):
limit = serializer.validated_data.get("limit")
offset = serializer.validated_data.get("offset")
return Friendship.objects.filter(from_profile=self.request.user)[
offset: offset + limit
]
return Friendship.objects.order_by("-addedAt").filter(
from_profile=self.request.user
)[offset: offset + limit]
class PasswordChangeApiView(APIView):