ttvdrops/templates/twitch/campaign_list.html
Joakim Helleśen 4663a827e4
All checks were successful
Deploy to Server / deploy (push) Successful in 10s
Make templates sexier
2026-03-11 23:38:31 +01:00

199 lines
13 KiB
HTML

{% extends "base.html" %}
{% load static %}
{% load image_tags %}
{% load image_tags %}
{% block title %}
Drop Campaigns
{% endblock title %}
{% block extra_head %}
<link rel="alternate"
type="application/rss+xml"
title="All campaigns (RSS)"
href="{% url 'twitch:campaign_feed' %}" />
<link rel="alternate"
type="application/atom+xml"
title="All campaigns (Atom)"
href="{% url 'twitch:campaign_feed_atom' %}" />
{% endblock extra_head %}
{% block content %}
<main>
<header>
<h1>Drop Campaigns</h1>
<!-- RSS Feeds -->
<div>
<a href="{% url 'twitch:campaign_feed' %}"
title="RSS feed for all campaigns">[rss]</a>
<a href="{% url 'twitch:campaign_feed_atom' %}"
title="Atom feed for all campaigns">[atom]</a>
<a href="{% url 'twitch:export_campaigns_csv' %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}"
title="Export campaigns as CSV">[csv]</a>
<a href="{% url 'twitch:export_campaigns_json' %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}"
title="Export campaigns as JSON">[json]</a>
</div>
</header>
<form method="get" action="{% url 'twitch:campaign_list' %}">
<div style="display: flex;
gap: 1rem;
align-items: center;
flex-wrap: wrap">
<!-- Game Filter -->
<div>
<select name="game">
<option value="">All Games</option>
{% for game in games %}
<!-- Game option with Twitch ID {{ game.twitch_id }} and display name "{{ game.display_name }}" -->
<option value="{{ game.twitch_id }}"
{% if selected_game == game.twitch_id %}selected{% endif %}>
{{ game.display_name|default:game.name|default:game.slug|default:game.twitch_id }}
</option>
{% endfor %}
</select>
<!-- Status Filter -->
<select id="status" name="status">
<option value="">All Statuses</option>
{% for status in status_options %}
<!-- Status option "{{ status }}" -->
<option value="{{ status }}"
{% if selected_status == status %}selected{% endif %}>{{ status|title }}</option>
{% endfor %}
</select>
<button id="apply-filters-button" type="submit">Apply Filters</button>
</div>
</div>
</form>
<br />
{% if campaigns %}
{% regroup campaigns by game as campaigns_by_game %}
{% for game_group in campaigns_by_game %}
<!-- Game group for game "{{ game_group.grouper.display_name }}" with {{ game_group.list|length }} campaigns -->
<section>
<div style="display: flex; gap: 1rem;">
<div>
{% if game_group.grouper.box_art_best_url %}
{% picture game_group.grouper.box_art_best_url alt="Box art for "|add:game_group.grouper.display_name width=120 height=160 %}
{% else %}
<div style="width: 120px;
height: 160px;
border: 1px solid;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
font-size: 1rem">
🎮
<br />
No Image
</div>
{% endif %}
</div>
<div style="flex: 1;">
<header style="margin-bottom: 1rem;">
<h2 style="margin: 0 0 0.5rem 0;">
<a href="{% url 'twitch:game_detail' game_group.grouper.twitch_id %}"
style="text-decoration: none">{{ game_group.grouper.display_name|default:game_group.grouper.name|default:game_group.grouper.slug|default:game_group.grouper.twitch_id }}</a>
</h2>
{% if game_group.grouper.owner and game_group.grouper.owner.twitch_id %}
<p style="margin: 0;">
<a href="{% url 'twitch:organization_detail' game_group.grouper.owner.twitch_id %}"
style="text-decoration: none">{{ game_group.grouper.owner.name }}</a>
</p>
{% endif %}
</header>
<div style="overflow-x: auto;">
<div style="display: flex; gap: 1rem; min-width: max-content;">
{% for campaign in game_group.list %}
<!-- Campaign "{{ campaign.clean_name }}" with Twitch ID {{ campaign.twitch_id }} -->
<!-- https://ttvdrops.lovinator.space{% url 'twitch:campaign_detail' campaign.twitch_id %} -->
<!-- https://ttvdrops.lovinator.space{{ campaign.image_best_url }} -->
<article style="display: flex;
flex-direction: column;
align-items: flex-start;
padding: 0.5rem;
flex-shrink: 0">
<div>
<a href="{% url 'twitch:campaign_detail' campaign.twitch_id %}"
style="text-decoration: none">
{% if campaign.image_best_url %}
{% picture campaign.image_best_url alt="Campaign artwork for "|add:campaign.name width=120 %}
{% endif %}
<h4 style="margin: 0.5rem 0; text-align: left">{{ campaign.clean_name }}</h4>
</a>
<div style="font-size: 0.9rem;">
<time datetime="{{ campaign.start_at|date:'c' }}"
title="Start: {{ campaign.start_at|date:'DATETIME_FORMAT' }}">
{{ campaign.start_at|date:"M d, Y" }}
</time>
<span>-</span>
<time datetime="{{ campaign.end_at|date:'c' }}"
title="End: {{ campaign.end_at|date:'DATETIME_FORMAT' }}">
{{ campaign.end_at|date:"M d, Y" }}
</time>
</div>
<div style="margin-top: 0.5rem;">
{% if campaign.start_at <= now and campaign.end_at >= now %}
<span style="font-weight: 600; color: #28a745">Active</span>
{% elif campaign.start_at > now %}
<span style="font-weight: 600">Upcoming</span>
{% else %}
<span style="font-weight: 600; color: #dc3545">Expired</span>
{% endif %}
</div>
</div>
</article>
{% endfor %}
</div>
</div>
</div>
</div>
</section>
{% endfor %}
{% else %}
<section style="text-align: center; padding: 3rem 1rem;">
<h2 style="margin: 0 0 1rem 0;">No Campaigns Found</h2>
<p style="margin: 0; font-size: 1.1rem;">
No campaigns match your current filters.
<br />
Try adjusting your search criteria.
</p>
</section>
{% endif %}
<!-- Pagination -->
{% if is_paginated %}
<!-- {{ page_obj.paginator.count }} total campaigns, showing {{ page_obj.start_index }} to {{ page_obj.end_index }} on page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }} -->
<nav style="text-align: center;">
<div>
{% if page_obj.has_previous %}
<a href="?{% if selected_status %}status={{ selected_status }}&{% endif %}{% if selected_game %}game={{ selected_game }}&{% endif %}{% if selected_per_page != 100 %}per_page={{ selected_per_page }}&{% endif %}page=1">[first]</a>
<a href="?{% if selected_status %}status={{ selected_status }}&{% endif %}{% if selected_game %}game={{ selected_game }}&{% endif %}{% if selected_per_page != 100 %}per_page={{ selected_per_page }}&{% endif %}page={{ page_obj.previous_page_number }}"
aria-label="Previous">[previous]</a>
{% else %}
<span>[first]</span>
<span>[previous]</span>
{% endif %}
{% for num in page_obj.paginator.page_range %}
{% if page_obj.number == num %}
<span>{{ num }}</span>
{% elif num > page_obj.number|add:'-10' and num < page_obj.number|add:'10' %}
<a href="?{% if selected_status %}status={{ selected_status }}&{% endif %}{% if selected_game %}game={{ selected_game }}&{% endif %}{% if selected_per_page != 100 %}per_page={{ selected_per_page }}&{% endif %}page={{ num }}">{{ num }}</a>
{% elif num == 1 or num == page_obj.paginator.num_pages %}
<a href="?{% if selected_status %}status={{ selected_status }}&{% endif %}{% if selected_game %}game={{ selected_game }}&{% endif %}{% if selected_per_page != 100 %}per_page={{ selected_per_page }}&{% endif %}page={{ num }}">{{ num }}</a>
{% elif num == page_obj.number|add:'-10' or num == page_obj.number|add:'10' %}
<span>...</span>
{% endif %}
{% endfor %}
{% if page_obj.has_next %}
<a href="?{% if selected_status %}status={{ selected_status }}&{% endif %}{% if selected_game %}game={{ selected_game }}&{% endif %}{% if selected_per_page != 100 %}per_page={{ selected_per_page }}&{% endif %}page={{ page_obj.next_page_number }}">[next]</a>
<a href="?{% if selected_status %}status={{ selected_status }}&{% endif %}{% if selected_game %}game={{ selected_game }}&{% endif %}{% if selected_per_page != 100 %}per_page={{ selected_per_page }}&{% endif %}page={{ page_obj.paginator.num_pages }}">[last]</a>
{% else %}
<span>[next]</span>
<span>[last]</span>
{% endif %}
</div>
<small style="display: block; margin-top: 1rem;">
Showing {{ page_obj.start_index }} to {{ page_obj.end_index }} of {{ page_obj.paginator.count }}
campaigns (Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }})
</small>
</nav>
{% endif %}
</main>
{% endblock content %}