def item_description(self, item): # TODO: put this in a jinja template if django syndication will let us previous = item.get_previous() action = "Edited" if previous is None: action = "Created" by = "<h3>%s by:</h3><p>%s</p>" % (action, item.creator.username) comment = "" if item.comment: comment = "<h3>Comment:</h3><p>%s</p>" % item.comment review_diff = "" tag_diff = "" content_diff = "" if previous: prev_review_tags = ",".join([x.name for x in previous.review_tags.all()]) curr_review_tags = ",".join([x.name for x in item.review_tags.all()]) if prev_review_tags != curr_review_tags: review_diff = "<h3>Review changes:</h3>%s" % tag_diff_table( prev_review_tags, curr_review_tags, previous.id, item.id ) review_diff = colorize_diff(review_diff) if previous.tags != item.tags: tag_diff = "<h3>Tag changes:</h3>%s" % tag_diff_table(previous.tags, item.tags, previous.id, item.id) tag_diff = colorize_diff(tag_diff) previous_content = "" previous_id = "N/A" content_diff = "<h3>Content changes:</h3>" if previous: previous_content = previous.content previous_id = previous.id if previous_content != item.content: content_diff = content_diff + diff_table(previous_content, item.content, previous_id, item.id) content_diff = colorize_diff(content_diff) else: content_diff = content_diff + cgi.escape(item.content, quote=True) link_cell = '<td><a href="%s">%s</a></td>' view_cell = link_cell % (reverse("wiki.document", args=[item.document.full_path]), _("View Page")) edit_cell = link_cell % (reverse("wiki.edit_document", args=[item.document.full_path]), _("Edit Page")) compare_cell = "" if previous: compare_cell = link_cell % ( reverse("wiki.compare_revisions", args=[item.document.full_path]) + "?" + urllib.urlencode({"from": previous.id, "to": item.id}), _("Show comparison"), ) history_cell = link_cell % (reverse("wiki.document_revisions", args=[item.document.full_path]), _("History")) links_table = '<table border="0" width="80%">' links_table = links_table + "<tr>%s%s%s%s</tr>" % (view_cell, edit_cell, compare_cell, history_cell) links_table = links_table + "</table>" description = "%s%s%s%s%s%s" % (by, comment, tag_diff, review_diff, content_diff, links_table) return description
def context_dict(revision): """Return a dict that fills in the blanks in notification templates.""" document = revision.document from_revision = revision.get_previous() to_revision = revision diff = diff_table(from_revision.content, to_revision.content, from_revision.id, to_revision.id) return { 'document_title': document.title, 'creator': revision.creator, 'host': Site.objects.get_current().domain, 'history_url': reverse('wiki.document_revisions', locale=document.locale, args=[document.slug]), 'diff': diff }
def item_description(self, item): # TODO: put this in a jinja template if django syndication will let us previous = item.get_previous() action = "Edited" if previous is None: action = "Created" by = '<h3>%s by:</h3><p>%s</p>' % (action, item.creator.username) comment = '' if item.comment: comment = '<h3>Comment:</h3><p>%s</p>' % item.comment review_diff = '' tag_diff = '' content_diff = '' if previous: prev_review_tags = ','.join( [x.name for x in previous.review_tags.all()]) curr_review_tags = ','.join( [x.name for x in item.review_tags.all()]) if prev_review_tags != curr_review_tags: review_diff = ("<h3>Review changes:</h3>%s" % tag_diff_table( prev_review_tags, curr_review_tags, previous.id, item.id)) review_diff = colorize_diff(review_diff) if previous.tags != item.tags: tag_diff = ("<h3>Tag changes:</h3>%s" % tag_diff_table( previous.tags, item.tags, previous.id, item.id)) tag_diff = colorize_diff(tag_diff) previous_content = '' previous_id = 'N/A' content_diff = "<h3>Content changes:</h3>" if previous: previous_content = previous.content previous_id = previous.id if previous_content != item.content: content_diff = content_diff + diff_table( previous_content, item.content, previous_id, item.id) content_diff = colorize_diff(content_diff) else: content_diff = content_diff + cgi.escape(item.content, quote=True) link_cell = '<td><a href="%s">%s</a></td>' view_cell = link_cell % (reverse('wiki.document', args=[item.document.full_path]), _('View Page')) edit_cell = link_cell % (reverse('wiki.edit_document', args=[item.document.full_path]), _('Edit Page')) compare_cell = '' if previous: compare_cell = link_cell % (reverse('wiki.compare_revisions', args=[item.document.full_path]) + '?' + urllib.urlencode({'from': previous.id, 'to': item.id}), _('Show comparison')) history_cell = link_cell % (reverse('wiki.document_revisions', args=[item.document.full_path]), _('History')) links_table = '<table border="0" width="80%">' links_table = links_table + '<tr>%s%s%s%s</tr>' % (view_cell, edit_cell, compare_cell, history_cell) links_table = links_table + '</table>' description = "%s%s%s%s%s%s" % (by, comment, tag_diff, review_diff, content_diff, links_table) return description
def item_description(self, item): # TODO: put this in a jinja template if django syndication will let us previous = item.get_previous() action = "Edited" if previous is None: action = "Created" by = '<h3>%s by:</h3><p>%s</p>' % (action, item.creator.username) comment = '' if item.comment: comment = '<h3>Comment:</h3><p>%s</p>' % item.comment review_diff = '' tag_diff = '' content_diff = '' if previous: prev_review_tags = ','.join( [x.name for x in previous.review_tags.all()]) curr_review_tags = ','.join( [x.name for x in item.review_tags.all()]) if prev_review_tags != curr_review_tags: review_diff = ("<h3>Review changes:</h3>%s" % tag_diff_table( prev_review_tags, curr_review_tags, previous.id, item.id)) review_diff = colorize_diff(review_diff) if previous.tags != item.tags: tag_diff = ("<h3>Tag changes:</h3>%s" % tag_diff_table( previous.tags, item.tags, previous.id, item.id)) tag_diff = colorize_diff(tag_diff) previous_content = '' previous_id = 'N/A' content_diff = "<h3>Content changes:</h3>" if previous: previous_content = previous.content previous_id = previous.id if previous_content != item.content: content_diff = content_diff + diff_table( previous_content, item.content, previous_id, item.id) content_diff = colorize_diff(content_diff) else: content_diff = content_diff + cgi.escape(item.content, quote=True) link_cell = '<td><a href="%s">%s</a></td>' view_cell = link_cell % (reverse( 'wiki.document', args=[item.document.full_path]), _('View Page')) edit_cell = link_cell % (reverse('wiki.edit_document', args=[item.document.full_path ]), _('Edit Page')) compare_cell = '' if previous: compare_cell = link_cell % (reverse( 'wiki.compare_revisions', args=[item.document.full_path]) + '?' + urllib.urlencode({ 'from': previous.id, 'to': item.id }), _('Show comparison')) history_cell = link_cell % (reverse('wiki.document_revisions', args=[item.document.full_path ]), _('History')) links_table = '<table border="0" width="80%">' links_table = links_table + '<tr>%s%s%s%s</tr>' % ( view_cell, edit_cell, compare_cell, history_cell) links_table = links_table + '</table>' description = "%s%s%s%s%s%s" % (by, comment, tag_diff, review_diff, content_diff, links_table) return description