Skip to content

Commit

Permalink
Error fix for curriculo message and formulario message
Browse files Browse the repository at this point in the history
  • Loading branch information
FredMagas committed Aug 9, 2024
1 parent 397a5a8 commit 0a5f880
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
10 changes: 3 additions & 7 deletions fredmagaweb/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,9 @@ <h4>
<a href="{% url 'download_curriculo' curriculo.id %}" target="_blank">
<button class="btn-curriculo">Download CV</button>
</a>
{% else %}
{% if messages %}
<ul>
{% for message in messages %}
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
{% endfor %}
</ul>
{% else %}
{% if curriculo_message %}
<p>{{ curriculo_message }}</p>
{% endif %}
{% endif %}
</div>
Expand Down
5 changes: 3 additions & 2 deletions fredmagaweb/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ def index(request):
portfolio_items = PortfolioItem.objects.filter(publicado=True)
curriculo = Curriculo.objects.last() # Obtém o currículo mais recente

curriculo_message = None
if not curriculo:
messages.error(request, 'O currículo não está disponível para download no momento.')
curriculo_message = 'O currículo não está disponível para download no momento.'

if request.method == 'POST':
form = ContatoForm(request.POST)
Expand Down Expand Up @@ -76,7 +77,7 @@ def index(request):
else:
form = ContatoForm()

return render(request, 'index.html', {'portfolio_items': portfolio_items,'curriculo': curriculo, 'form': form})
return render(request, 'index.html', {'portfolio_items': portfolio_items,'curriculo': curriculo, 'form': form, 'curriculo_message': curriculo_message})

def download_curriculo(request, curriculo_id):
curriculo = get_object_or_404(Curriculo, id=curriculo_id)
Expand Down

0 comments on commit 0a5f880

Please sign in to comment.