-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does django reversion support with markdown syntax? #97
Comments
It is possible to write a own compare for special fields. What does your model field look like? |
Here is my @python_2_unicode_compatible
class QuestionSuggestedEdits(TimeStampedModel):
question = models.ForeignKey(
Question, related_name='suggested_edits_question')
editor = models.ForeignKey(
User, related_name='suggested_edits_editor')
title = models.CharField(
_('Title'), max_length=200)
tags = models.ManyToManyField(
Tag, related_name='suggested_edits_tags')
STATUS_CHOICES = (
('approved', _('Approved')),
('rejected', _('Rejected')),
('pending', _('Pending'))
)
status = models.CharField(
_('Status'), max_length=20,
choices=STATUS_CHOICES, default='pending')
description = models.TextField(_('Description'))
comment = models.TextField(_('Revision Comment'))
@property
def slug(self):
return slugify(self.title)
class Meta:
verbose_name_plural = _('question suggested edits')
ordering = ['-created'] and the from reversion_compare.views import HistoryCompareDetailView
from app_faq.models.question import QuestionSuggestedEdits
class QuestionSuggestedEditsReversions(HistoryCompareDetailView):
template_name = 'app_faq/question_revisions.html'
context_object_name = 'question_suggested_edits'
model = QuestionSuggestedEdits
compare_fields = ('description', )
# def fallback_compare(self, obj_compare):
# value1, value2 = obj_compare.to_string()
# html = html_diff_custom(value1, value2)
# return html
def get_object(self):
return get_object_or_404(self.model, pk=self.kwargs['pk'])
def compare_ManyToOneRel(self, obj_compare):
change_info = obj_compare.get_m2o_change_info()
context = {'change_info': change_info}
return render_to_string('reversion-compare/question/compare_generic_many_to_many.html', context)
def compare_ManyToManyField(self, obj_compare):
change_info = obj_compare.get_m2m_change_info()
context = {'change_info': change_info}
return render_to_string('reversion-compare/question/compare_generic_many_to_many.html', context) I still focusing on this def html_diff(value1, value2, cleanup=SEMANTIC):
"""
Generates a diff used google-diff-match-patch is exist or ndiff as fallback
The cleanup parameter can be SEMANTIC, EFFICIENCY or None to clean up the diff
for greater human readibility.
"""
value1 = force_text(value1)
value2 = force_text(value2)
if dmp is not None:
# Generate the diff with google-diff-match-patch
....
else:
# fallback: use built-in difflib
value1 = value1.splitlines()
value2 = value2.splitlines()
....
html = mark_safe(html)
return html |
You use https://github.com/agusmakmun/django-markdown-editor ? But i didn't see a e.g. if you have something like this:
Then you can do something like this:
In See: https://github.com/jedie/django-reversion-compare#customize |
If I following
The html output is;
The
{{ field_diff.diff }}
is converted as html. How I can handle the markdown syntax?https://github.com/etianen/django-reversion/wiki/_history
or maybe like this;
The text was updated successfully, but these errors were encountered: