Skip to content

Commit

Permalink
#250 Cleaning bad data (#253)
Browse files Browse the repository at this point in the history
* #250 data cleanup

* user choices migrations

---------

Co-authored-by: aakashshankar <[email protected]>
  • Loading branch information
shub-garg and ahhcash authored Dec 11, 2024
1 parent de881da commit 6c69fb3
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
22 changes: 22 additions & 0 deletions src/accounts/migrations/0010_alter_customuser_user_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 5.1.1 on 2024-12-11 18:52

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("accounts", "0009_customuser_profile_image_url"),
]

operations = [
migrations.AlterField(
model_name="customuser",
name="user_type",
field=models.CharField(
choices=[("user", "User"), ("service_provider", "Service Provider")],
default="user",
max_length=20,
),
),
]
2 changes: 1 addition & 1 deletion src/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

class CustomUser(AbstractUser):
USER_TYPE_CHOICES = (
("service_provider", "Service Provider"),
("user", "User"),
("service_provider", "Service Provider"),
)

email = models.EmailField(unique=True)
Expand Down
5 changes: 4 additions & 1 deletion src/accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import uuid
import boto3
from botocore.exceptions import ClientError

from django.contrib.auth import login

from accounts.models import CustomUser
from forum.models import Post
Expand Down Expand Up @@ -69,6 +69,9 @@ def register(request):
return render(request, "register.html", {"form": form})

user.save() # Now save to DB login(request, user, backend="django.contrib.auth.backends.ModelBackend")

login(request, user, backend="django.contrib.auth.backends.ModelBackend")

if user.user_type == "service_provider":
return redirect("services:list")
else:
Expand Down
2 changes: 1 addition & 1 deletion src/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pycodestyle==2.12.1
pycparser==2.22
pyflakes==3.2.0
Pygments==2.18.0
PyJWT==2.9.0
PyJWT==2.10.1
python-dateutil==2.9.0.post0
python-decouple==3.8
pytz==2024.2
Expand Down
8 changes: 4 additions & 4 deletions src/services/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def setUp(self):
name="Test Service",
address="123 Test St",
category="Mental Health Center",
provider_id="test_provider_id",
provider_id="-1",
latitude=Decimal("40.7128"),
longitude=Decimal("-74.0060"),
ratings=Decimal("4.5"),
Expand All @@ -483,12 +483,12 @@ def test_get_services_by_provider(self, mock_get_services_by_provider):
mock_get_services_by_provider.return_value = [self.sample_service]

# Act
result = self.service_repo.get_services_by_provider("test_provider_id")
result = self.service_repo.get_services_by_provider(-1)

# Assert
self.assertEqual(len(result), 1)
self.assertEqual(result[0].name, "Test Service")
mock_get_services_by_provider.assert_called_once_with("test_provider_id")
mock_get_services_by_provider.assert_called_once_with(-1)

@patch("services.repositories.ServiceRepository.get_service")
def test_get_service(self, mock_get_service):
Expand Down Expand Up @@ -1557,7 +1557,7 @@ def setUp(self):
name="Test Service",
address="123 Test St",
category="Mental Health Center",
provider_id="test_provider_id",
provider_id="-1",
latitude=Decimal("40.7128"),
longitude=Decimal("-74.0060"),
ratings=Decimal("4.5"),
Expand Down

0 comments on commit 6c69fb3

Please sign in to comment.