diff --git a/wooey/__init__.py b/wooey/__init__.py index 761286ed..20166c5b 100644 --- a/wooey/__init__.py +++ b/wooey/__init__.py @@ -1,12 +1,2 @@ from . import version -import os -if version.DJANGO_VERSION >= version.DJ17: - default_app_config = 'wooey.apps.WooeyConfig' -else: - if os.environ.get('TESTING') != 'True' and os.environ.get('WOOEY_BOOTSTRAP') != 'True': - from . import settings as wooey_settings - # we need to call from within wooey_settings so the celery/etc vars are setup - if not wooey_settings.settings.configured: - wooey_settings.settings.configure() - from .apps import WooeyConfig - WooeyConfig().ready() +default_app_config = 'wooey.apps.WooeyConfig' diff --git a/wooey/backend/command_line.py b/wooey/backend/command_line.py index c44ebb9b..b41d74c7 100644 --- a/wooey/backend/command_line.py +++ b/wooey/backend/command_line.py @@ -109,10 +109,7 @@ def bootstrap(env=None, cwd=None): # do the same with urls shutil.move(os.path.join(project_base_dir, 'urls.py'), os.path.join(project_base_dir, 'urls', 'django_urls.py')) env['DJANGO_SETTINGS_MODULE'] = '.'.join([project_name, 'settings', 'user_settings']) - if django_compat.DJANGO_VERSION >= django_compat.DJ17: - subprocess.call(['python', 'manage.py', 'migrate'], env=env, cwd=project_root) - else: - subprocess.call(['python', 'manage.py', 'syncdb', '--noinput'], env=env, cwd=project_root) + subprocess.call(['python', 'manage.py', 'migrate'], env=env, cwd=project_root) subprocess.call(['python', 'manage.py', 'createcachetable'], env=env, cwd=project_root) subprocess.call(['python', 'manage.py', 'collectstatic', '--noinput'], env=env, cwd=project_root) sys.stdout.write("Please enter the project directory {0}, and run python manage.py createsuperuser and" diff --git a/wooey/conf/project_template/settings/wooey_settings.py b/wooey/conf/project_template/settings/wooey_settings.py index 54aa28b2..466645c0 100644 --- a/wooey/conf/project_template/settings/wooey_settings.py +++ b/wooey/conf/project_template/settings/wooey_settings.py @@ -1,5 +1,5 @@ from .django_settings import * -from wooey.version import DJANGO_VERSION, DJ17, DJ110 +from wooey.version import DJANGO_VERSION, DJ110 from django.utils.translation import ugettext_lazy as _ INSTALLED_APPS += ( @@ -23,7 +23,7 @@ ('fr', _('French')), ('ja', _('Japanese')), ('nl', _('Dutch')), - ('zh-hans' if DJANGO_VERSION >= DJ17 else 'zh-cn', _('Simplified Chinese')), + ('zh-hans', _('Simplified Chinese')), ] NEW_MIDDLEWARE = [] diff --git a/wooey/django_compat.py b/wooey/django_compat.py index a711106b..b8a846ca 100644 --- a/wooey/django_compat.py +++ b/wooey/django_compat.py @@ -6,30 +6,6 @@ except RuntimeError: pass -# JSON compatibility fixes -if DJANGO_VERSION < DJ17: - import json - from django.http import HttpResponse - - - class JsonResponse(HttpResponse): - """ - JSON response - # from https://gist.github.com/philippeowagner/3179eb475fe1795d6515 - """ - - def __init__(self, content, mimetype='application/json', status=None, content_type=None, **kwargs): - super(JsonResponse, self).__init__( - content=json.dumps(content), - mimetype=mimetype, - status=status, - content_type=content_type, - ) - - -else: - from django.http import JsonResponse - if DJANGO_VERSION < DJ19: from django.template.base import TagHelperNode, parse_bits else: @@ -40,18 +16,3 @@ def __init__(self, content, mimetype='application/json', status=None, content_ty get_template_from_string = Engine.get_default().from_string else: from django.template.loader import get_template_from_string - - -if DJANGO_VERSION < DJ17: - from django.forms.util import flatatt, format_html - -else: - from django.forms.utils import flatatt, format_html - -def get_cache(cache): - if DJANGO_VERSION < DJ17: - from django.core.cache import get_cache - return get_cache(cache) - else: - from django.core.cache import caches - return caches[cache] diff --git a/wooey/forms/factory.py b/wooey/forms/factory.py index 7d7251d3..2a243252 100644 --- a/wooey/forms/factory.py +++ b/wooey/forms/factory.py @@ -2,20 +2,20 @@ __author__ = 'chris' import copy import json -import six import os from collections import OrderedDict +import six from django import forms +from django.forms.utils import flatatt, format_html from django.http.request import QueryDict from django.utils.safestring import mark_safe -from .scripts import WooeyForm from . import config -from ..backend import utils -from ..models import ScriptParameter, ScriptVersion -from ..django_compat import flatatt, format_html +from .scripts import WooeyForm from .. import version +from ..backend import utils +from ..models import ScriptVersion def mutli_render(render_func, appender_data_dict=None): diff --git a/wooey/models/core.py b/wooey/models/core.py index f9975a56..09f1f237 100644 --- a/wooey/models/core.py +++ b/wooey/models/core.py @@ -10,6 +10,7 @@ from celery import states from django.db import models from django.conf import settings +from django.core.cache import caches as django_cache from django.core.files.storage import SuspiciousFileOperation from django.core.urlresolvers import reverse from django.contrib.auth.models import Group @@ -21,7 +22,6 @@ from . mixins import UpdateScriptsMixin, ModelDiffMixin, WooeyPy2Mixin from .. import settings as wooey_settings from .. backend import utils -from .. import django_compat # TODO: Handle cases where celery is not setup but specified to be used tasks = importlib.import_module(wooey_settings.WOOEY_CELERY_TASKS) @@ -100,7 +100,7 @@ class ScriptVersion(ModelDiffMixin, WooeyPy2Mixin, models.Model): # parameters, but even a huge site may only have a few thousand parameters to query though. script_version = models.CharField(max_length=50, help_text='The script version.', blank=True, default='1') script_iteration = models.PositiveSmallIntegerField(default=1) - script_path = models.FileField() if django_compat.DJANGO_VERSION >= django_compat.DJ17 else models.FileField(upload_to=wooey_settings.WOOEY_SCRIPT_DIR) + script_path = models.FileField() default_version = models.BooleanField(default=False) script = models.ForeignKey('Script', related_name='script_version') checksum = models.CharField(max_length=40, blank=True) @@ -248,7 +248,7 @@ def update_realtime(self, stdout='', stderr='', delete=False): self.stderr = stderr self.save() elif wooey_cache is not None: - cache = django_compat.get_cache(wooey_cache) + cache = django_cache[wooey_cache] if delete: cache.delete(self.get_realtime_key()) else: @@ -257,7 +257,7 @@ def update_realtime(self, stdout='', stderr='', delete=False): def get_realtime(self): wooey_cache = wooey_settings.WOOEY_REALTIME_CACHE if wooey_cache is not None: - cache = django_compat.get_cache(wooey_cache) + cache = django_cache[wooey_cache] out = cache.get(self.get_realtime_key()) if out: return json.loads(out) @@ -571,7 +571,7 @@ def __str__(self): class WooeyFile(WooeyPy2Mixin, models.Model): - filepath = models.FileField(max_length=500) if django_compat.DJANGO_VERSION >= django_compat.DJ17 else models.FileField(max_length=500, upload_to=wooey_settings.WOOEY_SCRIPT_DIR) + filepath = models.FileField(max_length=500) filepreview = models.TextField(null=True, blank=True) filetype = models.CharField(max_length=255, null=True, blank=True) size_bytes = models.IntegerField(null=True) diff --git a/wooey/tests/test_models.py b/wooey/tests/test_models.py index 89bfde23..e051973a 100644 --- a/wooey/tests/test_models.py +++ b/wooey/tests/test_models.py @@ -82,14 +82,10 @@ def test_jobs(self): new_job.submit_to_celery(rerun=True) # check that we overwrite our output new_output = sorted([i.pk for i in UserFile.objects.filter(job=new_job)]) - # Django 1.6 has a bug where they are reusing pk numbers - if version.DJANGO_VERSION >= version.DJ17: - self.assertNotEqual(old_output, new_output) + self.assertNotEqual(old_output, new_output) self.assertEqual(len(old_output), len(new_output)) # check the old entries are gone - if version.DJANGO_VERSION >= version.DJ17: - # Django 1.6 has a bug where they are reusing pk numbers, so once again we cannot use this check - self.assertEqual([], list(UserFile.objects.filter(pk__in=old_output))) + self.assertEqual([], list(UserFile.objects.filter(pk__in=old_output))) file_previews = utils.get_file_previews(job) for group, files in file_previews.items(): diff --git a/wooey/views/authentication.py b/wooey/views/authentication.py index d565fa80..0b7e7c2c 100644 --- a/wooey/views/authentication.py +++ b/wooey/views/authentication.py @@ -1,14 +1,14 @@ from __future__ import absolute_import -from django.views.generic import CreateView -from django.http import HttpResponseRedirect +from django.contrib.auth import login, authenticate, get_user_model from django.core.urlresolvers import reverse from django.forms.models import modelform_factory -from django.contrib.auth import login, authenticate, get_user_model +from django.http import HttpResponseRedirect +from django.http import JsonResponse from django.utils.translation import ugettext_lazy as _ from django.utils.encoding import force_text +from django.views.generic import CreateView from .. import settings as wooey_settings -from ..django_compat import JsonResponse class WooeyRegister(CreateView): diff --git a/wooey/views/favorite.py b/wooey/views/favorite.py index 439184f6..4f9fe793 100644 --- a/wooey/views/favorite.py +++ b/wooey/views/favorite.py @@ -1,13 +1,12 @@ -from django.views.generic import DetailView, TemplateView -from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden, HttpResponseNotFound, HttpResponseBadRequest -from django.core.urlresolvers import reverse -from django.conf import settings -from django.views.decorators.csrf import ensure_csrf_cookie -from django.contrib.contenttypes.models import ContentType - -from ..django_compat import JsonResponse - from django.contrib.auth.decorators import login_required +from django.contrib.contenttypes.models import ContentType +from django.http import ( + HttpResponseForbidden, + HttpResponseNotFound, + HttpResponseBadRequest, + JsonResponse, +) +from django.views.decorators.csrf import ensure_csrf_cookie from ..models import Favorite diff --git a/wooey/views/views.py b/wooey/views/views.py index ec2d8ef6..f7567f16 100644 --- a/wooey/views/views.py +++ b/wooey/views/views.py @@ -1,25 +1,20 @@ from __future__ import absolute_import, unicode_literals from collections import defaultdict -import datetime as dt -from django.views.generic import DetailView, TemplateView, View -from django.template.loader import render_to_string -from django.http import HttpResponse, HttpResponseRedirect +from django.contrib.auth import get_user_model +from django.contrib.contenttypes.models import ContentType from django.core.urlresolvers import reverse -from django.conf import settings from django.forms import FileField -from django.utils.translation import ugettext_lazy as _ -from django.utils.encoding import force_text +from django.http import JsonResponse from django.template import RequestContext -from django.contrib.auth import get_user_model -from django.http import Http404 - -from django.contrib.contenttypes.models import ContentType +from django.template.loader import render_to_string +from django.utils.encoding import force_text +from django.utils.translation import ugettext_lazy as _ +from django.views.generic import DetailView, TemplateView, View from ..backend import utils from ..models import WooeyJob, Script, UserFile, Favorite, ScriptVersion from .. import settings as wooey_settings -from ..django_compat import JsonResponse class WooeyScriptBase(DetailView): diff --git a/wooey/views/wooey_celery.py b/wooey/views/wooey_celery.py index a82f1e91..5ef55507 100644 --- a/wooey/views/wooey_celery.py +++ b/wooey/views/wooey_celery.py @@ -1,25 +1,22 @@ from __future__ import absolute_import import six -from django.core.urlresolvers import reverse -from django.views.generic import DetailView, TemplateView -from django.utils.translation import ugettext_lazy as _ -from django.utils.encoding import force_text -from django.template.defaultfilters import escape - from celery import app, states - -celery_app = app.app_or_default() - from django.contrib.contenttypes.models import ContentType +from django.core.urlresolvers import reverse +from django.db.models import Q +from django.http import JsonResponse +from django.template.defaultfilters import escape +from django.template.loader import render_to_string +from django.utils.encoding import force_text +from django.utils.translation import ugettext_lazy as _ +from django.views.generic import DetailView, ListView from ..models import WooeyJob, UserFile, Favorite from .. import settings as wooey_settings from ..backend.utils import valid_user, get_file_previews -from ..django_compat import JsonResponse -from django.db.models import Q -from django.views.generic import ListView -from django.template.loader import render_to_string + +celery_app = app.app_or_default() SPANBASE = " " MAXIMUM_JOBS_NAVBAR = 10