Rewrite everything

This commit is contained in:
2024-09-09 05:38:43 +02:00
parent 5334b6904e
commit ed0a7755bf
18 changed files with 991 additions and 622 deletions

View File

@ -1,98 +1,94 @@
{% extends "base.html" %}
{% block content %}
<div class="container my-5">
<div class="text-center">
<header class="h2 mt-4">
{{ game.name }}
</header>
<img src="{{ game.box_art_url }}" alt="{{ game.name }} box art" class="img-fluid rounded" height="283"
width="212" loading="lazy">
</div>
<div class="container">
<h2>{{ game.name }}</h2>
<img src="{{ game.box_art_url }}" alt="{{ game.name }} box art" height="283" width="212">
<div class="mt-5">
<h3 class="h4">Game Details</h3>
<ul class="list-group">
<li class="list-group-item"><strong>Twitch ID:</strong> {{ game.twitch_id }}</li>
<li class="list-group-item"><strong>Game URL:</strong> <a href="{{ game.url }}"
target="_blank">{{ game.url }}</a></li>
<li class="list-group-item"><strong>Game name:</strong> {{ game.name }}</li>
<li class="list-group-item"><strong>Game box art URL:</strong> <a href="{{ game.box_art_url }}"
target="_blank">{{ game.box_art_url }}</a></li>
</ul>
</div>
<h3>Game Details</h3>
<table class="table table-hover table-sm table-striped" cellspacing="0">
<tr>
<td><strong>Twitch ID:</strong></td>
<td>{{ game.pk }}</td>
</tr>
<tr>
<td><strong>Game URL:</strong></td>
<td><a href="{{ game.game_url }}" target="_blank">{{ game.game_url }}</a></td>
</tr>
<tr>
<td><strong>Game name:</strong></td>
<td>{{ game.name }}</td>
</tr>
<tr>
<td><strong>Game box art URL:</strong></td>
<td><a href="{{ game.box_art_url }}" target="_blank">{{ game.box_art_url }}</a></td>
</tr>
</table>
<div class="mt-5">
<h3 class="h4">Organization</h3>
<ul class="list-group">
<h3>Organization</h3>
<table class="table table-hover table-sm table-striped" cellspacing="0">
<tr>
{% if game.org %}
<li class="list-group-item">
<a href="#">{{ game.org.name }} - <span class="text-muted">{{ game.org.id }}</span></a>
</li>
<td><a href="#">{{ game.org.name }} - <span class="text-muted">{{ game.org.pk }}</span></a></td>
{% else %}
<li class="list-group-item">No organization associated with this game.</li>
<td>No organization associated with this game.</td>
{% endif %}
</ul>
</div>
</tr>
</table>
<div class="mt-5">
<h3 class="h4">Drop Campaigns</h3>
{% if game.drop_campaigns.all %}
<div>
{% for drop_campaign in game.drop_campaigns.all %}
<div>
<h2>
{{ drop_campaign.name }}
</h2>
<div>
<div>
<img src="{{ drop_campaign.image_url }}" alt="{{ drop_campaign.name }} image"
class="img-fluid mb-3 rounded">
<p><strong>Status:</strong> {{ drop_campaign.status }}</p>
<p>{{ drop_campaign.description }}</p>
<p><strong>Starts at:</strong> {{ drop_campaign.starts_at }}</p>
<p><strong>Ends at:</strong> {{ drop_campaign.ends_at }}</p>
<p><strong>More details:</strong> <a href="{{ drop_campaign.details_url }}"
target="_blank">{{ drop_campaign.details_url }}</a></p>
<p><strong>Account Link:</strong> <a href="{{ drop_campaign.account_link_url }}"
target="_blank">{{ drop_campaign.account_link_url }}</a></p>
<h3>Drop Campaigns</h3>
{% if game.drop_campaigns.all %}
{% for drop_campaign in game.drop_campaigns.all %}
<br>
<h2>{{ drop_campaign.name }}</h2>
<table class="table table-hover table-sm table-striped" cellspacing="0">
<tr>
<td><strong>Campaign Name:</strong></td>
<td>{{ drop_campaign.name }}</td>
</tr>
<tr>
<td><img src="{{ drop_campaign.image_url }}" alt="{{ drop_campaign.name }} image"></td>
<td>
<p><strong>Status:</strong> {{ drop_campaign.status }}</p>
<p><strong>Description:</strong> {{ drop_campaign.description }}</p>
<p><strong>Starts at:</strong> {{ drop_campaign.starts_at }}</p>
<p><strong>Ends at:</strong> {{ drop_campaign.ends_at }}</p>
<p><strong>More details:</strong> <a href="{{ drop_campaign.details_url }}"
target="_blank">{{ drop_campaign.details_url }}</a></p>
<p><strong>Account Link:</strong> <a href="{{ drop_campaign.account_link_url }}"
target="_blank">{{ drop_campaign.account_link_url }}</a></p>
</td>
</tr>
</table>
<h2 class="mt-4">Time-Based Drops</h2>
{% if drop_campaign.drops.all %}
<div>
{% for drop in drop_campaign.drops.all %}
<hr>
<div>
<h3 class="mb-2">{{ drop.name }}</h3>
{% for benefit in drop.benefits.all %}
<img src="{{ benefit.image_url }}" alt="{{ benefit.name }} image"
class="img-fluid rounded mb-2">
<p><strong>Required Subscriptions:</strong> {{ drop.required_subs }}</p>
<p><strong>Required Minutes Watched:</strong> {{ drop.required_minutes_watched }}</p>
<p><strong>Starts at:</strong> {{ drop.starts_at }}</p>
<p><strong>Ends at:</strong> {{ drop.ends_at }}</p>
<p><strong>Entitlement Limit:</strong> {{ benefit.entitlement_limit }}</p>
<p><strong>Available on iOS:</strong> {{ benefit.is_ios_available }}</p>
<p><strong>Twitch Created At:</strong> {{ benefit.twitch_created_at }}</p>
{% empty %}
<div>No benefits available for this drop.</div>
{% endfor %}
</div>
{% empty %}
<div>No time-based drops available for this campaign.</div>
{% endfor %}
</div>
{% else %}
<p>No time-based drops available for this campaign.</p>
{% endif %}
</div>
</div>
</div>
{% if drop_campaign.drops.all %}
<table class="table table-hover table-sm table-striped" cellspacing="0">
<tr>
<th>ID</th>
<th>Item Name</th>
<th>Minutes</th>
<th>Image</th>
<th>Benefit Name</th>
</tr>
{% for item in drop_campaign.drops.all %}
<tr>
<td>{{ item.pk }}</td>
<td>{{ item.name }}</td>
<td>{{ item.required_minutes_watched }}</td>
{% for benefit in item.benefits.all %}
<td><img src="{{ benefit.image_url }}" alt="{{ benefit.name }} reward image" height="50" width="50">
</td>
<td>{{ benefit.name }}</td>
{% endfor %}
</div>
{% else %}
<p>No drop campaigns available for this game.</p>
{% endif %}
</div>
</tr>
{% endfor %}
</table>
{% else %}
<p>No items associated with this drop campaign.</p>
{% endif %}
{% endfor %}
{% else %}
<p>No drop campaigns associated with this game.</p>
{% endif %}
</div>
{% endblock content %}

