Skip to content

Commit

Permalink
Merge branch 'release/2.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanbegbie committed Jan 16, 2017
2 parents 4f46445 + af26928 commit ffbeda3
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 13 deletions.
29 changes: 28 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,39 @@
CHANGELOG
=========

2.0.0
-----
- Removed dependency on wagtailmodeladmin

Backwards incompatible changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Removed use of ``wagtailmodeladmin``: use ``wagtail.contrib.modeladmin`` instead
- ``{% load wagtailmodeladmin_tags %}`` has been replaced by ``{% load modeladmin_tags %}``

NOTE: This release is not compatible with molo versions that are less than 4.0

1.0.4
-----
- Delete Comment Moderator and Expert group and recreate them again

1.0.3
-----
- Remove a duplicate line in migration

1.0.2
-----
- Fix a bug in permissions migration

1.0.1
-----
- Add commenting permissions to groups

1.0.0
-----
- Add BEM template naming convention
- Add namespace to commenting URLs in the temolates
- Remove `url(r'', include('django_comments.urls'))` from commenting URLs
Note: If you are using this release you need to add the `url(r'', include('django_comments.urls'))` to your app's urls.py
Note: If you are using this release you need to add the `url(r'', include('django_comments.urls'))` to your app's urls.py

0.5.4
-----
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
2.0.0
4 changes: 2 additions & 2 deletions molo/commenting/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

from daterange_filter.filter import DateRangeFilter

from wagtailmodeladmin.options import ModelAdmin as WagtailModelAdmin, \
ModelAdminGroup
from wagtail.contrib.modeladmin.options import ModelAdmin \
as WagtailModelAdmin, ModelAdminGroup


class MoloCommentAdmin(MPTTModelAdmin, CommentsAdmin):
Expand Down
2 changes: 1 addition & 1 deletion molo/commenting/admin_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from molo.commenting.admin_import_export import MoloCommentsResource
from molo.commenting.forms import AdminMoloCommentReplyForm
from molo.commenting.models import MoloComment
from wagtailmodeladmin.views import IndexView
from wagtail.contrib.modeladmin.views import IndexView
from django.utils.translation import ugettext as _


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.9 on 2016-10-23 12:29
from __future__ import unicode_literals

from django.db import migrations
from django.core.management.sql import emit_post_migrate_signal


class Migration(migrations.Migration):
def add_commenting_permissions_to_groups(apps, schema_editor):
db_alias = schema_editor.connection.alias
try:
# Django 1.9
emit_post_migrate_signal(2, False, db_alias)
except TypeError:
# Django < 1.9
try:
# Django 1.8
emit_post_migrate_signal(2, False, 'default', db_alias)
except TypeError: # Django < 1.8
emit_post_migrate_signal([], 2, False, 'default', db_alias)

Group = apps.get_model('auth.Group')
Permission = apps.get_model('auth.Permission')
GroupPagePermission = apps.get_model('wagtailcore.GroupPagePermission')

if Group.objects.all().filter(name='Comment Moderator'):
Group.objects.get(name='Comment Moderator').delete()

if Group.objects.all().filter(name='Expert'):
Group.objects.get(name='Expert').delete()


# Create groups

access_admin = Permission.objects.get(codename='access_admin')

# <- Moderator ->
moderator_group = Group.objects.get(name='Moderators')

add_cannedresponse = Permission.objects.get(
codename='add_cannedresponse')
change_cannedresponse = Permission.objects.get(
codename='change_cannedresponse')
delete_cannedresponse = Permission.objects.get(
codename='delete_cannedresponse')
add_molocomment = Permission.objects.get(
codename='add_molocomment')
delete_molocomment = Permission.objects.get(
codename='delete_molocomment')
moderator_group.permissions.add(
add_cannedresponse, delete_cannedresponse,
change_cannedresponse, add_molocomment, delete_molocomment)

# <- Comment Moderator ->
comment_moderator_group, _created = Group.objects.get_or_create(name='Comment Moderator')
comment_moderator_group.permissions.add(access_admin)
change_user = Permission.objects.get(
codename='change_user')
comment_moderator_group.permissions.add(change_user,
add_cannedresponse, add_molocomment, delete_molocomment)

# <- Expert ->
expert_group, _created = Group.objects.get_or_create(name='Expert')
expert_group.permissions.add(access_admin)
expert_group.permissions.add(add_molocomment)

dependencies = [
('commenting', '0004_auto_20160713_0221'),
('core', '0047_add_core_permissions_to_groups'),
('contenttypes', '__latest__'),
('sites', '__latest__'),
('auth', '__latest__'),
('wagtailcore', '__latest__'),
('wagtailadmin', '__latest__'),
('wagtailusers', '__latest__'),
]

operations = [
migrations.RunPython(add_commenting_permissions_to_groups),
]
2 changes: 1 addition & 1 deletion molo/commenting/templates/admin/molo_comments_admin.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "wagtailadmin/base.html" %}
{% load i18n wagtailmodeladmin_tags admin_static admin_modify %}
{% load i18n modeladmin_tags admin_static admin_modify %}
{% load admin_urls %}

{% block titletag %}{{ view.get_meta_title }}{% endblock %}
Expand Down
6 changes: 3 additions & 3 deletions molo/commenting/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def test_comment_appears_in_admin_view(self):
comment = self.mk_comment('the comment')

response = self.client.get(
'/admin/modeladmin/commenting/molocomment/'
'/admin/commenting/molocomment/'
)

self.assertContains(response, comment.comment)
Expand All @@ -275,7 +275,7 @@ def test_canned_response_appears_in_canned_responses_admin_view(self):
)

response = self.client.get(
'/admin/modeladmin/commenting/cannedresponse/'
'/admin/commenting/cannedresponse/'
)

self.assertContains(response, canned_response.response_header)
Expand All @@ -284,7 +284,7 @@ def test_export_csv(self):
self.mk_comment('export comment')

response = self.client.post(
'/admin/modeladmin/commenting/molocomment/'
'/admin/commenting/molocomment/'
)

# substitute the datetime component to avoid intermittent test failures
Expand Down
5 changes: 3 additions & 2 deletions molo/commenting/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from molo.commenting.admin import CommentingModelAdminGroup
from molo.commenting.admin_views import MoloCommentsAdminReplyView
from wagtail.wagtailcore import hooks
from wagtailmodeladmin.options import wagtailmodeladmin_register
from wagtail.contrib.modeladmin.options import modeladmin_register


@hooks.register('register_admin_urls')
Expand All @@ -13,4 +13,5 @@ def register_molo_comments_admin_reply_url():
name='molo-comments-admin-reply'),
]

wagtailmodeladmin_register(CommentingModelAdminGroup)

modeladmin_register(CommentingModelAdminGroup)
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
molo.core
molo.core<5.0.0,>=4.0.0
django-contrib-comments==1.7.1
django-mptt==0.8.5
django-import-export
wagtailmodeladmin
django-daterange-filter

0 comments on commit ffbeda3

Please sign in to comment.