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

Visual streak tracker #3165

Merged
merged 4 commits into from
Dec 31, 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
6 changes: 3 additions & 3 deletions website/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,9 +666,9 @@ def update_streak_and_award_points(self, check_in_date=None):
elif self.current_streak == 30:
points_awarded += 50
reason = "30-day streak milestone achieved!"
elif self.current_streak == 90:
elif self.current_streak == 100:
points_awarded += 150
reason = "90-day streak milestone achieved!"
reason = "100-day streak milestone achieved!"
elif self.current_streak == 180:
points_awarded += 300
reason = "180-day streak milestone achieved!"
Expand Down Expand Up @@ -700,7 +700,7 @@ def award_streak_badges(self):
7: "Weekly Streak",
15: "Half-Month Streak",
30: "Monthly Streak",
90: "Three Month Streak",
100: "100 Day Streak",
180: "Six Month Streak",
365: "Yearly Streak",
}
Expand Down
33 changes: 33 additions & 0 deletions website/templates/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,20 @@
color: #ff5722;
font-weight: bold;
}
.shine-effect {
background: linear-gradient(
90deg,
transparent,
rgba(255, 255, 255, 0.3),
transparent
);
animation: shine 2s infinite;
}

@keyframes shine {
0% { transform: translateX(-100%); }
100% { transform: translateX(100%); }
}
</style>
{% endblock style %}
{% block content %}
Expand Down Expand Up @@ -386,6 +400,25 @@ <h4 class="text-[16px] font-semibold uppercase tracking-wide mb-2">
<span><i class="fa fa-calendar-check mr-2 text-red-500"></i> Last Sizzle Check-in:</span>
<span class="font-bold text-red-500">{{ user.userprofile.last_check_in|default:"N/A" }}</span>
</div>
<div class="my-8 p-4 rounded-lg w-full">
<div class="flex items-center justify-between mb-2 font-medium">
<span>Streak Progress</span>
<div class="flex items-center gap-2">
<i class="fas fa-trophy text-yellow-500"></i>
<span class="font-bold">{{ base_milestone }}/{{ next_milestone }}</span>
</div>
</div>
<div class="relative w-full bg-gradient-to-r from-gray-100 to-gray-200 rounded-full h-3 overflow-hidden shadow-inner">
<div class="absolute top-0 left-0 h-full bg-gradient-to-r from-blue-700 to-red-600 rounded-full transition-all duration-500 ease-out animate-pulse"
style="width: {% widthratio base_milestone next_milestone 100 %}%">
<div class="absolute inset-0 bg-white/20 shine-effect"></div>
</div>
</div>
<div class="flex justify-between mt-1">
<span class="text-md text-gray-500">Current</span>
<span class="text-md text-gray-500">Next Milestone</span>
</div>
</div>
</div>
</div>
<!--add a link here to edit the profile /profile/edit -->
Expand Down
12 changes: 11 additions & 1 deletion website/views/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,19 @@ def get_context_data(self, **kwargs):

user = self.object
context = super(UserProfileDetailView, self).get_context_data(**kwargs)
milestones = [7, 15, 30, 100, 180, 365]
base_milestone = 0
next_milestone = 0
for milestone in milestones:
if user.userprofile.current_streak >= milestone:
base_milestone = milestone
elif user.userprofile.current_streak < milestone:
next_milestone = milestone
break
context["base_milestone"] = base_milestone
context["next_milestone"] = next_milestone
# Fetch badges
user_badges = UserBadge.objects.filter(user=user).select_related("badge")

context["user_badges"] = user_badges # Add badges to context
context["is_mentor"] = UserBadge.objects.filter(user=user, badge__title="Mentor").exists()
context["available_badges"] = Badge.objects.all()
Expand Down
Loading