Skip to content

Commit 29204cf

Browse files
committed
Updates for Django v1.9
1 parent 4604c72 commit 29204cf

File tree

6 files changed

+45
-17
lines changed

6 files changed

+45
-17
lines changed

.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
*.pyc
2+
.coverage
3+
/export
4+
.DS_Store
5+
.DS_Store?
6+
.envrc
7+
htmlcov
8+
ghostdriver.log
9+
celerybeat-schedule
10+
celerybeat.pid
11+
stellar.yaml
12+
\#*\#
13+
*.flymake.py
14+
.idea
15+
*~undo-tree~
16+
.python-version
17+
18+
export.zip
19+
.ignore
20+
*.ipynb

logical_rules/helpers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import sys
1+
import imp
2+
from importlib import import_module
3+
from django.conf import settings
4+
25

36
def import_rules(app):
4-
from django.utils.importlib import import_module
5-
import imp
6-
import sys
77

88
try:
99
app_path = import_module(app).__path__
@@ -18,8 +18,8 @@ def import_rules(app):
1818
module = import_module('%s.rules' % app)
1919
return module
2020

21+
2122
def autodiscover():
22-
from django.conf import settings
2323

2424
for app in settings.INSTALLED_APPS:
2525
import_rules(app)

logical_rules/rules.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def __call__(self, topping_list, pizza_place):
1313
1414
can_make_pizza = CanMakePizza
1515
rules.register('can_make_pizza', can_make_pizza)
16-
16+
1717
def can_eat_pizza(person, topping_list):
1818
for t in topping_list:
1919
if t in person.dislike_list:
@@ -24,14 +24,20 @@ def can_eat_pizza(person, topping_list):
2424
"""
2525
import logical_rules
2626

27+
2728
def evaluate_expression(exp):
2829
return exp
30+
31+
2932
logical_rules.site.register('evaluate_expression', evaluate_expression)
3033

34+
3135
def user_is_authenticated(user):
3236
"""
3337
Added to the rule set automatically as an alternative to the
3438
login_required decorator
3539
"""
3640
return user.is_authenticated()
41+
42+
3743
logical_rules.site.register('user_is_authenticated', user_is_authenticated)

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Django==1.4
1+
Django>=1.9

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def read(fname):
2121
'logical_rules.tests.test_app',
2222
],
2323
install_requires=[
24-
"Django >= 1.4",
24+
"Django >= 1.9",
2525
],
2626
classifiers=[
2727
'Development Status :: 4 - Beta',

tests.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def main():
1313
sys.exc_clear()
1414

1515
os.environ["DJANGO_SETTINGS_MODULE"] = "django.conf.global_settings"
16+
1617
from django.conf import global_settings
1718

1819
global_settings.INSTALLED_APPS = (
@@ -38,7 +39,7 @@ def main():
3839
global_settings.DATABASE_NAME = ":memory:"
3940

4041
global_settings.ROOT_URLCONF = 'logical_rules.tests.test_app.urls'
41-
42+
4243
global_settings.MIDDLEWARE_CLASSES = (
4344
'django.middleware.common.CommonMiddleware',
4445
'django.contrib.sessions.middleware.SessionMiddleware',
@@ -49,17 +50,18 @@ def main():
4950

5051
global_settings.SECRET_KEY = "blahblah"
5152
global_settings.DEBUG = True
52-
global_settings.TEMPLATE_DUBUG = True
53+
global_settings.TEMPLATE_DEBUG = True
54+
global_settings.SECRET_KEY = "guesswho"
55+
56+
django.setup()
5357

5458
from django.test.utils import get_runner
5559
test_runner = get_runner(global_settings)
56-
57-
if django.VERSION > (1,2):
58-
test_runner = test_runner()
59-
failures = test_runner.run_tests(['logical_rules',])
60-
else:
61-
failures = test_runner(['logical_rules',], verbosity=2)
60+
61+
test_runner = test_runner()
62+
failures = test_runner.run_tests(['logical_rules',])
63+
6264
sys.exit(failures)
6365

6466
if __name__ == '__main__':
65-
main()
67+
main()

0 commit comments

Comments
 (0)