usethesource: Require agreement to download
This commit is contained in:
parent
b8a626b955
commit
e340f18ec9
3 changed files with 34 additions and 16 deletions
13
conservancy/usethesource/forms.py
Normal file
13
conservancy/usethesource/forms.py
Normal file
|
@ -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).")
|
|
@ -5,13 +5,19 @@
|
|||
|
||||
<section class="pa2 mt4 mb5">
|
||||
<h2 class="f2 lh-title ttu mt0">Download</h2>
|
||||
<p><strong>File</strong>: {{ download_url }}</p>
|
||||
|
||||
<p>By downloading this, you agree to use it only for the purposes of GPL compliance checking, unless otherwise permitted by the license.</p>
|
||||
|
||||
<div style="display: flex">
|
||||
<a href="{% url 'usethesource:candidate' slug=candidate.slug %}" class="white bg-silver dib pv2 ph3 mb2 mr2">Back</a>
|
||||
<a href="{{ download_url }}" class="white bg-green dib pv2 ph3 mb2">Download</a>
|
||||
<form method="post" action="{% url 'usethesource:download' slug=candidate.slug download_type=download_type %}">
|
||||
{% csrf_token %}
|
||||
{% if form.agree.errors %}
|
||||
<div class="br2 bg-washed-red ph4 pv3 mb2">{{ form.agree.errors }}</div>
|
||||
{% endif %}
|
||||
<div class="mb3" style="display: flex; align-items: start">
|
||||
<span class="mr2">{{ form.agree }}</span> {{ form.agree.label_tag }}
|
||||
</div>
|
||||
<div style="display: flex">
|
||||
<a href="{% url 'usethesource:candidate' slug=candidate.slug %}" class="b white bg-silver dib pv2 ph3 mb2 mr2">Back</a>
|
||||
<button type="submit" class="b white bg-green dib pv2 ph3 bn mb2">Download</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
{% endblock content %}
|
||||
|
|
|
@ -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)
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue