usethesource: Add candidate option to show/hide download disclaimer
This commit is contained in:
parent
c0a4fe5f39
commit
296f29c84b
5 changed files with 34 additions and 3 deletions
|
@ -22,6 +22,7 @@ class CandidateAdmin(admin.ModelAdmin):
|
|||
'release_date',
|
||||
'source_url',
|
||||
'binary_url',
|
||||
'show_download_disclaimer',
|
||||
'description',
|
||||
]
|
||||
inlines = [CommentInline]
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.19 on 2024-03-15 03:25
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('usethesource', '0006_alter_comment_time'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='candidate',
|
||||
name='show_download_disclaimer',
|
||||
field=models.BooleanField(default=True),
|
||||
),
|
||||
]
|
|
@ -22,6 +22,7 @@ class Candidate(models.Model):
|
|||
description = models.TextField(blank=True)
|
||||
source_url = models.URLField()
|
||||
binary_url = models.URLField(blank=True)
|
||||
show_download_disclaimer = models.BooleanField(default=True)
|
||||
ordering = models.SmallIntegerField(default=0)
|
||||
email_message_id = models.CharField(max_length=255, default=gen_message_id)
|
||||
|
||||
|
|
|
@ -23,8 +23,19 @@
|
|||
<p><strong>Released</strong>: {{ candidate.release_date }}</p>
|
||||
</div>
|
||||
<div class="mt2">
|
||||
<div><a href="{% url 'usethesource:download' slug=candidate.slug download_type='source' %}" class="white bg-green db pv2 ph3 mb2">Download source</a></div>
|
||||
<div><a href="{% url 'usethesource:download' slug=candidate.slug download_type='binary' %}" class="white bg-green db pv2 ph3">Download image</a></div>
|
||||
{% if candidate.show_download_disclaimer %}
|
||||
<div><a href="{% url 'usethesource:download' slug=candidate.slug download_type='source' %}" class="white bg-green db pv2 ph3 mb2">Download source</a></div>
|
||||
<div><a href="{% url 'usethesource:download' slug=candidate.slug download_type='binary' %}" class="white bg-green db pv2 ph3">Download image</a></div>
|
||||
{% else %}
|
||||
<form method="post" action="{% url 'usethesource:download' slug=candidate.slug download_type='source' %}">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="white b bg-green db w-100 pv2 ph3 bn mb2">Download source</button>
|
||||
</form>
|
||||
<form method="post" action="{% url 'usethesource:download' slug=candidate.slug download_type='binary' %}">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="white b bg-green db w-100 pv2 ph3 bn mb2">Download image</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ def download_page(request, slug, download_type):
|
|||
if request.method == 'POST':
|
||||
form = DownloadForm(request.POST)
|
||||
url = candidate.source_url if download_type == 'source' else candidate.binary_url
|
||||
if form.is_valid():
|
||||
if not candidate.show_download_disclaimer or form.is_valid():
|
||||
return redirect(url)
|
||||
return render(
|
||||
request,
|
||||
|
|
Loading…
Reference in a new issue