I have 3 videos saved in the Postgres database where I set a star_date
and the video only appears in the template when start_date <= date.today()
My problem is in template . I have 3 buttons, one for each video, my idea is that any video that does not have start_date <= date.today()
has its button with opacity: 0.3;
But the way I'm doing, when any video is active it receives the button with images/01.png
and <a href="0">
and anyone who is inactive receives the button with images/02.png
and <a href="">
When active I need to have images/01.png
to have <a href="0">
images/02.png
have <a href="1">
and images/03.png
has <a href="2">
I'm doing the following:
video-list.html:
<div class="numbers-video">
<!-- MOSTRA VIDEOS ATIVOS -->
{%for video in videos%}
{%if video.is_visible%}
<a href="0">
<img src="{% static 'images/01.png' %}" alt="01">
</a>
{%endif%}
<!-- MOSTRA VIDEOS INATIVOS -->
{%if video.is_visible == False%}
<a href="">
<img class="opacity-button" src="{% static 'images/02.png' %}" alt="02">
</a>
{%endif%}
{%endfor%}
</div>
views.py:
# LISTA DOS VIDEOS
def video_list(request, position):
if 'lead_id' in request.session:
video = Video.objects.filter(position=position).first()
videos = Video.objects.order_by("position").all()
return render(request, 'video-list.html', {'video': video, 'position':position, 'videos': videos})
return redirect('registrations:create_lead')
models.py:
class Video(models.Model):
url = models.CharField(max_length=500, verbose_name='Link Embed')
title = models.CharField(max_length=255, verbose_name='Título')
description = models.TextField(max_length=1000, verbose_name='Descrição do video')
start_date = models.DateField(verbose_name='Estará disponível quando')
position = models.IntegerField(verbose_name='Qual posição')
@property
def is_visible(self):
return self.start_date <= date.today()
Can anyone give me this strength?