Skip to content

Commit

Permalink
revision compare for course articles
Browse files Browse the repository at this point in the history
  • Loading branch information
abhijitbonik committed Jun 12, 2018
1 parent fde39fb commit 18f764b
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion Course/admin.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
from django.contrib import admin
from mptt.admin import DraggableMPTTAdmin
from .models import Course, Topics, Links, TopicArticle
from reversion_compare.admin import CompareVersionAdmin
from reversion_compare.mixins import CompareMixin
from django.db.models import Manager
# Register your models here.

_old_compare = CompareMixin.compare


def compare(self, obj, version1, version2):
def replace_taggit_field(version_ins):
for fieldname in version_ins.field_dict:
if isinstance(version_ins.field_dict[fieldname], Manager):
version_ins.field_dict[fieldname] = []
replace_taggit_field(version1)
replace_taggit_field(version2)
return _old_compare(self, obj, version1, version2)

CompareMixin.compare = compare

class TopicArticleAdmin(CompareVersionAdmin):
pass

admin.site.register(Course)
admin.site.register(Links)
admin.site.register(TopicArticle)
admin.site.register(TopicArticle, TopicArticleAdmin)



Expand Down

0 comments on commit 18f764b

Please sign in to comment.