Skip to content

Commit

Permalink
fixes and testing for Django 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrDlouhy committed Aug 30, 2018
1 parent f50d712 commit e087167
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ env:
- TOXENV=py35-2.0.X
- TOXENV=py36-2.0.X

- TOXENV=py35-2.1.X
- TOXENV=py36-2.1.X

- TOXENV=coverage
- TOXENV=docs
- TOXENV=qunit
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
},
"dependencies": {
"backbone": ">=1.2 <1.3",
"codemirror": ">=5.10 <6.0",
"codemirror": "^5.40.0",
"jquery": ">=2.2 <2.3",
"jshint": "^2.9.5",
"jshint": "^2.9.6",
"less": "^2.7.3",
"phantomjs-prebuilt": "^2.1.16",
"underscore": ">=1.8 <1.9"
Expand Down
12 changes: 7 additions & 5 deletions scribbler/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
from django.db import models
from django.db.models.signals import post_save, post_delete, pre_save
from django.dispatch import receiver
try:
from django.urls import reverse
except ImportError:
from django.core.urlresolvers import reverse
try:
from django.utils.six import PY3
except ImportError:
Expand Down Expand Up @@ -35,16 +39,14 @@ def __str__(self):
class Meta(object):
unique_together = ('slug', 'url')

@models.permalink
def get_save_url(self):
if self.pk:
return ('edit-scribble', (), {'scribble_id': self.pk})
return reverse('edit-scribble', kwargs={'scribble_id': self.pk})
else:
return ('create-scribble', (), {})
return reverse('create-scribble')

@models.permalink
def get_delete_url(self):
return ('delete-scribble', (), {'scribble_id': self.pk})
return reverse('delete-scribble', kwargs={'scribble_id': self.pk})


@receiver(post_save, sender=Scribble)
Expand Down
17 changes: 14 additions & 3 deletions scribbler/templatetags/scribbler_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
from scribbler.views import build_scribble_context


try:
TOKEN_VAR = template_base.TokenType.VAR
TOKEN_BLOCK = template_base.TokenType.BLOCK
TOKEN_COMMENT = template_base.TokenType.COMMENT
except AttributeError:
TOKEN_VAR = template_base.TOKEN_VAR
TOKEN_BLOCK = template_base.TOKEN_BLOCK
TOKEN_COMMENT = template_base.TOKEN_COMMENT


register = template.Library()


Expand Down Expand Up @@ -88,24 +98,25 @@ def render(self, context):
return wrapper_template.render(context_data, request)



def rebuild_template_string(tokens):
"Reconstruct the original template from a list of tokens."
result = ''
for token in tokens:
value = token.contents
if token.token_type == template_base.TOKEN_VAR:
if token.token_type == TOKEN_VAR:
value = '{0} {1} {2}'.format(
template_base.VARIABLE_TAG_START,
value,
template_base.VARIABLE_TAG_END,
)
elif token.token_type == template_base.TOKEN_BLOCK:
elif token.token_type == TOKEN_BLOCK:
value = '{0} {1} {2}'.format(
template_base.BLOCK_TAG_START,
value,
template_base.BLOCK_TAG_END,
)
elif token.token_type == template_base.TOKEN_COMMENT:
elif token.token_type == TOKEN_COMMENT:
value = '{0} {1} {2}'.format(
template_base.COMMENT_TAG_START,
value,
Expand Down
7 changes: 6 additions & 1 deletion scribbler/tests/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ def test_500(request, exception=None):
'packages': ('scribbler', ),
}

try:
login_url = url(r'^test/', auth_views.LoginView.as_view(template_name='test.html'))
except AttributeError:
login_url = url(r'^test/', auth_views.login, {'template_name': 'test.html'})

urlpatterns = [
url(r'^scribble/', include('scribbler.urls')),
url(r'^jsi18n/$', javascript_catalog, js_info_dict, name='jsi18n'),
url(r'^test/', auth_views.login, {'template_name': 'test.html'}),
login_url,
]
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ envlist =
{py27,py34,py35}-1.10.X,
{py27,py34,py35,py36}-1.11.X,
{py34,py35,py36}-{2.0}.X,
{py35,py36}-{2.1}.X,
coverage,docs,qunit

[testenv]
Expand All @@ -25,6 +26,7 @@ deps =
1.10.X: Django>=1.10,<1.11
1.11.X: Django>=1.11,<2.0
2.0.X: Django>=2.0,<2.1
2.1.X: Django>=2.1,<2.2
Jinja2
selenium
whitelist_externals = make
Expand Down

0 comments on commit e087167

Please sign in to comment.