\r
def process_data(self, **data):\r
revision_data = self.create_revision_data(**data)\r
- revision = self.node.create_revision(self.user, action=self, **revision_data)\r
+ revision = self.node.create_revision(self.user, **revision_data)\r
self.extra = revision.revision\r
\r
+ def process_action(self):\r
+ self.node.last_edited = self\r
+ self.node.save()\r
+\r
def describe(self, viewer=None):\r
return _("%(user)s edited %(post_desc)s") % {\r
'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),\r
def process_data(self, tagnames=''):\r
active = self.node.active_revision\r
revision_data = dict(summary=_('Retag'), title=active.title, tagnames=strip_tags(tagnames.strip()), body=active.body)\r
- self.node.create_revision(self.user, action=self, **revision_data)\r
+ revision = self.node.create_revision(self.user, **revision_data)\r
+ self.extra = revision.revision\r
+\r
+ def process_action(self):\r
+ self.node.last_edited = self\r
+ self.node.save()\r
\r
def describe(self, viewer=None):\r
return _("%(user)s retagged %(post_desc)s") % {\r
\r
def process_data(self, activate=None):\r
previous = self.node.active_revision\r
- self.node.activate_revision(self.user, activate, self)\r
+ self.node.activate_revision(self.user, activate)\r
self.extra = "%d:%d" % (previous.revision, activate.revision)\r
\r
+ def process_action(self):\r
+ self.node.last_edited = self\r
+ self.node.save()\r
+\r
def describe(self, viewer=None):\r
revisions = [NodeRevision.objects.get(node=self.node, revision=int(n)) for n in self.extra.split(':')]\r
\r
def process_action(self):\r
self.node.extra_action = self\r
self.node.marked = True\r
- self.node.save()\r
+ self.node.update_last_activity(self.user, save=True)\r
\r
def cancel_action(self):\r
self.node.extra_action = None\r
self.node.marked = False\r
- self.node.save()\r
+ self.node.update_last_activity(self.user, save=True)\r
\r
def describe(self, viewer=None):\r
return _("%(user)s closed %(post_desc)s: %(reason)s") % {\r
from forum.modules import get_modules_script
get_modules_script('badges')
+
+from base import BadgesMeta
+
def cancel_action(self):\r
pass\r
\r
+ @property\r
+ def verb(self):\r
+ return ""\r
+\r
def describe(self, viewer=None):\r
return ""\r
\r
+ def get_absolute_url(self):\r
+ if self.node:\r
+ return self.node.get_absolute_url()\r
+ else:\r
+ return self.user.get_profile_url()\r
+\r
def repute(self, user, value):\r
repute = ActionRepute(action=self, user=user, value=value)\r
repute.save()\r
\r
@models.permalink\r
def get_absolute_url(self):\r
- return ('badge', [], {'id': self.id, 'slug': slugify(self.name)}) \r
+ return ('badge', [], {'id': self.id, 'slug': slugify(self.name)})\r
+\r
+ def save(self, *args, **kwargs):\r
+ if isinstance(self.awarded_count, models.expressions.ExpressionNode):\r
+ super(Badge, self).save(*args, **kwargs)\r
+ self.awarded_count = self.__class__.objects.filter(id=self.id).values_list('awarded_count', flat=True)[0]\r
+ else:\r
+ super(Badge, self).save(*args, **kwargs)\r
+\r
\r
class Meta:\r
app_label = 'forum'\r
def summary(self):\r
return strip_tags(self.html)[:300]\r
\r
+ @models.permalink\r
+ def get_revisions_url(self):\r
+ return ('revisions', (), {'id': self.id})\r
+\r
def update_last_activity(self, user, save=False):\r
self.last_activity_by = user\r
self.last_activity_at = datetime.datetime.now()\r
revision.save()\r
return revision\r
\r
- def create_revision(self, user, action=None, **kwargs):\r
+ def create_revision(self, user, **kwargs):\r
number = self.revisions.aggregate(last=models.Max('revision'))['last'] + 1\r
revision = self._create_revision(user, number, **kwargs)\r
- self.activate_revision(user, revision, action)\r
+ self.activate_revision(user, revision)\r
return revision\r
\r
- def activate_revision(self, user, revision, action=None):\r
+ def activate_revision(self, user, revision):\r
self.title = revision.title\r
self.tagnames = revision.tagnames\r
self.body = revision.body\r
self.active_revision = revision\r
self.update_last_activity(user)\r
\r
- if action:\r
- self.last_edited = action\r
-\r
self.save()\r
\r
def get_tag_list_if_changed(self):\r
def delete_messages(self):\r
self.message_set.all().delete()\r
\r
+ @models.permalink\r
def get_profile_url(self):\r
- return "/%s%d/%s" % (_('users/'), self.id, slugify(self.username))\r
+ return ('user_profile', (), {'id': self.id, 'slug': slugify(self.username)})\r
\r
def get_profile_link(self):\r
profile_link = u'<a href="%s">%s</a>' % (self.get_profile_url(),self.username)\r
--- /dev/null
+{% load extra_tags %}
+<div class='post-update-info'>
+ <p style="line-height:12px;">
+ {{ node_verb }}
+ <strong>{% diff_date node.added_at %}</strong>
+ </p>
+ {% gravatar node.author 32 %}
+ <p><a href="{{ node.author.get_profile_url }}">{{ node.author.username }}</a><br/>
+ {% get_score_badge node.author %}</p>
+</div>
+{% if node.last_edited %}
+ <div class='post-update-info'>
+ <p style="line-height:12px;">
+ <a href="{{ node.get_revisions_url }}">
+ {{ node.last_edited.verb }}
+ <strong>{% diff_date node.last_edited.at %}</strong>
+ </a>
+ </p>
+ {% ifnotequal node.author node.last_edited.by %}
+ {% gravatar node.last_edited.by 32 %}
+ <p><a href="{{ node.last_edited.by.get_profile_url }}">{{ node.last_edited.by.username }}</a><br/>
+ {% get_score_badge node.last_edited.by %}</p>
+ {% endifnotequal %}
+ </div>
+{% endif %}
--- /dev/null
+{% load extra_tags %}\r
+<div class='post-update-info'>\r
+ <p style="line-height:12px;">\r
+ <strong>{% diff_date revision.revised_at %}</strong>\r
+ </p>\r
+ {% gravatar revision.author 32 %}\r
+ <p><a href="{{ revised_at.author.get_profile_url }}">{{ revision.author.username }}</a><br/>\r
+ {% get_score_badge revision.author %}</p>\r
+</div>
\ No newline at end of file
+++ /dev/null
-{% load i18n %}
-{% load smart_if %}
-{% load extra_tags %}
-<div class='post-update-info'>
-{% ifequal contributor_type "original_author" %}
- {% if wiki %}
- <p>{% trans "community wiki" %}</p>
- <p>
- {% blocktrans count post.revisions.all|length as rev_count %}
- one revision
- {% plural %}
- {{rev_count}} revisions
- {% endblocktrans %}
- </p>
- <p>{{post.author.get_profile_link}}</p>
- {% else %}
- <p style="line-height:12px;">
- {% ifequal post_type "question" %}
- {% trans "asked" %}
- {% else %}
- {% ifequal post_type "answer" %}
- {% trans "answered" %}
- {% else %}
- {% trans "posted" %}
- {% endifequal %}
- {% endifequal %}
- {% ifequal post_type "revision" %}
- <strong>{% diff_date post.revised_at %}</strong>
- {% else %}
- <strong>{% diff_date post.added_at %}</strong>
- {% endifequal %}
- </p>
- {% gravatar post.author 32 %}
- <p>{{post.author.get_profile_link}}<br/>
- {% get_score_badge post.author %}</p>
- {% endif %}
-{% else %}
- {% if post.last_edited %}
- <p style="line-height:12px;">
- {% ifequal post_type 'question' %}
- <a href="{% url question_revisions post.id %}">
- {% else %}
- <a href="{% url answer_revisions post.id %}">
- {% endifequal %}
- {% trans "updated" %} <strong>{% diff_date post.last_edited.at %}</strong>
- </a>
- </p>
- {% if post.author != post.last_edited.by or wiki %}
- {% gravatar post.last_edited.by 32 %}
- <p style="float:left">{{post.last_edited.by.get_profile_link}}<br/>
- {% get_score_badge post.last_edited.by %}</p>
- {% endif %}
- {% endif %}
-{% endifequal %}
-</div>
{% post_controls question request.user %}\r
</div>\r
<div class="post-update-info-container">\r
- {% post_contributor_info question "original_author" %}\r
- {% post_contributor_info question "last_updater" %}\r
+ {% contributors_info question %}\r
</div>\r
{% comments question request.user %}\r
</div>\r
{% post_controls answer request.user %}\r
</div>\r
<div class="post-update-info-container">\r
- {% post_contributor_info answer "original_author" %}\r
- {% post_contributor_info answer "last_updater" %}\r
+ {% contributors_info answer %}\r
</div>\r
{% comments answer request.user %}\r
</div>\r
{% extends "base_content.html" %}
-
+{% load node_tags %}
{% load extra_tags %}
{% load i18n %}
{% load extra_filters %}
</td>
<td align="right">
<div class="revision-mark" >
- {% post_contributor_info revision.inst %}
+ {% reviser_info revision.inst %}
</div>
</td>
</tr>
+++ /dev/null
-{% extends "base_content.html" %}
-<!-- revisions_answer.html -->
-{% load i18n %}
-{% load extra_tags %}
-{% load extra_filters %}
-{% load humanize %}
-{% block title %}{% spaceless %}{% trans "Revision history" %}{% endspaceless %}{% endblock %}
-{% block forejs %}
- <script type="text/javascript">
- //todo - take this out into .js file
- $().ready(function(){
- $("#nav_questions").attr('className',"on");
- $('div.revision div[id^=rev-header-]').bind('click', function(){
- var revId = this.id.substr(11);
- toggleRev(revId);
-
- });
- lanai.highlightSyntax();
- });
-
- function toggleRev(id) {
- var arrow = $("#rev-arrow-" + id);
- var visible = arrow.attr("src").indexOf("hide") > -1;
-
- var path = $.i18n._('/') + "media/images/expander-arrow-" +
- (visible ? "show" : "hide") + ".gif" + "?v={{settings.RESOURCE_REVISION}}";
- arrow.attr("src", path);
- $("#rev-body-" + id).slideToggle("fast");
- }
-
- </script>
-{% endblock %}
-
-{% block content %}
-<div id="main-bar" class="headNormal">
- {% trans "Revision history" %} [<a href="{{ post.get_absolute_url }}">{% trans "back" %}</a>]
-</div>
-<div id="main-body" class="">
- <div id="revisions">
- {% for revision in revisions %}
- <div class="revision">
- <div id="rev-header-{{ revision.revision }}" class="header {% ifequal post.author_id revision.author_id %}author{% endifequal %}">
- <div class="header-controls">
- <table width="100%">
- <tr>
- <td width="20" style="vertical-align:middle"><img id="rev-arrow-{{ revision.revision }}"
- src="{% media "/media/images/expander-arrow-show.gif" %}"
- alt="{% trans "click to hide/show revision" %}"/>
- </td>
- <td width="30px" style="vertical-align:middle"><span class="revision-number" title="{% trans "revision" %} {{ revision.revision }}">{{ revision.revision }}</span></td>
- <td width="200px" style="vertical-align:middle">
- {% if revision.summary %}
- <div class="summary"><span>{{ revision.summary }}</span></div>
- {% endif %}
- {% if request.user|can_edit_post:post %}
- <a href="{% url edit_answer post.id %}?revision={{ revision.revision }}">{% trans "edit" %}</a>
- {% endif %}
-
- </td>
- <td align="right">
- <div class="revision-mark" >
- {% post_contributor_info revision %}
- </div>
- </td>
- </tr>
-
- </table>
- </div>
- </div>
- <div id="rev-body-{{ revision.revision }}" class="answerbody">
- {{ revision.diff|safe }}
- </div>
- </div>
- {% endfor %}
- </div>
-</div>
-{% endblock %}
-
-{% block endjs %}
-{% endblock %}
-<!-- end revisions_answer.html -->
{% load i18n %}\r
{% block title %}{% spaceless %}{% trans "Edit user profile" %}{% endspaceless %}{% endblock %}\r
{% block forejs %}\r
- <script type="text/javascript">google.load("jquery", "1.4.2");</script>\r
+ <script type="text/javascript">google.load("jquery", "1.4.2");google.load("jqueryui", "1.8.1");</script>\r
\r
<link rel="stylesheet" href="http://jquery-ui.googlecode.com/svn/tags/latest/themes/base/jquery-ui.css" type="text/css" media="all" />\r
<link rel="stylesheet" href="http://static.jquery.com/ui/css/demo-docs-theme/ui.theme.css" type="text/css" media="all" />\r
- \r
- <script src="{% media "/media/js/effects.core.min.js" %}" type="text/javascript"></script>\r
- <script src="{% media "/media/js/ui.core.js" %}" type="text/javascript"></script>\r
- <script src="{% media "/media/js/ui.datepicker.js" %}" type="text/javascript"></script>\r
\r
<script type="text/javascript">\r
$().ready(function(){\r
"is_paginated": context["is_paginated"]
}
-@register.inclusion_tag("post_contributor_info.html")
-def post_contributor_info(post,contributor_type='original_author'):
- """contributor_type: original_author|last_updater
- """
- if isinstance(post,Question):
- post_type = 'question'
- elif isinstance(post,Answer):
- post_type = 'answer'
- elif isinstance(post,(AnswerRevision, QuestionRevision, NodeRevision)):
- post_type = 'revision'
- return {
- 'post':post,
- 'post_type':post_type,
- 'wiki_on':settings.WIKI_ON,
- 'contributor_type':contributor_type
- }
-
+
@register.simple_tag
def get_score_badge(user):
BADGE_TEMPLATE = '<span class="score" title="%(reputation)s %(reputationword)s">%(reputation)s</span>'
'total': len(all_comments),\r
'user': user,\r
}\r
+\r
+\r
+@register.inclusion_tag("node/contributors_info.html")\r
+def contributors_info(node):\r
+ return {\r
+ 'node_verb': (node.node_type == "question") and _("asked") or (\r
+ (node.node_type == "answer") and _("answered") or _("posted")),\r
+ 'node': node,\r
+ }\r
+\r
+\r
+@register.inclusion_tag("node/reviser_info.html")\r
+def reviser_info(revision):\r
+ return {'revision': revision}\r
+\r
return ActivityNode(activity, viewer)\r
\r
\r
-@register.inclusion_tag('users/moderation.html')\r
+@register.inclusion_tag('users/action_info.html')\r
def user_moderation(moderator, user):\r
- \r
return dict(user=user)\r
+\r
url(r'^%s$' % _('privacy/'), app.meta.privacy, name='privacy'),
url(r'^%s$' % _('logout/'), app.meta.logout, name='logout'),
url(r'^%s(?P<id>\d+)/%s$' % (_('answers/'), _('edit/')), app.writers.edit_answer, name='edit_answer'),
- url(r'^%s(?P<id>\d+)/%s$' % (_('answers/'), _('revisions/')), app.readers.revisions, name='answer_revisions'),
+ url(r'^%s(?P<id>\d+)/$' % _('revisions/'), app.readers.revisions, name='revisions'),
url(r'^%s$' % _('questions/'), app.readers.questions, name='questions'),
url(r'^%s%s$' % (_('questions/'), _('ask/')), app.writers.ask, name='ask'),
url(r'^%s%s$' % (_('questions/'), _('unanswered/')), app.readers.unanswered, name='unanswered'),
url(r'^%s' % _('matching_tags/'), app.commands.matching_tags, name='matching_tags'),
url(r'^%s(?P<id>\d+)/' % _('node_markdown/'), app.commands.node_markdown, name='node_markdown'),
- url(r'^%s(?P<id>\d+)/%s$' % (_('questions/'), _('revisions/')), app.readers.revisions, name='question_revisions'),
-
#place general question item in the end of other operations
url(r'^%s(?P<id>\d+)/(?P<slug>[\w-]*)$' % _('question/'), app.readers.question, name='question'),
url(r'^%s$' % _('tags/'), app.readers.tags, name='tags'),
else:
rev_ctx[i]['summary'] = revision.summary
- return render_to_response('revisions_question.html', {
+ return render_to_response('revisions.html', {
'post': post,
'revisions': rev_ctx,
}, context_instance=RequestContext(request))