View File

@ -1,27 +1,176 @@
{% extends "base.html" %}
{% load static %}
{% load campaign_tags %}
{% load game_tags %}
{% load custom_filters %}
{% load time_filters %}
{% block content %}
<div class="container mt-4">
{% include "partials/info_box.html" %}
{% include "partials/news.html" %}
<h2>
Reward campaign -
<span class="d-inline text-muted">
{{ reward_campaigns.count }}
campaign{{ reward_campaigns.count|pluralize }}
</span>
</h2>
{% for campaign in reward_campaigns %}
{% render_campaign campaign %}
{% endfor %}
<h2>
Drop campaigns -
<span class="d-inline text-muted ">{{ games.count }} game{{ games.count|pluralize }}</span>
</h2>
{% for game in games %}
{% render_game_card game %}
{% endfor %}
<!-- Reward Campaigns Section -->
<section class="reward-campaigns">
<h2>
Reward Campaigns -
<span class="d-inline text-muted">
{{ reward_campaigns.count }} campaign{{ reward_campaigns.count|pluralize }}
</span>
</h2>
<!-- Loop through reward campaigns -->
{% for campaign in reward_campaigns %}
<div class="card mb-4 shadow-sm" id="campaign-{{ campaign.twitch_id }}">
<div class="row g-0">
<!-- Campaign Image -->
<div class="col-md-2">
<img src="{{ campaign.image_url }}" alt="{{ campaign.name }}" class="img-fluid rounded-start"
height="283" width="212" loading="lazy">
</div>
<!-- Campaign Details -->
<div class="col-md-10">
<div class="card-body">
<h2 class="card-title h5">
<a href="#campaign-{{ campaign.twitch_id }}" class="plain-text-item">
{{ campaign.name }}
</a>
</h2>
<p class="card-text text-muted">{{ campaign.summary }}</p>
<p class="mb-2 text-muted">
Ends in:
<abbr
title="{{ campaign.starts_at|date:'l d F H:i %Z' }} - {{ campaign.ends_at|date:'l d F H:i %Z' }}">
{{ campaign.ends_at|timesince }}
</abbr>
</p>
<a href="{{ campaign.external_url }}" class="btn btn-primary" target="_blank">Learn More</a>
<!-- Instructions (if any) -->
{% if campaign.instructions %}
<div class="mt-3">
<h3 class="h6">Instructions</h3>
<p>{{ campaign.instructions|safe }}</p>
</div>
{% endif %}
<!-- Rewards (if any) -->
{% if campaign.rewards.all %}
<div class="mt-3">
<h3 class="h6">Rewards</h3>
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-2">
{% for reward in campaign.rewards.all %}
<div class="col d-flex align-items-center position-relative">
<img src="{{ reward.thumbnail_image_url }}" alt="{{ reward.name }} reward image"
class="img-fluid rounded me-3" height="50" width="50" loading="lazy">
<div><strong>{{ reward.name }}</strong></div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endfor %}
</section>
<!-- Drop Campaigns Section -->
<section class="drop-campaigns">
<h2>
Drop Campaigns -
<span class="d-inline text-muted">{{ games.count }} game{{ games.count|pluralize }}</span>
</h2>
<!-- Loop through games -->
{% for game in games %}
<div class="card mb-4 shadow-sm">
<div class="row g-0">
<!-- Game Box Art -->
<div class="col-md-2">
<img src="{{ game.box_art_url|default:'https://static-cdn.jtvnw.net/ttv-static/404_boxart.jpg' }}"
alt="{{ game.name|default:'Game name unknown' }} box art" class="img-fluid rounded-start"
height="283" width="212" loading="lazy">
</div>
<!-- Game Details -->
<div class="col-md-10">
<div class="card-body">
<h2 class="card-title h5">
<a href="{% url 'game' game.twitch_id %}" class="text-decoration-none">
{{ game.name|default:'Unknown' }}
</a>
-
<a href="https://www.twitch.tv/directory/category/{{ game.slug|default:'game-name-unknown' }}"
class="text-decoration-none text-muted">Twitch</a>
</h2>
<!-- Loop through campaigns for each game -->
{% for campaign in game.drop_campaigns.all %}
<div class="mt-4">
<h4 class="h6">{{ campaign.name }}</h4>
<a href="{{ campaign.details_url }}" class="text-decoration-none">Details</a>
{% if campaign.details_url != campaign.account_link_url %}
| <a href="{{ campaign.account_link_url }}" class="text-decoration-none">Link Account</a>
{% endif %}
<p class="mb-2 text-muted">
Ends in:
<abbr
title="{{ campaign.starts_at|date:'l d F H:i' }} - {{ campaign.ends_at|date:'l d F H:i' }}">
{{ campaign.ends_at|timeuntil }}
</abbr>
</p>
<!-- Drop Benefits Table -->
<div class="table-responsive">
<table class="table table-striped table-hover align-middle">
<thead>
<tr>
<th>Benefit Image</th>
<th>Benefit Name</th>
<th>Required Minutes Watched</th>
</tr>
</thead>
<tbody>
{% for drop in campaign.drops.all %}
{% if drop.benefits.exists %}
{% for benefit in drop.benefits.all %}
<tr>
<td>
<img src="{{ benefit.image_url|default:'https://static-cdn.jtvnw.net/ttv-static/404_boxart.jpg' }}"
alt="{{ benefit.name|default:'Unknown' }}" class="img-fluid rounded"
height="50" width="50" loading="lazy">
</td>
<td>
<abbr title="{{ drop.name|default:'Unknown' }}">
{{ benefit.name|default:'Unknown' }}
</abbr>
</td>
<td>{{ drop.required_minutes_watched|minutes_to_hours }}</td>
</tr>
{% endfor %}
{% else %}
<tr>
<td>
<img src="https://static-cdn.jtvnw.net/ttv-static/404_boxart.jpg"
alt="{{ drop.name|default:'Unknown' }}" class="img-fluid rounded"
height="50" width="50" loading="lazy">
</td>
<td>{{ drop.name|default:'Unknown' }}</td>
<td>N/A</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
</div>
{% endfor %}
</section>
</div>
{% endblock content %}