Changeset - 296f29c84bb2
[Not reviewed]
0 4 1
Ben Sturmfels (bsturmfels) - 2 months ago 2024-03-15 07:39:49
ben@sturm.com.au
usethesource: Add candidate option to show/hide download disclaimer
5 files changed with 34 insertions and 3 deletions:
0 comments (0 inline, 0 general)
conservancy/usethesource/admin.py
Show inline comments
...
 
@@ -24,2 +24,3 @@ class CandidateAdmin(admin.ModelAdmin):
 
        'binary_url',
 
        'show_download_disclaimer',
 
        'description',
conservancy/usethesource/migrations/0007_candidate_show_download_disclaimer.py
Show inline comments
 
new file 100644
 
# 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),
 
        ),
 
    ]
conservancy/usethesource/models.py
Show inline comments
...
 
@@ -24,2 +24,3 @@ class Candidate(models.Model):
 
    binary_url = models.URLField(blank=True)
 
    show_download_disclaimer = models.BooleanField(default=True)
 
    ordering = models.SmallIntegerField(default=0)
conservancy/usethesource/templates/usethesource/candidate.html
Show inline comments
...
 
@@ -25,4 +25,15 @@
 
      <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>
conservancy/usethesource/views.py
Show inline comments
...
 
@@ -24,3 +24,3 @@ def download_page(request, slug, download_type):
 
        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)
0 comments (0 inline, 0 general)