diff --git a/openslides/motion/models.py b/openslides/motion/models.py index 25260f71d..ac9a41854 100644 --- a/openslides/motion/models.py +++ b/openslides/motion/models.py @@ -15,6 +15,8 @@ from datetime import datetime +import difflib + from django.core.urlresolvers import reverse from django.db import models from django.db.models import Max @@ -496,6 +498,12 @@ class MotionVersion(models.Model): """Return True, if the version is the active version of a motion. Else: False.""" return self.active_version.exists() + def make_htmldiff(self, rev1, rev2): + """Return string of html diff between two strings (rev1 and rev2)""" + + diff = difflib.HtmlDiff(wrapcolumn=60) + return diff.make_table(rev1.splitlines(), rev2.splitlines()) + class MotionSubmitter(models.Model): """Save the submitter of a Motion.""" diff --git a/openslides/motion/static/styles/motion.css b/openslides/motion/static/styles/motion.css new file mode 100644 index 000000000..951f94309 --- /dev/null +++ b/openslides/motion/static/styles/motion.css @@ -0,0 +1,41 @@ +/** + * OpenSlides motion style + * + * :copyright: 2013 by OpenSlides team, see AUTHORS. + * :license: GNU GPL, see LICENSE for more details. + */ + +/* motion version diff table */ +table.diff, .diff_row { + font-size: 12px; + width: 100%; + border: 0px; +} +table.diff[rules][rules="groups"] > colgroup, table[rules][rules="groups"] > tfoot, table[rules][rules="groups"] > thead, table[rules][rules="groups"] > tbody { + border: none; +} +table.diff td { + padding: 0 !important; + border: none; +} +.diff_header { + background-color:#e0e0e0; +} +td.diff_header { + text-align:right; + display: none; +} +.diff_next { + background-color:#c0c0c0; + display: none; +} +.diff_add { + background-color:#aaffaa; +} +.diff_chg { + background-color:#ffff77; +} +.diff_sub { + background-color:#ffaaaa; +} + diff --git a/openslides/motion/templates/motion/motion_detail.html b/openslides/motion/templates/motion/motion_detail.html index 231854e97..3548beba8 100644 --- a/openslides/motion/templates/motion/motion_detail.html +++ b/openslides/motion/templates/motion/motion_detail.html @@ -56,14 +56,14 @@
{% trans "Version" %} {{ version_rev1.version_number }} + {% trans "created: " %} {{ version_rev1.creation_time }} + {{ version_rev1.title }}+ |
+ {% trans "Version" %} {{ version_rev2.version_number }} + {% trans "created: " %} {{ version_rev1.creation_time }} + {{ version_rev2.title }}+ |
+||
{{ diff_text|safe }} | + {% else %} +{{ version_rev1.text }} | +{{ version_rev2.text }} | + {% endif %} +|
{% trans "Reason" %}: | |||
{{ diff_reason|safe }} | + {% else %} +{{ version_rev1.reason }} | +{{ version_rev2.reason }} | + {% endif %} +