Skip to content

Commit

Permalink
Remove public_statistics option
Browse files Browse the repository at this point in the history
  • Loading branch information
anorthall committed Dec 19, 2023
1 parent 997f955 commit dcadd8b
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 52 deletions.
19 changes: 0 additions & 19 deletions app/logger/tests/test_user_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,25 +156,6 @@ def test_user_profile_page_with_various_privacy_settings(self):
self.assertEqual(response.status_code, 200)
self.assertContains(response, self.user.name)

@tag("privacy")
def test_public_statistics_privacy_setting(self):
"""Test that the public statistics privacy setting works"""
for i in range(0, 50):
TripFactory(user=self.user)
self.user.public_statistics = False
self.user.save()

response = self.client.get(self.user.get_absolute_url())
self.assertEqual(response.status_code, 200)
self.assertNotContains(response, '<div class="profile-stats')

self.user.public_statistics = True
self.user.save()

response = self.client.get(self.user.get_absolute_url())
self.assertEqual(response.status_code, 200)
self.assertContains(response, '<div class="profile-stats')

def test_friends_appear_on_the_user_profile_page(self):
"""Test that friends appear on the user profile page when viewed by the user"""
self.client.force_login(self.user)
Expand Down
8 changes: 3 additions & 5 deletions app/logger/views/userprofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,13 @@ def get_context_data(self, **kwargs):
context["trips"] = self.get_trips(user)
context["photos"] = self.profile_user.get_photos(for_user=user)
context["quick_stats"] = self.profile_user.quick_stats
context["stats"] = statistics.yearly(
self.profile_user.trips.exclude(type=Trip.SURFACE)
)
context["enable_private_stats"] = (
self.profile_user == user
) or user.is_superuser
else:
context["private_profile"] = True

if self.profile_user.public_statistics:
context["stats"] = statistics.yearly(
self.profile_user.trips.exclude(type=Trip.SURFACE)
)

return context
14 changes: 0 additions & 14 deletions app/templates/users/account.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,20 +177,6 @@ <h3 class="fs-5">Profile settings</h3>
</div>
</div>

<div class="row p-1 border-bottom">
<div class="col-5 col-md-4 col-lg-3 col-xl-2 account-info-label">
Statistics
</div>

<div class="col account-info-data">
{% if user.privacy == user.PRIVATE %}
Public statistics are disabled as your profile is private.
{% else %}
Statistics are {% if not user.public_statistics %}not {% endif %}shown on your profile page.
{% endif %}
</div>
</div>

<div class="row p-1">
<div class="col-5 col-md-4 col-lg-3 col-xl-2 account-info-label">
Biography
Expand Down
1 change: 0 additions & 1 deletion app/users/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ class CavingUserAdmin(BaseUserAdmin, ModelAdmin):
"allow_friend_email",
"allow_friend_username",
"allow_comments",
"public_statistics",
"email_friend_requests",
),
},
Expand Down
1 change: 0 additions & 1 deletion app/users/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class Meta:
location = factory.Faker("city")
clubs = factory.LazyFunction(generate_club)
timezone = factory.Faker("timezone")
public_statistics = factory.Faker("pybool")
allow_friend_email = factory.Faker("pybool")
allow_friend_username = factory.Faker("pybool")
allow_comments = factory.Faker("pybool")
Expand Down
2 changes: 0 additions & 2 deletions app/users/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ class Meta:
"allow_friend_email",
"allow_comments",
"show_cavers_on_trip_list",
"public_statistics",
"disable_distance_statistics",
"disable_survey_statistics",
"disable_stats_over_time",
Expand Down Expand Up @@ -318,7 +317,6 @@ def __init__(self, *args, **kwargs):
),
HTML('<h5 class="mt-3">Statistics</h5>'),
Div(
Div("public_statistics", css_class="col"),
Div("disable_distance_statistics", css_class="col"),
Div("disable_survey_statistics", css_class="col"),
Div("disable_stats_over_time", css_class="col"),
Expand Down
16 changes: 16 additions & 0 deletions app/users/migrations/0044_remove_cavinguser_public_statistics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 4.2 on 2023-12-19 10:04

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("users", "0043_cavinguser_profile_view_count"),
]

operations = [
migrations.RemoveField(
model_name="cavinguser",
name="public_statistics",
),
]
8 changes: 0 additions & 8 deletions app/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,6 @@ class CavingUser(AbstractBaseUser, PermissionsMixin):
"comments, but will hide them until it is re-enabled."
),
)
public_statistics = models.BooleanField(
"Show statistics on profile",
default=True,
help_text=(
"Enabling this option will show an annual statistics table on your "
"profile page which will be visible to anyone who can view your profile."
),
)
disable_distance_statistics = models.BooleanField(
"Disable distance statistics",
default=False,
Expand Down
2 changes: 0 additions & 2 deletions app/users/tests/test_custom_user_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,6 @@ def test_submit_updates_to_settings(self):
"privacy": "Friends",
"timezone": "US/Central",
"units": "Imperial",
"public_statistics": True,
"settings_submit": "Save",
},
follow=True,
Expand All @@ -480,7 +479,6 @@ def test_submit_updates_to_settings(self):
self.assertEqual(self.user.privacy, self.user.FRIENDS)
self.assertEqual(self.user.timezone, ZoneInfo("US/Central"))
self.assertEqual(self.user.units, self.user.IMPERIAL)
self.assertTrue(self.user.public_statistics)

def test_submit_invalid_updates_to_profile(self):
"""Test submitting invalid updates to a user's profile"""
Expand Down

0 comments on commit dcadd8b

Please sign in to comment.