Skip to content

Commit

Permalink
open 1.3 alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
saxix committed May 5, 2016
1 parent 88ecb87 commit b8c483b
Show file tree
Hide file tree
Showing 37 changed files with 178 additions and 109 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -9,6 +9,7 @@ coverage.xml
.cache
notes.txt
docs/build/
__pycache__
/dist
/build
/MANIFEST
Expand Down
7 changes: 7 additions & 0 deletions CHANGES
@@ -1,3 +1,10 @@
Release 1.3 (dev)
-----------------
* drop support for Python < 3.3
* add support Django>1.10
* change license


Release 1.2 (05 Apr 2016)
-------------------------
* better support for django 1.9 ( ``TemplateDoesNotExist`` is now in ``django.template.exceptions``
Expand Down
34 changes: 18 additions & 16 deletions LICENSE
@@ -1,20 +1,22 @@
* Copyright (c) 2010, Stefano Apostolico (s.apostolico@gmail.com)
* Dual licensed under the MIT or GPL Version 2 licenses.
Copyright (c) 2010-2016, Stefano Apostolico (s.apostolico@gmail.com)

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Any use in a commercial product must be notified to the author by email
indicating company name and product name

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions MANIFEST.in
Expand Up @@ -10,8 +10,11 @@ include *.py
exclude Makefile
exclude .editorconfig
exclude .tx
exclude .pyc

recursive-exclude .tx *
recursive-exclude __pycache__ *
recursive-exclude . *.pyc

recursive-include docs *
recursive-include src *
Expand Down
7 changes: 2 additions & 5 deletions setup.py
@@ -1,10 +1,7 @@
#!/usr/bin/env python
import imp
import os
import sys
import imp
from distutils import log
from distutils.command.clean import clean as CleanCommand
from distutils.dir_util import remove_tree

from setuptools import find_packages, setup
from setuptools.command.test import test as TestCommand
Expand Down Expand Up @@ -58,7 +55,7 @@ def run_tests(self):
long_description=open('README.rst').read(),
license='MIT License',
keywords='django',
setup_requires=['pytest-runner',],
setup_requires=['pytest-runner', ],
install_requires=install_requires,
tests_require='django\n' + test_requires,
extras_require={'test': test_requires,
Expand Down
2 changes: 1 addition & 1 deletion src/concurrency/__init__.py
Expand Up @@ -5,7 +5,7 @@
__author__ = 'sax'
default_app_config = 'concurrency.apps.ConcurrencyConfig'

VERSION = __version__ = (1, 2, 0, 'final', 0)
VERSION = __version__ = (1, 3, 0, 'alpha', 0)
NAME = 'django-concurrency'


Expand Down
2 changes: 1 addition & 1 deletion src/concurrency/admin.py
Expand Up @@ -16,7 +16,7 @@
from django.http import HttpResponse, HttpResponseRedirect
from django.utils.encoding import force_text
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext as _, ungettext
from django.utils.translation import ungettext

from concurrency import core, forms
from concurrency.api import get_revision_of_object
Expand Down
51 changes: 34 additions & 17 deletions src/concurrency/management/commands/triggers.py
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from optparse import make_option

from django.core.exceptions import ImproperlyConfigured
from django.core.management.base import BaseCommand
from django.db import connections
Expand All @@ -12,20 +10,37 @@
class Command(BaseCommand):
args = ''
help = 'register Report classes and create one ReportConfiguration per each'
requires_model_validation = False
# requires_system_checks = False

option_list = BaseCommand.option_list + (
make_option('-d', '--database',
action='store',
dest='database',
default=None,
help='limit to this database'),
make_option('-t', '--trigger',
action='store',
dest='trigger',
default=None,
help='limit to this trigger name'))

requires_system_checks = False

def add_arguments(self, parser):
"""
Entry point for subclassed commands to add custom arguments.
"""
subparsers = parser.add_subparsers(help='sub-command help',
dest='command')

subparsers.add_parser('list',
cmd=parser,
help="command_a help")
subparsers.add_parser('drop',
cmd=parser,
help="command_a help")
subparsers.add_parser('create',
cmd=parser,
help="command_a help")

parser.add_argument('-d', '--database',
action='store',
dest='database',
default=None,
help='limit to this database')

parser.add_argument('-t', '--trigger',
action='store',
dest='trigger',
default=None,
help='limit to this trigger name')

def _list(self, databases):
for alias, triggers in get_triggers(databases).items():
Expand All @@ -34,7 +49,9 @@ def _list(self, databases):
self.stdout.write(" {}".format(trigger))
self.stdout.write('')

def handle(self, cmd='list', *args, **options):
def handle(self, *args, **options):

cmd = options['command']
database = options['database']
if database is None:
databases = [alias for alias in connections]
Expand Down
14 changes: 12 additions & 2 deletions tests/conftest.py
@@ -1,13 +1,23 @@
import os
import platform
import sys

import django

import pytest

py_impl = getattr(platform, 'python_implementation', lambda: None)
PYPY = py_impl() == 'PyPy'
PURE_PYTHON = os.environ.get('PURE_PYTHON', False)

windows = pytest.mark.skipif(sys.platform != 'win32', reason="requires windows")

win32only = pytest.mark.skipif("sys.platform != 'win32'")

skipIfDjangoVersion = lambda v: pytest.mark.skipif("django.VERSION[:2]>={}".format(v),
reason="Skip if django>={}".format(v))
skippypy = pytest.mark.skipif(PYPY, reason='skip on pypy')

# skipIfDjangoVersion = lambda v: pytest.mark.skipif("django.VERSION[:2]>={}".format(v),
# reason="Skip if django>={}".format(v))


def pytest_configure():
Expand Down
6 changes: 3 additions & 3 deletions tests/demoapp/demo/admin.py
Expand Up @@ -3,14 +3,14 @@
from django.contrib import admin
from django.contrib.admin.sites import NotRegistered

from concurrency.admin import ConcurrentModelAdmin
from concurrency.api import disable_concurrency

from demo.models import * # noqa
from demo.models import (
ListEditableConcurrentModel, NoActionsConcurrentModel, ReversionConcurrentModel
)

from concurrency.admin import ConcurrentModelAdmin
from concurrency.api import disable_concurrency

try:
from reversion import VersionAdmin
except ImportError:
Expand Down
4 changes: 2 additions & 2 deletions tests/demoapp/demo/base.py
Expand Up @@ -4,13 +4,13 @@
from django.contrib.auth.models import Group, User
from django.test import TransactionTestCase
from django.utils import timezone

from demo.admin import admin_register_models
from django_webtest import WebTestMixin

from concurrency.api import apply_concurrency_check
from concurrency.fields import IntegerVersionField

from demo.admin import admin_register_models

SENTINEL = '**concurrent_update**'


Expand Down
5 changes: 3 additions & 2 deletions tests/demoapp/demo/migrations/0001_initial.py
Expand Up @@ -2,10 +2,11 @@
# Generated by Django 1.9.1 on 2016-01-09 17:12
from __future__ import unicode_literals

import concurrency.fields
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion

import concurrency.fields


class Migration(migrations.Migration):
Expand Down
@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models
from django.conf import settings
from django.db import migrations, models

import concurrency.fields


Expand Down
12 changes: 8 additions & 4 deletions tests/demoapp/demo/models.py
Expand Up @@ -4,9 +4,10 @@
from django.contrib.auth.models import Group, User
from django.db import models

from concurrency.fields import (AutoIncVersionField, IntegerVersionField,
TriggerVersionField,
ConditionalVersionField)
from concurrency.fields import (
AutoIncVersionField, ConditionalVersionField, IntegerVersionField,
TriggerVersionField
)

__all__ = ['SimpleConcurrentModel', 'AutoIncConcurrentModel',
'ProxyModel', 'InheritedModel', 'CustomSaveModel',
Expand All @@ -26,8 +27,11 @@ class Meta:
verbose_name = "SimpleConcurrentModel"
verbose_name_plural = "SimpleConcurrentModels"

def __str__(self):
return "{0} #{1}".format(self.__class__.__name__, self.pk)

def __unicode__(self):
return "{0.__class__.__name__} #{0.pk}".format(self)
return "{0} #{1}".format(self.__class__.__name__, self.pk)


class AutoIncConcurrentModel(models.Model):
Expand Down
27 changes: 19 additions & 8 deletions tests/demoapp/demo/settings.py
@@ -1,12 +1,15 @@
import os
from tempfile import mktemp

import django

try:
from psycopg2cffi import compat

compat.register()
except ImportError:
pass

import django

DEBUG = True
STATIC_URL = '/static/'
Expand All @@ -25,12 +28,9 @@
'django.contrib.staticfiles',
'django.contrib.admin',
'concurrency',
# 'reversion',
'reversion',
'demo']

if django.VERSION[:2] != (1, 9):
INSTALLED_APPS += ['reversion']


MIGRATION_MODULES = {
'demo': 'demo.migrations',
Expand All @@ -44,11 +44,22 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
]
if django.VERSION[1] >= 7:
MIDDLEWARE_CLASSES += ['django.contrib.auth.middleware.SessionAuthenticationMiddleware', ]

TEMPLATE_DIRS = ['demo/templates']
if django.VERSION[1] >= 10:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
# ... some options here ...
},
},
]
else:
TEMPLATE_DIRS = ['demo/templates']

