Add Twitch directory URL property to Game model and update dashboard to handle channel display logic
This commit is contained in:
parent
fc52a94284
commit
c8cc6d83df
2 changed files with 44 additions and 24 deletions
|
|
@ -85,34 +85,47 @@ Hover over the end time to see the exact date and time.
|
||||||
text-align: left">
|
text-align: left">
|
||||||
Duration: {{ campaign.start_at|timesince:campaign.end_at }}
|
Duration: {{ campaign.start_at|timesince:campaign.end_at }}
|
||||||
</time>
|
</time>
|
||||||
{% if campaign.allow_channels.all %}
|
<div style="margin-top: 0.5rem; font-size: 0.8rem; color: #444;">
|
||||||
<div style="margin-top: 0.5rem; font-size: 0.8rem; color: #444;">
|
<strong>Channels:</strong>
|
||||||
<strong>Channels:</strong>
|
<ul style="margin: 0.25rem 0 0 0;
|
||||||
<ul style="margin: 0.25rem 0 0 0;
|
padding-left: 1rem;
|
||||||
padding-left: 1rem;
|
list-style-type: none">
|
||||||
list-style-type: none">
|
{% if campaign.allow_is_enabled %}
|
||||||
{% for channel in campaign.allow_channels.all %}
|
{% if campaign.allow_channels.all %}
|
||||||
{% if forloop.counter <= 5 %}
|
{% for channel in campaign.allow_channels.all %}
|
||||||
<li style="margin-bottom: 0.1rem;">
|
{% if forloop.counter <= 5 %}
|
||||||
<a href="https://twitch.tv/{{ channel.name }}"
|
<li style="margin-bottom: 0.1rem;">
|
||||||
target="_blank"
|
<a href="https://twitch.tv/{{ channel.name }}"
|
||||||
rel="noopener noreferrer"
|
target="_blank"
|
||||||
style="color: #9146ff;
|
rel="noopener noreferrer"
|
||||||
text-decoration: none"
|
title="Watch {{ channel.display_name }} on Twitch">
|
||||||
title="Watch {{ channel.display_name }} on Twitch">
|
{{ channel.display_name }}
|
||||||
{{ channel.display_name }}
|
</a>
|
||||||
</a>
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% if campaign.allow_channels.all|length > 5 %}
|
||||||
|
<li style="margin-bottom: 0.1rem; color: #666; font-style: italic;">
|
||||||
|
... and {{ campaign.allow_channels.all|length|add:"-5" }} more
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
|
||||||
{% if campaign.allow_channels.all|length > 5 %}
|
|
||||||
<li style="margin-bottom: 0.1rem; color: #666; font-style: italic;">
|
|
||||||
... and {{ campaign.allow_channels.all|length|add:"-5" }} more
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
{% else %}
|
||||||
</div>
|
{% if campaign.game.twitch_directory_url %}
|
||||||
{% endif %}
|
<li>
|
||||||
|
<a href="{{ campaign.game.twitch_directory_url }}"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
title="Find streamers playing {{ campaign.game.display_name }} with drops enabled">
|
||||||
|
Go to a participating live channel
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% else %}
|
||||||
|
<li>Failed to get Twitch directory URL :(</li>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,13 @@ class Game(models.Model):
|
||||||
return self.slug
|
return self.slug
|
||||||
return self.id
|
return self.id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def twitch_directory_url(self) -> str:
|
||||||
|
"""Return the Twitch directory URL for this game with drops filter if slug is available."""
|
||||||
|
if self.slug:
|
||||||
|
return f"https://www.twitch.tv/directory/category/{self.slug}?filter=drops"
|
||||||
|
return ""
|
||||||
|
|
||||||
|
|
||||||
class Channel(models.Model):
|
class Channel(models.Model):
|
||||||
"""Represents a Twitch channel that can participate in drop campaigns."""
|
"""Represents a Twitch channel that can participate in drop campaigns."""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue