Skip to content

Commit

Permalink
Fix running Django 1.7/1.8 code, always use django_comments app
Browse files Browse the repository at this point in the history
  • Loading branch information
vdboor committed Apr 14, 2015
1 parent c2e2815 commit 933f256
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 14 deletions.
10 changes: 7 additions & 3 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
from django.core.management import execute_from_command_line

if not settings.configured:
base_app = 'django.contrib.comments'
if django.VERSION >= (1,7):
base_app = 'django_comments'

settings.configure(
DATABASES = {
'default': {
Expand All @@ -24,20 +28,20 @@
'django.contrib.messages',
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.comments',
base_app,
'threadedcomments',
'example',
),
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
),
ROOT_URLCONF = 'django.contrib.comments.urls',
ROOT_URLCONF = '{0}.urls'.format(base_app),
TEST_RUNNER = 'django.test.simple.DjangoTestSuiteRunner' if django.VERSION < (1,6) else 'django.test.runner.DiscoverRunner',
SITE_ID = 1,
COMMENTS_APP = 'threadedcomments',
COMMENTS_ALLOW_PROFANITIES = True,
)

def runtests():
Expand Down
14 changes: 7 additions & 7 deletions threadedcomments/fixtures/simple_tree.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
},
{
"pk": 1,
"model": "comments.comment",
"model": "django_comments.comment",
"fields": {
"comment": "Comment 1",
"user_url": "",
Expand All @@ -82,7 +82,7 @@
},
{
"pk": 2,
"model": "comments.comment",
"model": "django_comments.comment",
"fields": {
"comment": "Comment 2",
"user_url": "",
Expand All @@ -100,7 +100,7 @@
},
{
"pk": 3,
"model": "comments.comment",
"model": "django_comments.comment",
"fields": {
"comment": "Comment 3",
"user_url": "",
Expand All @@ -118,7 +118,7 @@
},
{
"pk": 4,
"model": "comments.comment",
"model": "django_comments.comment",
"fields": {
"comment": "Comment 4",
"user_url": "",
Expand All @@ -136,7 +136,7 @@
},
{
"pk": 5,
"model": "comments.comment",
"model": "django_comments.comment",
"fields": {
"comment": "Comment 5",
"user_url": "",
Expand All @@ -154,7 +154,7 @@
},
{
"pk": 6,
"model": "comments.comment",
"model": "django_comments.comment",
"fields": {
"comment": "Comment 6",
"user_url": "",
Expand All @@ -172,7 +172,7 @@
},
{
"pk": 7,
"model": "comments.comment",
"model": "django_comments.comment",
"fields": {
"comment": "Comment 7",
"user_url": "",
Expand Down
191 changes: 191 additions & 0 deletions threadedcomments/fixtures/simple_tree_old.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
[
{
"pk": 1,
"model": "threadedcomments.threadedcomment",
"fields": {
"tree_path": "0000000001",
"last_child": 4,
"parent": null
}
},
{
"pk": 2,
"model": "threadedcomments.threadedcomment",
"fields": {
"tree_path": "0000000001/0000000002",
"last_child": 5,
"parent": 1
}
},
{
"pk": 3,
"model": "threadedcomments.threadedcomment",
"fields": {
"tree_path": "0000000001/0000000002/0000000003",
"last_child": null,
"parent": 2
}
},
{
"pk": 5,
"model": "threadedcomments.threadedcomment",
"fields": {
"tree_path": "0000000001/0000000002/0000000005",
"last_child": null,
"parent": 2
}
},
{
"pk": 4,
"model": "threadedcomments.threadedcomment",
"fields": {
"tree_path": "0000000001/0000000004",
"last_child": 6,
"parent": 1
}
},
{
"pk": 6,
"model": "threadedcomments.threadedcomment",
"fields": {
"tree_path": "0000000001/0000000004/0000000006",
"last_child": null,
"parent": 4
}
},
{
"pk": 7,
"model": "threadedcomments.threadedcomment",
"fields": {
"tree_path": "0000000007",
"last_child": null,
"parent": null
}
},
{
"pk": 1,
"model": "comments.comment",
"fields": {
"comment": "Comment 1",
"user_url": "",
"submit_date": "2009-03-31 17:58:09",
"ip_address": null,
"object_pk": "1",
"site": 1,
"is_removed": false,
"user": null,
"content_type": 7,
"is_public": true,
"user_name": "",
"user_email": ""
}
},
{
"pk": 2,
"model": "comments.comment",
"fields": {
"comment": "Comment 2",
"user_url": "",
"submit_date": "2009-03-31 17:58:12",
"ip_address": null,
"object_pk": "1",
"site": 1,
"is_removed": false,
"user": null,
"content_type": 7,
"is_public": true,
"user_name": "",
"user_email": ""
}
},
{
"pk": 3,
"model": "comments.comment",
"fields": {
"comment": "Comment 3",
"user_url": "",
"submit_date": "2009-03-31 17:58:28",
"ip_address": null,
"object_pk": "1",
"site": 1,
"is_removed": false,
"user": null,
"content_type": 7,
"is_public": true,
"user_name": "",
"user_email": ""
}
},
{
"pk": 4,
"model": "comments.comment",
"fields": {
"comment": "Comment 4",
"user_url": "",
"submit_date": "2009-03-31 17:58:50",
"ip_address": null,
"object_pk": "1",
"site": 1,
"is_removed": false,
"user": null,
"content_type": 7,
"is_public": true,
"user_name": "",
"user_email": ""
}
},
{
"pk": 5,
"model": "comments.comment",
"fields": {
"comment": "Comment 5",
"user_url": "",
"submit_date": "2009-03-31 17:58:57",
"ip_address": null,
"object_pk": "1",
"site": 1,
"is_removed": false,
"user": null,
"content_type": 7,
"is_public": true,
"user_name": "",
"user_email": ""
}
},
{
"pk": 6,
"model": "comments.comment",
"fields": {
"comment": "Comment 6",
"user_url": "",
"submit_date": "2009-03-31 17:59:17",
"ip_address": null,
"object_pk": "1",
"site": 1,
"is_removed": false,
"user": null,
"content_type": 7,
"is_public": true,
"user_name": "",
"user_email": ""
}
},
{
"pk": 7,
"model": "comments.comment",
"fields": {
"comment": "Comment 7",
"user_url": "",
"submit_date": "2009-03-31 17:59:25",
"ip_address": null,
"object_pk": "1",
"site": 1,
"is_removed": false,
"user": null,
"content_type": 7,
"is_public": true,
"user_name": "",
"user_email": ""
}
}
]
6 changes: 3 additions & 3 deletions threadedcomments/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
class Migration(migrations.Migration):

dependencies = [
('comments', '__first__'),
('django_comments', '__first__'),
]

operations = [
migrations.CreateModel(
name='ThreadedComment',
fields=[
('comment_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='comments.Comment')),
('comment_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='django_comments.Comment')),
('title', models.TextField(verbose_name='Title', blank=True)),
('tree_path', models.CharField(verbose_name='Tree path', max_length=500, editable=False, db_index=True)),
('last_child', models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, verbose_name='Last child', blank=True, to='threadedcomments.ThreadedComment', null=True)),
Expand All @@ -27,6 +27,6 @@ class Migration(migrations.Migration):
'verbose_name': 'Threaded comment',
'verbose_name_plural': 'Threaded comments',
},
bases=('comments.comment',),
bases=('django_comments.comment',),
),
]
5 changes: 4 additions & 1 deletion threadedcomments/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ def test_post_comment_child(self):


class HierarchyTest(TransactionTestCase):
fixtures = ['simple_tree']
if 'django.contrib.comments' in settings.INSTALLED_APPS:
fixtures = ['simple_tree_old']
else:
fixtures = ['simple_tree']

EXPECTED_HTML_PARTIAL = sanitize_html('''
<ul>
Expand Down

0 comments on commit 933f256

Please sign in to comment.