add post_count in profile

This commit is contained in:
alafin 2009-01-19 21:23:53 +02:00
parent b895061918
commit 075f158999
8 changed files with 18 additions and 7 deletions

View file

@ -75,6 +75,9 @@ class AddPostForm(forms.ModelForm):
markup='bbcode',
body=self.cleaned_data['body'])
post.save()
profile = get_object_or_404(Profile, user=self.user)
profile.post_count += 1
profile.save()
return post
class EssentialsProfileForm(forms.ModelForm):

View file

@ -269,6 +269,7 @@ class Profile(models.Model):
show_signatures = models.BooleanField(_('Show signatures'), blank=True, default=True)
privacy_permission = models.IntegerField(_('Privacy permission'), choices=PRIVACY_CHOICES, default=1)
markup = models.CharField(_('Default markup'), max_length=15, default=forum_settings.DEFAULT_MARKUP, choices=MARKUP_CHOICES)
post_count = models.IntegerField(_('Post count'), blank=True, default=0)
class Meta:
verbose_name = _('Profile')
@ -333,7 +334,6 @@ class Report(models.Model):
return u'%s %s' % (self.reported_by ,self.zapped)
class PrivateMessage(models.Model):
dst_user = models.ForeignKey(User, verbose_name=_('Recipient'), related_name='dst_users')
src_user = models.ForeignKey(User, verbose_name=_('Author'), related_name='src_users')
read = models.BooleanField(_('Read'), blank=True, default=False)

View file

@ -63,7 +63,7 @@
<div class="infldset">
<p>{% trans "Registered:" %} {{ profile.date_joined|date:"Y-m-d" }}</p>
<p>{% trans "Last post:" %} {{ profile.forum_profile.last_post }}</p>
<label>{% trans "Posts:" %} {{ form.fields.post_count.initial }} -
<label>{% trans "Posts:" %} {{ profile.forum_profile.post_count }} -
<a href="{% url search %}?action=show_user&user_id={{ profile.id }}">{% trans "Show all posts" %}</a></p>
</label>
</div>

View file

@ -44,7 +44,7 @@
<dd>{% trans "From:" %} {{ post.user.forum_profile.location }}</dd>
{% endif %}
<dd>{% trans "Registered:" %} {{ post.user.date_joined|date:"Y-m-d" }}</dd>
<dd>{% trans "Posts:" %} {{ post.user.posts.count }}</dd>
<dd>{% trans "Posts:" %} {{ post.user.forum_profile.post_count }}</dd>
{% if moderator %}
<dd>{% trans "IP:" %} {{ post.user_ip }}</dd>
{% endif %}

View file

@ -125,7 +125,7 @@
<div class="infldset">
<dl>
<dt>{% trans "Posts:" %} </dt>
<dd>{{ profile.posts.all.count }} - <a href="{% url search %}?action=show_user&user_id={{ profile.id }}">Показать все сообщения</a></dd>
<dd>{{ profile.forum_profile.post_count }} - <a href="{% url search %}?action=show_user&user_id={{ profile.id }}">Показать все сообщения</a></dd>
<dt>{% trans "Last post:" %} </dt>
{% if profile.forum_profile.last_post %}
<dd>{{ profile.forum_profile.last_post }}</dd>

View file

@ -57,7 +57,7 @@
<tr>
<td class="tcl">{{ profile|profile_link }}</td>
<td class="tc2">{{ profile.forum_profile.status }}</td>
<td class="tc3">{{ profile.posts.count }}</td>
<td class="tc3">{{ profile.forum_profile.post_count }}</td>
<td class="tcr">{{ profile.date_joined|date:"d-m-Y" }}</td>
</tr>
{% endfor %}

View file

@ -579,12 +579,19 @@ def delete_post(request, post_id):
return HttpResponseRedirect(post.get_absolute_url())
topic = post.topic
forum = post.topic.forum
topic.post_count -= 1
topic.save()
forum = post.topic.forum
forum.post_count -= 1
forum.save()
topic.save()
profile = get_object_or_404(Profile, user=post.user)
profile.post_count -= 1
profile.save()
post.delete()
try:
Topic.objects.get(pk=topic.id)

View file

@ -89,6 +89,7 @@ INSTALLED_APPS = (
'apps.account',
'apps.captcha',
'apps.forum',
'django_evolution',
)
FORCE_SCRIPT_NAME = ''