diff --git a/conservancy/usethesource/admin.py b/conservancy/usethesource/admin.py index 8d131dc1502dce9e2c77249e0d6cca5a857f7733..6a886813114ca4e199b0b536f3e4dc1d063e6f68 100644 --- a/conservancy/usethesource/admin.py +++ b/conservancy/usethesource/admin.py @@ -22,6 +22,7 @@ class CandidateAdmin(admin.ModelAdmin): 'release_date', 'source_url', 'binary_url', + 'show_download_disclaimer', 'description', ] inlines = [CommentInline] diff --git a/conservancy/usethesource/migrations/0007_candidate_show_download_disclaimer.py b/conservancy/usethesource/migrations/0007_candidate_show_download_disclaimer.py new file mode 100644 index 0000000000000000000000000000000000000000..cb15982ddb570f2ae1075823834c680364e32c9a --- /dev/null +++ b/conservancy/usethesource/migrations/0007_candidate_show_download_disclaimer.py @@ -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), + ), + ] diff --git a/conservancy/usethesource/models.py b/conservancy/usethesource/models.py index 2edb1206fa10a10a3d0d8cc6a5fc1240ea1a2695..8de4e74ab5a9cc1b92f5ec8ca65354cb385d824a 100644 --- a/conservancy/usethesource/models.py +++ b/conservancy/usethesource/models.py @@ -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) diff --git a/conservancy/usethesource/templates/usethesource/candidate.html b/conservancy/usethesource/templates/usethesource/candidate.html index d38444bc982799a74016cb5a4dc8011c976b2e78..b31a11f246b93398f3dbe2342c830446c39e5425 100644 --- a/conservancy/usethesource/templates/usethesource/candidate.html +++ b/conservancy/usethesource/templates/usethesource/candidate.html @@ -23,8 +23,19 @@

Released: {{ candidate.release_date }}

-
Download source
-
Download image
+ {% if candidate.show_download_disclaimer %} +
Download source
+
Download image
+ {% else %} +
+ {% csrf_token %} + +
+
+ {% csrf_token %} + +
+ {% endif %}
diff --git a/conservancy/usethesource/views.py b/conservancy/usethesource/views.py index 6b3c10d66963402a9ee309e356546071883fa4ea..4b7a6be9ff2697a98750bc3c00b6f06a617e00b9 100644 --- a/conservancy/usethesource/views.py +++ b/conservancy/usethesource/views.py @@ -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,