Skip to content

Commit

Permalink
Upgrade to python 3 and Django 1.11.28
Browse files Browse the repository at this point in the history
  • Loading branch information
allo- committed Mar 9, 2020
1 parent 3a604f3 commit bd7a5fa
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions forms.py
Expand Up @@ -2,7 +2,7 @@
from django.utils.translation import ugettext as _
import json, glob, os

from merge import merge
from .merge import merge

# current structure:
# - FirefoxTracking: builtin features, which send data to Mozilla,
Expand Down Expand Up @@ -37,7 +37,7 @@ def __init__(self, *args, **kwargs):
self.fields[option['name']] = forms.ChoiceField(
label=option['label'],
help_text=option['help_text'],
choices = zip(range(len(choices)), choices),
choices = list(zip(list(range(len(choices))), choices)),
initial=option['initial'], required=False)
elif option['type'] == "text":
self.fields[option['name']] = forms.CharField(
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
@@ -1,3 +1,3 @@
Django==1.10.8
Django==1.11.28
django-bootstrap3==6.2.2
django-jquery==1.9.1
10 changes: 5 additions & 5 deletions templates/main.html
Expand Up @@ -128,13 +128,13 @@ <h1>{% trans "Download" %}</h1>
<dd>An archive that only contains the chosen addons.</dd>
</dl>
{% endblocktrans %}
<a href="{% url 'profilemaker.views.download' 'profile.zip' %}" class="btn btn-primary" style="margin-bottom: 1ex">{% bootstrap_icon "download" %} {% trans "Download profile.zip" %}</a>
<a href="{% url 'profilemaker.views.download' 'enterprise_policy.zip' %}" class="btn btn-primary" style="margin-bottom: 1ex">{% bootstrap_icon "download" %} {% trans "Download enterprise_policy.zip" %}</a>
<a href="{% url 'download' 'profile.zip' %}" class="btn btn-primary" style="margin-bottom: 1ex">{% bootstrap_icon "download" %} {% trans "Download profile.zip" %}</a>
<a href="{% url 'download' 'enterprise_policy.zip' %}" class="btn btn-primary" style="margin-bottom: 1ex">{% bootstrap_icon "download" %} {% trans "Download enterprise_policy.zip" %}</a>
<br />
<a href="{% url 'profilemaker.views.download' 'prefs.js' %}" class="btn btn-primary" style="margin-bottom: 1ex">{% bootstrap_icon "download" %} {% trans "Download only prefs.js" %}</a>
<a href="{% url 'profilemaker.views.download' 'prefs.js.txt' %}" class="btn btn-primary" style="margin-bottom: 1ex">{% bootstrap_icon "download" %} {% trans "Open prefs.js in the browser" %}</a>
<a href="{% url 'download' 'prefs.js' %}" class="btn btn-primary" style="margin-bottom: 1ex">{% bootstrap_icon "download" %} {% trans "Download only prefs.js" %}</a>
<a href="{% url 'download' 'prefs.js.txt' %}" class="btn btn-primary" style="margin-bottom: 1ex">{% bootstrap_icon "download" %} {% trans "Open prefs.js in the browser" %}</a>
<br />
<a href="{% url 'profilemaker.views.download' 'addons.zip' %}" class="btn btn-primary" style="margin-bottom: 1ex">{% bootstrap_icon "download" %} {% trans "Download only addons.zip" %}</a>
<a href="{% url 'download' 'addons.zip' %}" class="btn btn-primary" style="margin-bottom: 1ex">{% bootstrap_icon "download" %} {% trans "Download only addons.zip" %}</a>
<br />
{% trans "When you download only the addons.zip, you need to copy the <code>user_pref(\"extensions.autoDisableScopes\", 14);</code> line into your prefs.js, otherwise firefox won't install the addons." %}

Expand Down
5 changes: 3 additions & 2 deletions urls.py
@@ -1,6 +1,7 @@
from django.conf.urls import include, url
from profilemaker.views import main, download

urlpatterns = [
url('^$', 'profilemaker.views.main'),
url('^download/(?P<what>.*)$', 'profilemaker.views.download'),
url('^$', main, name="main"),
url('^download/(?P<what>.*)$', download, name="download"),
]
18 changes: 9 additions & 9 deletions views.py
@@ -1,14 +1,14 @@
from django.shortcuts import render, redirect
from django.core.urlresolvers import reverse
from forms import *
from .forms import *
from django import forms
from django.http import HttpResponse
import os
import zipfile
from StringIO import StringIO
from io import StringIO
import json

from merge import merge
from .merge import merge

AUTOCONFIG_JS = """pref("general.config.filename", "firefox.cfg");
pref("general.config.obscure_value", 0);"""
Expand Down Expand Up @@ -58,7 +58,7 @@ def main(request):
request.session['profile'] = profile_name
form_classes = PROFILES.get(profile_name)[1]
forms, invalid_data = get_forms(request, form_classes)
return redirect(reverse(main) + "#" + forms[0].id)
return redirect(reverse("main") + "#" + forms[0].id)
# start over again
elif request.POST.get("reset", None) == "reset":
request.session.clear()
Expand All @@ -67,9 +67,9 @@ def main(request):
next = request.POST.get("next", "")
form_name = request.POST.get("form_name", "")
if next and not invalid_data:
return redirect(reverse(main) + "#" + next)
return redirect(reverse("main") + "#" + next)
else:
return redirect(reverse(main) + "#" + form_name)
return redirect(reverse("main") + "#" + form_name)
else:
# nothing posted, just render the current page
prefs_js, addons, files_inline, enterprise_policy = generate_prefsjs_and_addonlist(forms, False)
Expand All @@ -79,7 +79,7 @@ def main(request):
'forms': forms,
'prefs_js': prefs_js,
'enterprise_policy': enterprise_policy,
'filenames': addons + files_inline.keys(),
'filenames': addons + list(files_inline.keys()),
'finished': finished
})

Expand All @@ -105,7 +105,7 @@ def generate_prefsjs_and_addonlist(forms, prefsjs_only, pref_type='user_pref'):
config['extensions.autoDisableScopes'] = 14
for key in sorted(config):
value = config[key]
if isinstance(value, basestring):
if isinstance(value, str):
value = '"{0}"'.format(value)
elif isinstance(value, bool):
value = "true" if value else "false"
Expand Down Expand Up @@ -142,7 +142,7 @@ def download(request, what):
pref_type = "pref"

if invalid_data:
return redirect(reverse(main) + "#finish")
return redirect(reverse("main") + "#finish")

prefs, addons, files_inline, enterprise_policy = generate_prefsjs_and_addonlist(forms, prefsjs_only, pref_type)

Expand Down

0 comments on commit bd7a5fa

Please sign in to comment.