LOGGING = {
'version': 1,
Expand Down
15 changes: 7 additions & 8 deletions tests/demoapp/demo/urls.py
@@ -1,4 +1,4 @@
from django.conf.urls import include, patterns, url
from django.conf.urls import include, url
from django.contrib import admin
from django.views.generic.edit import UpdateView

Expand All @@ -13,10 +13,9 @@

admin.autodiscover()

urlpatterns = patterns('',
url('cm/(?P<pk>\d+)/',
UpdateView.as_view(model=SimpleConcurrentModel),
name='concurrent-edit'),
url(r'^admin/',
include(admin.site.urls))
)
urlpatterns = (url('cm/(?P<pk>\d+)/',
UpdateView.as_view(model=SimpleConcurrentModel),
name='concurrent-edit'),
url(r'^admin/',
include(admin.site.urls))
)
2 changes: 1 addition & 1 deletion tests/demoapp/demo/util.py
Expand Up @@ -3,9 +3,9 @@
from functools import partial, update_wrapper
from itertools import count

import pytest
from django import db

import pytest
from demo.models import (
AutoIncConcurrentModel, ConcreteModel, CustomSaveModel, InheritedModel, ProxyModel,
SimpleConcurrentModel, TriggerConcurrentModel
Expand Down

0 comments on commit b8c483b

Please sign in to comment.