Skip to content

Commit

Permalink
django 1.7 compatibility, removed south
Browse files Browse the repository at this point in the history
  • Loading branch information
nanvel committed May 26, 2016
1 parent 4a62bed commit a1841da
Show file tree
Hide file tree
Showing 21 changed files with 106 additions and 118 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,11 @@

- docs improvements
- support for django 1.6
- updated AUTHORS
- updated AUTHORS

=== 1.1 ===

- support for Django 1.7
- removed South
- updated migrations
- fixed tests
24 changes: 14 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ Blog post: `NicEdit widget for Django <http://nanvel.name/2013/08/django-nicedit
Versions
--------

0.23 - use with Django<1.6

0.24 - use with Django==1.6

1.1 - use with Django==1.7

Installation
------------

Expand Down Expand Up @@ -126,7 +130,7 @@ Usage in admin:
.. code-block:: python
# -*- coding: utf-8 -*-
from django import forms
from django import forms
from django.contrib import admin
from nicedit.widgets import NicEditAdminWidget
Expand All @@ -139,16 +143,16 @@ Usage in admin:
class Meta:
model = Item
widgets = {
'text': NicEditAdminWidget(
attrs={'style': 'width: 610px;'},
js_options={"buttonList": [
'save', 'bold', 'italic', 'underline', 'left', 'center',
'right', 'justify', 'ol', 'ul', 'fontSize', # 'fontFamily',
'fontFormat', 'indent', 'outdent', 'image', 'upload', 'link',
'unlink', 'forecolor', 'bgcolor', 'xhtml']
'text': NicEditAdminWidget(
attrs={'style': 'width: 610px;'},
js_options={"buttonList": [
'save', 'bold', 'italic', 'underline', 'left', 'center',
'right', 'justify', 'ol', 'ul', 'fontSize', # 'fontFamily',
'fontFormat', 'indent', 'outdent', 'image', 'upload', 'link',
'unlink', 'forecolor', 'bgcolor', 'xhtml']
}
)
}
)
}
class ItemAdmin(admin.ModelAdmin):
Expand Down
2 changes: 1 addition & 1 deletion nicedit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# -*- coding: utf-8 -*-
__version__ = '0.24'
__version__ = '1.1'
4 changes: 4 additions & 0 deletions nicedit/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
from .models import NicEditImage


__all__ = ('NicEditImageForm',)


class NicEditImageForm(forms.ModelForm):

class Meta:
model = NicEditImage
fields = '__all__'
21 changes: 7 additions & 14 deletions nicedit/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
from __future__ import unicode_literals

from django.db import models, migrations

class Migration(SchemaMigration):

def forwards(self, orm):
pass
class Migration(migrations.Migration):

def backwards(self, orm):
pass
dependencies = [
]

models = {

}

complete_apps = ['nicedit']
operations = [
]
44 changes: 18 additions & 26 deletions nicedit/migrations/0002_auto__add_niceditimage.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
from __future__ import unicode_literals

from django.db import models, migrations

class Migration(SchemaMigration):

def forwards(self, orm):
# Adding model 'NicEditImage'
db.create_table(u'nicedit_niceditimage', (
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('image', self.gf('django.db.models.fields.files.ImageField')(max_length=100)),
))
db.send_create_signal(u'nicedit', ['NicEditImage'])
class Migration(migrations.Migration):

dependencies = [
('nicedit', '0001_initial'),
]

def backwards(self, orm):
# Deleting model 'NicEditImage'
db.delete_table(u'nicedit_niceditimage')


models = {
u'nicedit.niceditimage': {
'Meta': {'object_name': 'NicEditImage'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'image': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'})
}
}

complete_apps = ['nicedit']
operations = [
migrations.CreateModel(
name='NicEditImage',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('image', models.ImageField(upload_to=b'nicedit/%Y/%m/%d')),
],
options={
},
bases=(models.Model,),
),
]
3 changes: 3 additions & 0 deletions nicedit/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from django.db import models


__all__ = ('NicEditImage',)


class NicEditImage(models.Model):
image = models.ImageField(upload_to='nicedit/%Y/%m/%d')
47 changes: 0 additions & 47 deletions nicedit/tests.py

This file was deleted.

1 change: 1 addition & 0 deletions nicedit/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .test_image_upload import *
6 changes: 5 additions & 1 deletion nicedit/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from django.conf.urls import patterns, url


urlpatterns = patterns('nicedit.views',
__all__ = ('urlpatterns',)


urlpatterns = patterns(
'nicedit.views',
url(r'^upload/$', 'upload', name='nicedit_upload'),
)
15 changes: 9 additions & 6 deletions nicedit/views.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
try:
from django.utils import simplejson as json
except ImportError:
import json
import json

from django.http import HttpResponse

from .forms import NicEditImageForm


__all__ = ('upload',)


def upload(request):

if not request.user.is_authenticated():
json_data = json.dumps({
'success': False,
'errors': {'__all__': 'Authentication required'}})
return HttpResponse(json_data, mimetype='application/json')
return HttpResponse(json_data, content_type='application/json')

form = NicEditImageForm(request.POST or None, request.FILES or None)
if form.is_valid():
image = form.save()
Expand All @@ -29,4 +32,4 @@ def upload(request):
else:
json_data = json.dumps({
'success': False, 'errors': form.errors})
return HttpResponse(json_data, mimetype='application/json')
return HttpResponse(json_data, content_type='application/json')
5 changes: 4 additions & 1 deletion nicedit/widgets.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# -*- coding: utf-8 -*-
import json

from django import forms
from django.conf import settings
from django.contrib.staticfiles.storage import staticfiles_storage
from django.core.urlresolvers import reverse
from django.utils.safestring import mark_safe


__all__ = ('NicEditWidget', 'NicEditAdminWidget')


class NicEditWidget(forms.Textarea):

def __init__(self, *args, **kwargs):
Expand Down
8 changes: 8 additions & 0 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
import os

from django import setup
from django.conf import settings


Expand All @@ -17,11 +18,18 @@ def main():
'ENGINE': 'django.db.backends.sqlite3',
},
},
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware'
),
ROOT_URLCONF='nicedit.urls',
MEDIA_ROOT=os.path.join(os.path.dirname(__file__), 'app_media'),
SITE_ID=1,
)

setup()

from django.test.simple import DjangoTestSuiteRunner

test_runner = DjangoTestSuiteRunner(verbosity=1)
Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,13 @@ def read(fname):
license='The MIT License',
platforms=['OS Independent'],
keywords='django, nicedit, widget, rte',
author='Oleksandr Polyeno',
author='Oleksandr Polieno',
author_email='[email protected]',
url="https://github.com/nanvel/django-nicedit",
packages=find_packages(),
include_package_data=True,
install_requires=[
'django<1.7',
'South',
'Django>=1.7,<1.8',
'Pillow'
],
)
3 changes: 1 addition & 2 deletions test_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
Django>=1.4,<1.7
South
Django>=1.7,<1.8
Pillow
5 changes: 2 additions & 3 deletions testproject/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
Django==1.6
South
PIL
Django>=1.7,<1.8
Pillow
3 changes: 1 addition & 2 deletions testproject/testproject/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
# 'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
Expand Down Expand Up @@ -131,7 +131,6 @@
'django.contrib.staticfiles',
'django.contrib.admin',

'south',
'nicedit',

'testproject.testapp',
Expand Down
3 changes: 3 additions & 0 deletions testproject/testproject/testapp/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
from .forms import MessageAdminForm


__all__ = tuple()


class MessageAdmin(admin.ModelAdmin):

form = MessageAdminForm
Expand Down
5 changes: 5 additions & 0 deletions testproject/testproject/testapp/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
from .models import Message


__all__ = ('MessageForm', 'MessageAdminForm')


class MessageAdminForm(forms.ModelForm):

class Meta:
model = Message
widgets = {
'content': NicEditAdminWidget(attrs={'style': 'width: 800px;'}),
}
fields = '__all__'


class MessageForm(forms.ModelForm):
Expand All @@ -21,3 +25,4 @@ class Meta:
widgets = {
'content': NicEditWidget(attrs={'style': 'width: 800px;'}),
}
fields = '__all__'
3 changes: 3 additions & 0 deletions testproject/testproject/testapp/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from django.db import models


__all__ = ('Message',)


class Message(models.Model):
content = models.TextField()
Loading

0 comments on commit a1841da

Please sign in to comment.