Refactor profile view to separate game and organization subscriptions for improved clarity in the profile template.
This commit is contained in:
parent
1c3a9304b3
commit
9840a2c133
2 changed files with 19 additions and 10 deletions
|
|
@ -86,11 +86,14 @@ def profile_view(request: HttpRequest) -> HttpResponse:
|
||||||
HttpResponse: Rendered profile template.
|
HttpResponse: Rendered profile template.
|
||||||
"""
|
"""
|
||||||
subscriptions = NotificationSubscription.objects.filter(user=request.user) # type: ignore[misc]
|
subscriptions = NotificationSubscription.objects.filter(user=request.user) # type: ignore[misc]
|
||||||
|
game_subscriptions = subscriptions.filter(game_id__isnull=False)
|
||||||
|
org_subscriptions = subscriptions.filter(organization_id__isnull=False)
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
"accounts/profile.html",
|
"accounts/profile.html",
|
||||||
{
|
{
|
||||||
"user": request.user,
|
"user": request.user,
|
||||||
"subscriptions": subscriptions,
|
"game_subscriptions": game_subscriptions,
|
||||||
|
"org_subscriptions": org_subscriptions,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -26,19 +26,25 @@
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<a href="{% url 'accounts:logout' %}">Logout</a>
|
<a href="{% url 'accounts:logout' %}">Logout</a>
|
||||||
<h2>Will get notifications to:</h2>
|
<h2>Will get notifications for these subscriptions:</h2>
|
||||||
|
<h3>Games</h3>
|
||||||
<ul>
|
<ul>
|
||||||
{% for subscription in subscriptions %}
|
{% for subscription in game_subscriptions %}
|
||||||
<li>
|
<li>
|
||||||
{% if subscription.game_id %}
|
<a href="{% url 'twitch:game_detail' subscription.game_id %}">{{ subscription.game.display_name }}</a>
|
||||||
<a href="{% url 'twitch:game_detail' subscription.game_id %}">{{ subscription.game.display_name }}</a>
|
|
||||||
{% endif %}
|
|
||||||
{% if subscription.organization_id %}
|
|
||||||
<a href="{% url 'twitch:organization_detail' subscription.organization_id %}">{{ subscription.organization.name }}</a>
|
|
||||||
{% endif %}
|
|
||||||
</li>
|
</li>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<li>You have no subscriptions yet.</li>
|
<li>You have no game subscriptions yet.</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
<h3>Organizations</h3>
|
||||||
|
<ul>
|
||||||
|
{% for subscription in org_subscriptions %}
|
||||||
|
<li>
|
||||||
|
<a href="{% url 'twitch:organization_detail' subscription.organization_id %}">{{ subscription.organization.name }}</a>
|
||||||
|
</li>
|
||||||
|
{% empty %}
|
||||||
|
<li>You have no organization subscriptions yet.</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue