diff --git a/conservancy/usethesource/forms.py b/conservancy/usethesource/forms.py new file mode 100644 index 0000000000000000000000000000000000000000..8e3349c5d80754f560a9b3a7cc417d06fbd1f915 --- /dev/null +++ b/conservancy/usethesource/forms.py @@ -0,0 +1,13 @@ +from django import forms + +from .models import Comment + + +class CommentForm(forms.ModelForm): + class Meta: + model = Comment + fields = ['message'] + + +class DownloadForm(forms.Form): + agree = forms.BooleanField(label="I promise and represent that I will not copy, distribute, modify, or otherwise use this source code candidate and/or firmware for any purpose other than to help SFC evaluate the source code candidate for compliance with the terms of the GNU General Public License (any version) (unless and until it is determined that the source code candidate and firmware are entirely governed by one or more software licenses that permit such use beyond such purpose).") diff --git a/conservancy/usethesource/templates/usethesource/download.html b/conservancy/usethesource/templates/usethesource/download.html index 792441c51c0bd9795b1a23f777b6a415493dbe5e..a58c0ad21fe16ca459b15d305abf592298faf582 100644 --- a/conservancy/usethesource/templates/usethesource/download.html +++ b/conservancy/usethesource/templates/usethesource/download.html @@ -5,13 +5,19 @@

Download

-

File: {{ download_url }}

-

By downloading this, you agree to use it only for the purposes of GPL compliance checking, unless otherwise permitted by the license.

- -
- Back - Download -
+
+ {% csrf_token %} + {% if form.agree.errors %} +
{{ form.agree.errors }}
+ {% endif %} +
+ {{ form.agree }} {{ form.agree.label_tag }} +
+
+ Back + +
+
{% endblock content %} diff --git a/conservancy/usethesource/views.py b/conservancy/usethesource/views.py index e97401785e299c65a58aa292a8e7267f7beda0d8..d2acba9d7f8bb422a43f2827f43f62fdb633b786 100644 --- a/conservancy/usethesource/views.py +++ b/conservancy/usethesource/views.py @@ -1,8 +1,8 @@ -from django import forms from django.contrib.admin.views.decorators import staff_member_required from django.shortcuts import get_object_or_404, redirect, render from .models import Candidate, Comment +from .forms import CommentForm, DownloadForm def landing_page(request): @@ -17,20 +17,19 @@ def candidate_page(request, slug): def download_page(request, slug, download_type): candidate = get_object_or_404(Candidate, slug=slug) - url = candidate.source_url if download_type == 'source' else candidate.binary_url + form = DownloadForm() + if request.method == 'POST': + form = DownloadForm(request.POST) + url = candidate.source_url if download_type == 'source' else candidate.binary_url + if form.is_valid(): + return redirect(url) return render( request, 'usethesource/download.html', - {'candidate': candidate, 'download_url': url}, + {'form': form, 'candidate': candidate, 'download_type': download_type}, ) -class CommentForm(forms.ModelForm): - class Meta: - model = Comment - fields = ['message'] - - @staff_member_required def create_comment(request, slug): candidate = get_object_or_404(Candidate, slug=slug)