Update to Django 1.8

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2016-08-01 20:14:50 +12:00
parent 211e2fa3a5
commit f268a3cfdb
5 changed files with 20 additions and 13 deletions

12
README
View File

@ -12,19 +12,19 @@ Setup
In order to make use of this application you will need: In order to make use of this application you will need:
* Python 3.4+ * Python 3.4+
* Django 1.6.x - tested with 1.6.10; newer versions may work, but * Django 1.8.x - tested with 1.8.13; newer versions may work, but
the application has not been tested with 1.7 or newer. the application has not been tested with 1.9 or newer.
* For production usage, a web server set up to host Django applications * For production usage, a web server set up to host Django applications
(not needed for local-only testing) (not needed for local-only testing)
* A database supported by Django (SQLite, MySQL, etc.). Django takes * A database supported by Django (SQLite, MySQL, etc.). Django takes
care of creating the database itself, you just need to ensure that the care of creating the database itself, you just need to ensure that the
database server (if not using SQLite) is configured and running. database server (if not using SQLite) is configured and running.
* The following third-party Django modules (tested versions listed): * The following third-party Django modules (tested versions listed):
* django-registration (1.0) * django-registration (2.1)
* django-reversion (1.8.7) * django-reversion (1.9.3)
* django-reversion-compare (0.4.0) * django-reversion-compare (0.5.6)
* django-simple-captcha (0.4.6) * django-simple-captcha (0.4.6)
* django-nvd3 (0.9.7) * django-nvd3 (0.14.2)
* djangorestframework (3.2.5) * djangorestframework (3.2.5)
* django-cors-headers (1.1.0) * django-cors-headers (1.1.0)
* On the machine that will run the backend update script (which does not * On the machine that will run the backend update script (which does not

View File

@ -4,6 +4,7 @@
# #
# Licensed under the MIT license, see COPYING.MIT for details # Licensed under the MIT license, see COPYING.MIT for details
from collections import OrderedDict
from layerindex.models import LayerItem, LayerBranch, LayerMaintainer, LayerNote, RecipeChangeset, RecipeChange, ClassicRecipe from layerindex.models import LayerItem, LayerBranch, LayerMaintainer, LayerNote, RecipeChangeset, RecipeChange, ClassicRecipe
from django import forms from django import forms
from django.core.validators import URLValidator, RegexValidator, EmailValidator from django.core.validators import URLValidator, RegexValidator, EmailValidator
@ -66,10 +67,14 @@ class EditLayerForm(forms.ModelForm):
if user.is_authenticated(): if user.is_authenticated():
del self.fields['captcha'] del self.fields['captcha']
# Ensure repo subdir appears after repo URL # Ensure repo subdir appears after repo URL
field_order = self.fields.keyOrder field_order = list(self.fields.keys())
field_order.pop(field_order.index('vcs_subdir')) field_order.pop(field_order.index('vcs_subdir'))
name_pos = field_order.index('vcs_url') + 1 name_pos = field_order.index('vcs_url') + 1
field_order.insert(name_pos, 'vcs_subdir') field_order.insert(name_pos, 'vcs_subdir')
new_fields = OrderedDict()
for field in field_order:
new_fields[field] = self.fields[field]
self.fields = new_fields
self.fields['vcs_subdir'].initial = layerbranch.vcs_subdir self.fields['vcs_subdir'].initial = layerbranch.vcs_subdir
self.was_saved = False self.was_saved = False

View File

@ -53,10 +53,12 @@ def runcmd(cmd, destdir=None, printerr=True, logger=None):
return output return output
def setup_django(): def setup_django():
import django
# Get access to our Django model # Get access to our Django model
newpath = os.path.abspath(os.path.dirname(__file__) + '/..') newpath = os.path.abspath(os.path.dirname(__file__) + '/..')
sys.path.append(newpath) sys.path.append(newpath)
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
django.setup()
def logger_create(name): def logger_create(name):
logger = logging.getLogger(name) logger = logging.getLogger(name)

View File

@ -121,7 +121,7 @@ def edit_layer_view(request, template_name, branch='master', slug=None):
form = EditLayerForm(request.user, layerbranch, request.POST, instance=layeritem) form = EditLayerForm(request.user, layerbranch, request.POST, instance=layeritem)
maintainerformset = LayerMaintainerFormSet(request.POST, instance=layerbranch) maintainerformset = LayerMaintainerFormSet(request.POST, instance=layerbranch)
if form.is_valid() and maintainerformset.is_valid(): if form.is_valid() and maintainerformset.is_valid():
with transaction.commit_on_success(): with transaction.atomic():
reset_last_rev = False reset_last_rev = False
form.save() form.save()
layerbranch.layer = layeritem layerbranch.layer = layeritem

View File

@ -1,9 +1,9 @@
Django==1.6.11 Django==1.8.13
django-cors-headers==1.1.0 django-cors-headers==1.1.0
django-nvd3==0.9.7 django-nvd3==0.9.7
django-registration==1.0 django-registration==2.1
django-reversion==1.8.7 django-reversion==1.9.3
django-reversion-compare==0.4.0 django-reversion-compare==0.5.6
django-simple-captcha==0.4.6 django-simple-captcha==0.4.6
djangorestframework==3.2.5 djangorestframework==3.2.5
gitdb==0.6.4 gitdb==0.6.4
@ -11,7 +11,7 @@ GitPython==2.0.5
Jinja2==2.8 Jinja2==2.8
MarkupSafe==0.23 MarkupSafe==0.23
mysqlclient==1.3.7 mysqlclient==1.3.7
Pillow==3.2.0 Pillow==3.3.0
python-nvd3==0.14.2 python-nvd3==0.14.2
python-slugify==1.1.4 python-slugify==1.1.4
six==1.10.0 six==1.10.0