Improve HTML on profile and game details
This commit is contained in:
parent
4af2b02a01
commit
2ff314ecc8
10 changed files with 60 additions and 16 deletions
|
|
@ -216,4 +216,8 @@ class NotificationSubscription(models.Model):
|
|||
]
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.user} subscription to {Game.display_name}"
|
||||
if self.game:
|
||||
return f"{self.user} subscription to game: {self.game.display_name}"
|
||||
if self.organization:
|
||||
return f"{self.user} subscription to organization: {self.organization.name}"
|
||||
return f"{self.user} subscription"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,6 @@ urlpatterns = [
|
|||
path("games/<str:pk>/", views.GameDetailView.as_view(), name="game_detail"),
|
||||
path("games/<str:game_id>/subscribe/", views.subscribe_game_notifications, name="subscribe_notifications"),
|
||||
path("organizations/", views.OrgListView.as_view(), name="org_list"),
|
||||
path("organizations/<str:pk>/", views.OrgDetailView.as_view(), name="org_detail"),
|
||||
path("organizations/<str:pk>/", views.OrgDetailView.as_view(), name="organization_detail"),
|
||||
path("organizations/<str:org_id>/subscribe/", views.subscribe_org_notifications, name="subscribe_org_notifications"),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -49,10 +49,21 @@ class OrgDetailView(DetailView):
|
|||
Returns:
|
||||
dict: Context data.
|
||||
"""
|
||||
organization: Organization = self.object
|
||||
context = super().get_context_data(**kwargs)
|
||||
games = Game.objects.filter(drop_campaigns__owner=organization).distinct()
|
||||
context["games"] = games
|
||||
organization: Organization = self.object
|
||||
|
||||
user = self.request.user
|
||||
if not user.is_authenticated:
|
||||
subscription: NotificationSubscription | None = None
|
||||
else:
|
||||
subscription = NotificationSubscription.objects.filter(user=user, organization=organization).first()
|
||||
|
||||
games: QuerySet[Game, Game] = Game.objects.filter(drop_campaigns__owner=organization).distinct()
|
||||
context.update({
|
||||
"subscription": subscription,
|
||||
"games": games,
|
||||
})
|
||||
|
||||
return context
|
||||
|
||||
|
||||
|
|
@ -290,6 +301,7 @@ class GameDetailView(DetailView):
|
|||
"upcoming_campaigns": upcoming_campaigns,
|
||||
"expired_campaigns": expired_campaigns,
|
||||
"subscription": subscription,
|
||||
"owner": active_campaigns[0].owner if active_campaigns else None,
|
||||
"now": now,
|
||||
})
|
||||
|
||||
|
|
@ -430,7 +442,7 @@ def subscribe_org_notifications(request: HttpRequest, org_id: str) -> HttpRespon
|
|||
message = ""
|
||||
|
||||
messages.success(request, message)
|
||||
return redirect("organization_detail", org_id=organization.id)
|
||||
return redirect("twitch:organization_detail", pk=organization.id)
|
||||
|
||||
messages.warning(request, "Only POST is available for this view.")
|
||||
return redirect("organization_detail", org_id=organization.id)
|
||||
return redirect("twitch:organization_detail", pk=organization.id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue