Skip to content
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

Feature/remove is filled for fun #51

Merged
merged 4 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion account/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class Meta:
"year_of_birth",
"postal_code",
"optional_postal_code",
"is_filled_for_fun",
"is_interested_in_mobility",
"result_can_be_used",
"gender",
Expand Down
17 changes: 17 additions & 0 deletions account/migrations/0014_remove_profile_is_filled_for_fun.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.1.13 on 2024-04-11 06:37

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("account", "0013_user_has_subscribed"),
]

operations = [
migrations.RemoveField(
model_name="profile",
name="is_filled_for_fun",
),
]
1 change: 0 additions & 1 deletion account/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class Profile(models.Model):
year_of_birth = models.PositiveSmallIntegerField(null=True, blank=True)
postal_code = models.CharField(max_length=10, null=True)
optional_postal_code = models.CharField(max_length=10, null=True)
is_filled_for_fun = models.BooleanField(default=False)
is_interested_in_mobility = models.BooleanField(default=False)
result_can_be_used = models.BooleanField(default=True)
gender = models.CharField(
Expand Down
13 changes: 0 additions & 13 deletions account/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ def test_profile_put(api_client_authenticated, users, profiles):
user = users.get(username="test1")
url = reverse("account:profiles-detail", args=[user.id])
assert user.profile.is_interested_in_mobility is False
assert user.profile.is_filled_for_fun is False
assert user.profile.gender is None
assert user.profile.postal_code is None
assert user.profile.optional_postal_code is None
Expand All @@ -133,14 +132,12 @@ def test_profile_put(api_client_authenticated, users, profiles):
"optional_postal_code": "20220",
"is_interested_in_mobility": True,
"gender": "F",
"is_filled_for_fun": True,
"result_can_be_used": False,
}
response = api_client_authenticated.put(url, data)
assert response.status_code == 200
user.refresh_from_db()
assert user.profile.is_interested_in_mobility is True
assert user.profile.is_filled_for_fun is True
assert user.profile.gender == "F"
assert user.profile.postal_code == "20210"
assert user.profile.optional_postal_code == "20220"
Expand Down Expand Up @@ -206,16 +203,6 @@ def test_profile_patch_year_of_birth(api_client_authenticated, users, profiles):
assert user.profile.year_of_birth == 42


@pytest.mark.django_db
def test_profile_patch_is_filled_for_fun(api_client_authenticated, users, profiles):
user = users.get(username="test1")
url = reverse("account:profiles-detail", args=[user.id])
assert user.profile.is_filled_for_fun is False
patch(api_client_authenticated, url, {"is_filled_for_fun": True})
user.refresh_from_db()
assert user.profile.is_filled_for_fun is True


@pytest.mark.django_db
def test_profile_patch_result_can_be_used(api_client_authenticated, users, profiles):
user = users.get(username="test1")
Expand Down
6 changes: 1 addition & 5 deletions profiles/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,7 @@ def question_condition_met(question_condition_qs, user):
def update_postal_code_result(user):
# Ensure that duplicate results are not saved, profiles filled for fun and profiles whos result
# can not be used are ignored.
if (
user.postal_code_result_saved
or user.profile.is_filled_for_fun
or not user.profile.result_can_be_used
):
if user.postal_code_result_saved or not user.profile.result_can_be_used:
return
if user.result:
result = user.result
Expand Down
23 changes: 0 additions & 23 deletions profiles/tests/api/test_question.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,29 +374,6 @@ def test_get_question_by_numbers(api_client, questions):
assert response.json()["results"][-1]["number"] == questions.last().number


@pytest.mark.django_db
def test_result_count_is_filled_for_fun_is_false(
api_client_authenticated, answers, users
):
user = users.get(username="test1")
assert user.profile.is_filled_for_fun is False
url = reverse("profiles:question-end-poll")
response = api_client_authenticated.post(url)
assert response.status_code == 200
assert PostalCodeResult.objects.count() == 2


@pytest.mark.django_db
def test_result_count_is_filled_for_fun_is_true(api_client_authenticated, users):
user = users.get(username="test1")
url = reverse("profiles:question-end-poll")
user.profile.is_filled_for_fun = True
user.profile.save()
response = api_client_authenticated.post(url)
assert response.status_code == 200
assert PostalCodeResult.objects.count() == 0


@pytest.mark.django_db
def test_result_count_result_can_be_used_is_true(
api_client_authenticated, users, answers
Expand Down
Loading