def create_parser(self, prog_name, subcommand): """ For ``Django>=1.10`` Create and return the ``ArgumentParser`` which extends ``BaseCommand`` parser with chroniker extra args and will be used to parse the arguments to this command. """ from distutils.version import StrictVersion # pylint: disable=E0611 parser = super(Command, self).create_parser(prog_name, subcommand) version_threshold = StrictVersion('1.10') current_version = StrictVersion(django_get_version(VERSION)) if current_version >= version_threshold: parser.add_argument('args', nargs="*") parser.add_argument('--imports', dest='imports', help='Modules to import.') parser.add_argument('--query', dest='query', help='The query to run.') parser.add_argument( '--verbose', dest='verbose', default=False, help='If given, displays extra logging messages.') self.add_arguments(parser) return parser
def test_redirection_class(self): view_url = "/permission_required/" if django_get_version() < "1.5": # skip this test for django versions < 1.5 return response = self.client.get(view_url) self.assertRedirects(response, reverse(settings.LOGIN_URL) + "?next=" + view_url)
def test_redirection_class(self): view_url = '/permission_required/' if django_get_version() < "1.5": # skip this test for django versions < 1.5 return response = self.client.get(view_url) self.assertRedirects(response, reverse(settings.LOGIN_URL) + "?next=" + view_url)
def test_redirection_class(self): view_url = '/permission_required/' if django_get_version() < "1.5": # skip this test for django versions < 1.5 return response = self.client.get(view_url) # this should be '/account/login' self.assertRedirects(response, global_settings.LOGIN_URL + "?next=" + view_url)
def create_parser(self, prog_name, subcommand): """ For ``Django>=1.10`` Create and return the ``ArgumentParser`` which extends ``BaseCommand`` parser with chroniker extra args and will be used to parse the arguments to this command. """ from distutils.version import StrictVersion # pylint: disable=E0611 parser = super(Command, self).create_parser(prog_name, subcommand) version_threshold = StrictVersion('1.10') current_version = StrictVersion(django_get_version(VERSION)) if current_version >= version_threshold: parser.add_argument('--update_heartbeat', dest='update_heartbeat', default=1, help='If given, launches a thread to asynchronously update ' + \ 'job heartbeat status.') parser.add_argument('--force_run', dest='force_run', action='store_true', default=False, help='If given, forces all jobs to run.') parser.add_argument('--dryrun', action='store_true', default=False, help='If given, only displays jobs to be run.') parser.add_argument('--jobs', dest='jobs', default='', help='A comma-delimited list of job ids to limit executions to.') parser.add_argument('--name', dest='name', default='', help='A name to give this process.') parser.add_argument('--sync', action='store_true', default=False, help='If given, runs jobs one at a time.') parser.add_argument('--verbose', action='store_true', default=False, help='If given, shows debugging info.') self.add_arguments(parser) return parser
def create_parser(self, prog_name, subcommand): """ For ``Django>=1.10`` Create and return the ``ArgumentParser`` which extends ``BaseCommand`` parser with chroniker extra args and will be used to parse the arguments to this command. """ from distutils.version import StrictVersion # pylint: disable=E0611 parser = super(Command, self).create_parser(prog_name, subcommand) version_threshold = StrictVersion('1.10') current_version = StrictVersion(django_get_version(VERSION)) if current_version >= version_threshold: parser.add_argument('root_job_id') parser.add_argument( '--samples', default=20, help= 'The number of log samples to use when estimating mean job run time.' ) self.add_arguments(parser) return parser
def get_version(): from django import get_version as django_get_version return django_get_version(VERSION) # pragma: no cover
from __future__ import unicode_literals # handler404 and handler500 are needed for admin tests from guardian.compat import include, patterns, handler404, handler500 # pyflakes:ignore from guardian.mixins import PermissionRequiredMixin from django.contrib import admin from django import get_version as django_get_version if (django_get_version() >= "1.5"): from django.views.generic import View admin.autodiscover() urlpatterns = patterns('', (r'^admin/', include(admin.site.urls)), ) if (django_get_version() >= "1.5"): class testClassRedirectView(PermissionRequiredMixin, View): permission_required = 'testapp.change_project' urlpatterns += patterns('', (r'^accounts/login/', 'django.contrib.auth.views.login', {'template_name': 'blank.html'}), (r'^permission_required/', testClassRedirectView.as_view()), )
# handler404 and handler500 are needed for admin tests from guardian.compat import include, patterns, handler404, handler500 # pyflakes:ignore from guardian.mixins import PermissionRequiredMixin from django.contrib import admin from django import get_version as django_get_version if (django_get_version() >= "1.5"): from django.views.generic import View admin.autodiscover() urlpatterns = patterns('', (r'^admin/', include(admin.site.urls)), ) if (django_get_version() >= "1.5"): class testClassRedirectView(PermissionRequiredMixin, View): permission_required = 'testapp.change_project' urlpatterns += patterns('', (r'^accounts/login/', 'django.contrib.auth.views.login', {'template_name': 'blank.html'}), (r'^permission_required/', testClassRedirectView.as_view()), )