def context_dict(revision): """ Return a dict that fills in the blanks in notification templates. """ document = revision.document from_revision = revision.previous to_revision = revision diff = revisions_unified_diff(from_revision, to_revision) context = {"document_title": document.title, "creator": revision.creator, "diff": diff} if from_revision: compare_url = get_compare_url(document, from_revision.id, to_revision.id) else: compare_url = "" link_urls = { "user_url": revision.creator.get_absolute_url(), "compare_url": compare_url, "view_url": document.get_absolute_url(), "edit_url": reverse("wiki.edit_document", locale=document.locale, args=[document.slug]), "history_url": reverse("wiki.document_revisions", locale=document.locale, args=[document.slug]), } for name, url in link_urls.items(): context[name] = add_utm(url, "Wiki Doc Edits") return context
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 = revisions_unified_diff(from_revision, to_revision) compare_url = "" if from_revision: compare_url = reverse( "wiki.compare_revisions", args=[document.slug], locale=document.locale ) + "?from=%s&to=%s" % (from_revision.id, to_revision.id) link_urls = { "profile_url": revision.creator.get_absolute_url(), "compare_url": compare_url, "view_url": reverse("wiki.document", locale=document.locale, args=[document.slug]), "edit_url": reverse("wiki.edit_document", locale=document.locale, args=[document.slug]), "history_url": reverse("wiki.document_revisions", locale=document.locale, args=[document.slug]), } for name, url in link_urls.iteritems(): url = add_utm(url, "Wiki Doc Edits") link_urls[name] = url context = {"document_title": document.title, "creator": revision.creator, "diff": diff} context.update(link_urls) return context
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 = revisions_unified_diff(from_revision, to_revision) compare_url = '' if from_revision: compare_url = (reverse('wiki.compare_revisions', args=[document.full_path], locale=document.locale) + '?from=%s&to=%s' % (from_revision.id, to_revision.id)) link_urls = { 'profile_url': revision.creator.get_absolute_url(), 'compare_url': compare_url, 'view_url': reverse('wiki.document', locale=document.locale, args=[document.slug]), 'edit_url': reverse('wiki.edit_document', locale=document.locale, args=[document.slug]), 'history_url': reverse('wiki.document_revisions', locale=document.locale, args=[document.slug]), } for name, url in link_urls.iteritems(): url = add_utm(url, 'Wiki Doc Edits') link_urls[name] = url context = { 'document_title': document.title, 'creator': revision.creator, 'diff': diff } context.update(link_urls) return context
def context_dict(revision): """ Return a dict that fills in the blanks in notification templates. """ document = revision.document from_revision = revision.previous to_revision = revision diff = revisions_unified_diff(from_revision, to_revision) context = { 'document_title': document.title, 'creator': revision.creator, 'diff': diff, } if from_revision: compare_url = get_compare_url(document, from_revision.id, to_revision.id) else: compare_url = '' link_urls = { 'user_url': revision.creator.get_absolute_url(), 'compare_url': compare_url, 'view_url': document.get_absolute_url(), 'edit_url': reverse('wiki.edit_document', locale=document.locale, args=[document.slug]), 'history_url': reverse('wiki.document_revisions', locale=document.locale, args=[document.slug]), } for name, url in link_urls.items(): context[name] = add_utm(url, 'Wiki Doc Edits') return context
def context_dict(revision): """ Return a dict that fills in the blanks in notification templates. """ document = revision.document from_revision = revision.previous to_revision = revision diff = revisions_unified_diff(from_revision, to_revision) context = { 'document_title': document.title, 'creator': revision.creator, 'diff': diff, } if from_revision: compare_url = ( reverse('wiki.compare_revisions', args=[document.slug], locale=document.locale) + '?from=%s&to=%s' % (from_revision.id, to_revision.id) ) else: compare_url = '' link_urls = { 'user_url': revision.creator.get_absolute_url(), 'compare_url': compare_url, 'view_url': document.get_absolute_url(), 'edit_url': reverse('wiki.edit_document', locale=document.locale, args=[document.slug]), 'history_url': reverse('wiki.document_revisions', locale=document.locale, args=[document.slug]), } for name, url in link_urls.items(): context[name] = add_utm(url, 'Wiki Doc Edits') return context
def item_link(self, document): return add_utm( self.request.build_absolute_uri(document.get_absolute_url()), 'feed', medium='rss')
def item_author_link(self, document): return add_utm( self.request.build_absolute_uri( document.current_revision.creator.get_absolute_url()), 'feed', medium='rss')
def item_author_link(self, item): return add_utm( self.request.build_absolute_uri(item.creator.get_absolute_url()), 'feed', medium='rss')
def item_description(self, item): # TODO: put this in a jinja template if django syndication will let us previous = item.previous if previous is None: action = u'Created' else: action = u'Edited' by = u'<h3>%s by:</h3><p>%s</p>' % (action, item.creator.username) if item.comment: comment = u'<h3>Comment:</h3><p>%s</p>' % item.comment else: comment = u'' review_diff = u'' tag_diff = u'' content_diff = u'' if previous: prev_review_tags = previous.review_tags.names() curr_review_tags = item.review_tags.names() if set(prev_review_tags) != set(curr_review_tags): table = tag_diff_table(u','.join(prev_review_tags), u','.join(curr_review_tags), previous.id, item.id) review_diff = u'<h3>Review changes:</h3>%s' % table review_diff = colorize_diff(review_diff) if previous.tags != item.tags: table = tag_diff_table(previous.tags, item.tags, previous.id, item.id) tag_diff = u'<h3>Tag changes:</h3>%s' % table tag_diff = colorize_diff(tag_diff) previous_content = '' previous_id = u'N/A' content_diff = u'<h3>Content changes:</h3>' if previous: previous_content = previous.get_tidied_content() current_content = item.get_tidied_content() previous_id = previous.id if previous_content != current_content: content_diff = content_diff + diff_table( previous_content, current_content, previous_id, item.id) content_diff = colorize_diff(content_diff) else: content_diff = content_diff + escape(item.content) link_cell = u'<td><a href="%s">%s</a></td>' view_cell = link_cell % (add_utm(item.document.get_absolute_url(), 'feed', medium='rss'), _('View Page')) edit_cell = link_cell % (add_utm(item.document.get_edit_url(), 'feed', medium='rss'), _('Edit Page')) if previous: compare_cell = link_cell % ( add_utm( get_compare_url(item.document, previous.id, item.id), 'feed', medium='rss' ), _('Show comparison') ) else: compare_cell = '' history_cell = link_cell % ( add_utm( reverse( 'wiki.document_revisions', args=[item.document.slug] ), 'feed', medium='rss' ), _('History') ) links_table = u'<table border="0" width="80%">' links_table = links_table + u'<tr>%s%s%s%s</tr>' % (view_cell, edit_cell, compare_cell, history_cell) links_table = links_table + u'</table>' return u''.join([by, comment, tag_diff, review_diff, content_diff, links_table])
def item_link(self, item): return add_utm(self.request.build_absolute_uri(item.document.get_absolute_url()), "feed", medium="rss")
def item_description(self, item): # TODO: put this in a jinja template if django syndication will let us previous = item.previous if previous is None: action = u"Created" else: action = u"Edited" by = u"<h3>%s by:</h3><p>%s</p>" % (action, item.creator.username) if item.comment: comment = u"<h3>Comment:</h3><p>%s</p>" % item.comment else: comment = u"" review_diff = u"" tag_diff = u"" content_diff = u"" if previous: prev_review_tags = previous.review_tags.names() curr_review_tags = item.review_tags.names() if set(prev_review_tags) != set(curr_review_tags): table = tag_diff_table(u",".join(prev_review_tags), u",".join(curr_review_tags), previous.id, item.id) review_diff = u"<h3>Review changes:</h3>%s" % table review_diff = colorize_diff(review_diff) if previous.tags != item.tags: table = tag_diff_table(previous.tags, item.tags, previous.id, item.id) tag_diff = u"<h3>Tag changes:</h3>%s" % table tag_diff = colorize_diff(tag_diff) previous_content = "" previous_id = u"N/A" content_diff = u"<h3>Content changes:</h3>" if previous: previous_content = previous.get_tidied_content() current_content = item.get_tidied_content() previous_id = previous.id if previous_content != current_content: content_diff = content_diff + diff_table(previous_content, current_content, previous_id, item.id) content_diff = colorize_diff(content_diff) else: content_diff = content_diff + escape(item.content) link_cell = u'<td><a href="%s">%s</a></td>' view_cell = link_cell % (add_utm(item.document.get_absolute_url(), "feed", medium="rss"), _("View Page")) edit_cell = link_cell % (add_utm(item.document.get_edit_url(), "feed", medium="rss"), _("Edit Page")) if previous: compare_cell = link_cell % ( add_utm(get_compare_url(item.document, previous.id, item.id), "feed", medium="rss"), _("Show comparison"), ) else: compare_cell = "" history_cell = link_cell % ( add_utm(reverse("wiki.document_revisions", args=[item.document.slug]), "feed", medium="rss"), _("History"), ) links_table = u'<table border="0" width="80%">' links_table = links_table + u"<tr>%s%s%s%s</tr>" % (view_cell, edit_cell, compare_cell, history_cell) links_table = links_table + u"</table>" return u"".join([by, comment, tag_diff, review_diff, content_diff, links_table])