Skip to content

Commit

Permalink
Merge commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
carljm committed Jul 2, 2014
2 parents d0c4782 + 1fb2795 commit 6ca0295
Show file tree
Hide file tree
Showing 18 changed files with 145 additions and 122 deletions.
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Alexandr Shurigin <http://brainstorage.me/phpdude>
Aram Dulyan
Berker Peksag <berker.peksag@gmail.com>
Carl Meyer <carl@dirtcircle.com>
Fursov Sergey <GeyseR85@gmail.com>
James Turk <james.p.turk@gmail.com>
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
CHANGES
=======

2.2 (not released)
------------------

* Added Python 3.3+ support.


2.1 (2013.11.11)
----------------

Expand Down
11 changes: 7 additions & 4 deletions markitup/fields.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from __future__ import unicode_literals

from django.conf import settings
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.safestring import mark_safe, SafeData
from django.utils.functional import curry
from django.core.exceptions import ImproperlyConfigured
Expand All @@ -15,12 +18,13 @@ def _get_render_func(dotted_path, **kwargs):
try:
render_func = _get_render_func(settings.MARKITUP_FILTER[0],
**settings.MARKITUP_FILTER[1])
except ImportError, e:
except ImportError as e:
raise ImproperlyConfigured("Could not import MARKITUP_FILTER %s: %s" %
(settings.MARKITUP_FILTER, e))
except AttributeError, e:
except AttributeError as e:
raise ImproperlyConfigured("MARKITUP_FILTER setting is required")

@python_2_unicode_compatible
class Markup(SafeData):
def __init__(self, instance, field_name, rendered_field_name):
# instead of storing actual values store a reference to the instance
Expand All @@ -42,7 +46,7 @@ def _get_rendered(self):
rendered = property(_get_rendered)

# allows display via templates to work without safe filter
def __unicode__(self):
def __str__(self):
return mark_safe(self.rendered)

# Return length of rendered string so that bool tests work as expected
Expand Down Expand Up @@ -128,4 +132,3 @@ def formfield(self, **kwargs):
patterns=['markitup\.fields\.'])
except ImportError:
pass

2 changes: 2 additions & 0 deletions markitup/markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
.. _django-template-utils: http://code.google.com/p/django-template-utils/
"""
from __future__ import unicode_literals

from django.utils.functional import curry, wraps

from markitup.settings import MARKITUP_PREVIEW_FILTER
Expand Down
2 changes: 2 additions & 0 deletions markitup/renderers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

try:
from docutils.core import publish_parts
def render_rest(markup, **docutils_settings):
Expand Down
2 changes: 2 additions & 0 deletions markitup/settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

from django.conf import settings

MARKITUP_PREVIEW_FILTER = getattr(settings, 'MARKITUP_PREVIEW_FILTER',
Expand Down
2 changes: 2 additions & 0 deletions markitup/templatetags/markitup_tags.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

from django import template
from django.core.urlresolvers import reverse, NoReverseMatch
from markitup import settings
Expand Down
2 changes: 2 additions & 0 deletions markitup/urls.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

from django.conf.urls import patterns, url

from markitup.views import apply_filter
Expand Down
5 changes: 5 additions & 0 deletions markitup/util.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
from __future__ import unicode_literals

import posixpath

from django.conf import settings as django_settings

from markitup import settings


def absolute_url(path, prefix=None):
if prefix is None:
prefix = django_settings.STATIC_URL
Expand Down
4 changes: 3 additions & 1 deletion markitup/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

from django.shortcuts import render_to_response
from django.template import RequestContext

Expand All @@ -6,6 +8,6 @@

def apply_filter(request):
markup = filter_func(request.POST.get('data', ''))
return render_to_response( 'markitup/preview.html',
return render_to_response('markitup/preview.html',
{'preview': markup},
context_instance=RequestContext(request))
3 changes: 3 additions & 0 deletions markitup/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
Time-stamp: <2011-11-26 14:39:52 carljm widgets.py>
"""

from __future__ import unicode_literals

from django import forms
from django.utils.safestring import mark_safe
from django.contrib.admin.widgets import AdminTextareaWidget
Expand Down
8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
p = subprocess.Popen(['hg', 'parents', r'--template={rev}\n'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if not p.returncode:
fh = open('HGREV', 'w')
fh = open('HGREV', 'wb')
fh.write(p.communicate()[0].splitlines()[0])
fh.close()
except (OSError, IndexError):
Expand All @@ -36,7 +36,7 @@ def _static_files(prefix):

setup(
name='django-markitup',
version='2.1',
version='2.2',
description='Markup handling for Django using the MarkItUp! universal markup editor',
long_description=long_description,
author='Carl Meyer',
Expand All @@ -50,6 +50,10 @@ def _static_files(prefix):
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Framework :: Django',
],
zip_safe=False,
Expand Down
3 changes: 3 additions & 0 deletions tests/filter.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
from __future__ import unicode_literals


def testfilter(s, arg=None):
return s.replace('replace this', arg)
14 changes: 6 additions & 8 deletions tests/models.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
from __future__ import unicode_literals

from django.db import models
from django.utils.encoding import python_2_unicode_compatible

from markitup.fields import MarkupField



@python_2_unicode_compatible
class Post(models.Model):
title = models.CharField(max_length=50)
body = MarkupField()


def __unicode__(self):
def __str__(self):
return self.title



class AbstractParent(models.Model):
content = MarkupField()


class Meta:
abstract = True



class NoRendered(models.Model):
"""
Test that the no_rendered_field keyword arg works. This arg should
Expand All @@ -32,9 +31,8 @@ class NoRendered(models.Model):
body = MarkupField(no_rendered_field=True)



class CallableDefault(models.Model):
"""
A callable default on a field triggers hidden widget rendering by Django.
"""
body = MarkupField(default=lambda:'')
body = MarkupField(default=lambda: '')
5 changes: 4 additions & 1 deletion tests/test_settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from os.path import dirname, join
from __future__ import unicode_literals

from os.path import dirname

MIU_TEST_ROOT = dirname(__file__)

INSTALLED_APPS = [
Expand Down
Loading

0 comments on commit 6ca0295

Please sign in to comment.