[extensions-web/filter-sort-ui: 2/20] Make sure extension authors can distribute extensions under the GPLv2



commit c5327c4c9215185309873fe1e32d53e6f0912f6d
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri Dec 23 12:25:47 2011 -0500

    Make sure extension authors can distribute extensions under the GPLv2

 sweettooth/extensions/forms.py                     |    3 +++
 .../extensions/templates/extensions/upload.html    |   10 ++++++++++
 sweettooth/extensions/views.py                     |   17 ++++++++++++-----
 3 files changed, 25 insertions(+), 5 deletions(-)
---
diff --git a/sweettooth/extensions/forms.py b/sweettooth/extensions/forms.py
index a718b50..c5fde42 100644
--- a/sweettooth/extensions/forms.py
+++ b/sweettooth/extensions/forms.py
@@ -3,3 +3,6 @@ from django import forms
 
 class UploadForm(forms.Form):
     source = forms.FileField()
+    gplv2_compliant = forms.BooleanField(label="""
+I verify that my extension can be distributed under the terms of the GPLv2+
+""".strip())
diff --git a/sweettooth/extensions/templates/extensions/upload.html b/sweettooth/extensions/templates/extensions/upload.html
index 4b7f43a..eaec864 100644
--- a/sweettooth/extensions/templates/extensions/upload.html
+++ b/sweettooth/extensions/templates/extensions/upload.html
@@ -35,6 +35,16 @@
     {% csrf_token %}
 
     {{ form.source }}
+
+    <br>
+    {{ form.gplv2_compliant }}
+    {{ form.gplv2_compliant.label_tag }}
+
+    <br>
+    {{ form.tos_compliant }}
+    {{ form.tos_compliant.label_tag }}
+
+    <br>
     <input type="submit" value="Upload extension">
   </form>
 
diff --git a/sweettooth/extensions/views.py b/sweettooth/extensions/views.py
index dd855a7..2a0698c 100644
--- a/sweettooth/extensions/views.py
+++ b/sweettooth/extensions/views.py
@@ -343,9 +343,20 @@ def upload_file(request, pk):
     errors = []
     extra_debug = None
 
+    def redirect_to_page():
+        if pk is not None:
+            return redirect('extensions-upload-file', pk=pk)
+        else:
+            return redirect('extensions-upload-file')
+
     if request.method == 'POST':
         form = UploadForm(request.POST, request.FILES)
         if form.is_valid():
+            gplv2_compliant = form.cleaned_data['gplv2_compliant']
+            if not gplv2_compliant:
+                messages.error(request, "You must be able to distribute your extension under the terms of the GPLv2+.")
+                return redirect_to_page()
+
             file_source = form.cleaned_data['source']
 
             try:
@@ -353,11 +364,7 @@ def upload_file(request, pk):
                 uuid = metadata['uuid']
             except (models.InvalidExtensionData, KeyError), e:
                 messages.error(request, "Invalid extension data: %s" % (e.message,))
-
-                if pk is not None:
-                    return redirect('extensions-upload-file', pk=pk)
-                else:
-                    return redirect('extensions-upload-file')
+                return redirect_to_page()
 
             existing = models.Extension.objects.filter(uuid=uuid)
             if pk is None and existing.exists():



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]