[Oi-commits] r1391 - in trunk: forum media/dijital/img/forum profile templates/forum
oi-commits at pardus.org.tr
oi-commits at pardus.org.tr
Fri May 16 15:21:02 EEST 2008
Author: jnmbk
Date: Fri May 16 15:21:01 2008
New Revision: 1391
Added:
trunk/media/dijital/img/forum/exclamation.gif (contents, props changed)
trunk/templates/forum/abuse_list.html
- copied, changed from r1369, trunk/templates/user/followed_topics.html
trunk/templates/forum/forum_done.html
- copied, changed from r1369, trunk/templates/forum/forum_error.html
Modified:
trunk/forum/models.py
trunk/forum/urls.py
trunk/forum/views.py
trunk/profile/models.py
trunk/templates/forum/forum_error.html
trunk/templates/forum/topic.html
Log:
report abuse support for forum
Modified: trunk/forum/models.py
=================================================================
--- trunk/forum/models.py (original)
+++ trunk/forum/models.py Fri May 16 15:21:01 2008
@@ -79,6 +79,9 @@
def get_email_id(self):
return '<%s.%s@%s>' % (self.id, self.author.username, FORUM_FROM_EMAIL.split('@')[1])
+ def get_abuse_report_url(self):
+ return "/forum/raporla/%s/" % self.id
+
class Admin:
list_display = ('id', 'topic', 'author', 'created', 'ip')
@@ -294,6 +297,7 @@
class AbuseReport(models.Model):
post = models.ForeignKey(Post, verbose_name='İleti')
submitter = models.ForeignKey(User, verbose_name='Raporlayan kullanıcı')
+ reason = models.TextField(verbose_name="Sebep")
class Admin:
list_display = ('post', 'submitter')
Modified: trunk/forum/urls.py
=================================================================
--- trunk/forum/urls.py (original)
+++ trunk/forum/urls.py Fri May 16 15:21:01 2008
@@ -29,6 +29,8 @@
#(r'^okunmamis_konular/$', 'oi.forum.views.unread_topics'),
(r'^son-iletiler/$', 'oi.forum.views.latest_posts'),
(r'^tumunu-okunmus-say/$', 'oi.forum.views.mark_all_as_read'),
+ (r'^raporla/(?P<post_id>\d+)/$', 'oi.forum.views.report_abuse'),
+ (r'^raporlanmis-iletiler/$', 'oi.forum.views.list_abuse'),
(r'^(?P<forum_slug>.*)/(?P<topic_id>\d+)/delete/(?P<post_id>\d+)/$','oi.forum.views.delete_post'),
(r'^(?P<forum_slug>.*)/new/$', 'oi.forum.views.new_topic'),
(r'^(?P<forum_slug>.*)/(?P<topic_id>\d+)/quote/(?P<quote_id>\d+)/$', 'oi.forum.views.reply'),
Modified: trunk/forum/views.py
=================================================================
--- trunk/forum/views.py (original)
+++ trunk/forum/views.py Fri May 16 15:21:01 2008
@@ -163,8 +163,8 @@
# determine if user already added this to prevent double adding.
if len(WatchList.objects.filter(topic__id=topic_id).filter(user__username=request.user.username)) > 0:
- error = 'Bu başlığı zaten izlemektesiniz.'
- return render_response(request, 'forum/forum_error.html', {'error': error})
+ errorMessage = 'Bu başlığı zaten izlemektesiniz.'
+ return render_response(request, 'forum/forum_error.html', {'message': errorMessage})
else:
watchlist = WatchList(topic=topic, user=request.user)
watchlist.save()
@@ -602,3 +602,31 @@
post.delete()
return HttpResponseRedirect(topic.get_absolute_url())
+
+ at login_required
+def report_abuse(request,post_id):
+ post = get_object_or_404(Post, pk=post_id)
+
+ try:
+ AbuseReport.objects.get(post=post_id)
+ return render_response(request, "forum/forum_error.html", {"message":"Bu ileti daha önce raporlanmış."})
+ except ObjectDoesNotExist:
+ #TODO: take reason from POST
+ report = AbuseReport(post=post, submitter=request.user)
+ report.save()
+ return render_response(request, 'forum/forum_done.html', {"message":"İleti şikayetiniz ilgililere ulaştırılmıştır. Teşekkür Ederiz."})
+
+ at permission_required('forum.can_change_abuse', login_url="/kullanici/giris/")
+def list_abuse(request):
+ if request.method == 'POST':
+ list = request.POST.getlist('abuse_list')
+ for id in list:
+ AbuseReport.objects.get(id=id).delete()
+ print "silinen:", id
+ return HttpResponseRedirect(request.path)
+ else:
+ if AbuseReport.objects.count() == 0:
+ return render_response(request, 'forum/abuse_list.html', {'no_entry': True})
+ else:
+ abuse_list = AbuseReport.objects.all()
+ return render_response(request, 'forum/abuse_list.html', {'abuse_list': abuse_list})
Modified: trunk/profile/models.py
=================================================================
--- trunk/profile/models.py (original)
+++ trunk/profile/models.py Fri May 16 15:21:01 2008
@@ -90,7 +90,7 @@
latitude = models.DecimalField('Enlem', max_digits=10, decimal_places=6, default=0)
longitude = models.DecimalField('Boylam', max_digits=10, decimal_places=6, default=0)
- def __str__(self):
+ def __unicode__(self):
return self.user.username
class Admin:
@@ -106,3 +106,6 @@
class Meta:
verbose_name = "Kullanıcı Profili"
verbose_name_plural = "Kullanıcı Profilleri"
+
+ def get_absolute_url(self):
+ return '/kullanici/profil/%s/' % self.user.username
Copied: trunk/templates/forum/abuse_list.html (from r1369, trunk/templates/user/followed_topics.html)
=================================================================
--- trunk/templates/user/followed_topics.html (original)
+++ trunk/templates/forum/abuse_list.html Fri May 16 15:21:01 2008
@@ -1,6 +1,6 @@
{% extends "base.html" %}
-{% block title %}Takip Edilen Konular - {% endblock %}
+{% block title %}Raporlanmış İletiler - {% endblock %}
{% block header_menu %}
{% include "header.html" %}
@@ -15,17 +15,16 @@
<br />
{% if no_entry %}
-Şu anda izlemekte olduğunuz herhangi bir konu bulunmamaktadır. Foruma dönmek için <a href="/forum/">Tıklayın</a>
+Raporlanmış herhangi bir ileti bulunmamaktadır. Foruma dönmek için <a href="/forum/">Tıklayın</a>
{% else %}
<form action="" method="POST">
- <strong>Takip edilen konular: </strong><br /><br />
-{% for watch in watch_list %}
- <input type="checkbox" name="topic_watch_list" value="{{ watch.topic_id }}" /> <a href="{{watch.topic.get_absolute_url }}" target="_blank">{{ watch.topic.title }}</a></input><br />
+ <strong>Raporlanmış İletiler: </strong><br /><br />
+{% for abuse in abuse_list %}
+<input type="checkbox" name="abuse_list" value="{{ abuse.id }}" /> <a href="{{abuse.post.get_absolute_url }}" target="_blank">{{ abuse.post.topic.title }}</a> | Raporlayan: <a href="{{ abuse.submitter.get_profile.get_absolute_url }}">{{ abuse.submitter }}</a> | Sebep: {{ abuse.reason }}</input><br />
{% endfor %}
<br />
-<input type="submit" value="İzleme Listesinden Çıkar">
+<input type="submit" value="Şikayet Listesinden Çıkar" />
</form>
{% endif %}
-
{% endblock %}
Copied: trunk/templates/forum/forum_done.html (from r1369, trunk/templates/forum/forum_error.html)
=================================================================
--- trunk/templates/forum/forum_error.html (original)
+++ trunk/templates/forum/forum_done.html Fri May 16 15:21:01 2008
@@ -4,5 +4,5 @@
{% block content %}
<div id="space"> </div>
- <div class="forum_error">{{ error }}<br /><a href="javascript: history.go(-1)">Geri dönmek için tıklayın</a></div>
+ <div class="forum_done">{{ message }}<br /><a href="javascript: history.go(-1)">Geri dönmek için tıklayın</a></div>
{% endblock %}
Modified: trunk/templates/forum/forum_error.html
=================================================================
--- trunk/templates/forum/forum_error.html (original)
+++ trunk/templates/forum/forum_error.html Fri May 16 15:21:01 2008
@@ -4,5 +4,5 @@
{% block content %}
<div id="space"> </div>
- <div class="forum_error">{{ error }}<br /><a href="javascript: history.go(-1)">Geri dönmek için tıklayın</a></div>
+ <div class="forum_error">{{ message }}<br /><a href="javascript: history.go(-1)">Geri dönmek için tıklayın</a></div>
{% endblock %}
Modified: trunk/templates/forum/topic.html
=================================================================
--- trunk/templates/forum/topic.html (original)
+++ trunk/templates/forum/topic.html Fri May 16 15:21:01 2008
@@ -40,6 +40,10 @@
<div class="post_message_top_date">
{{ post.created|date:"d-m-Y H:i" }}
</div>
+ {% if request.user.is_authenticated %}
+ <div class="post_message_top_button">
+ <a href="{{ post.get_abuse_report_url }}"><img src="/media/dijital/img/forum/exclamation.gif" alt="raporla" title="Kurallara uymayan iletiyi şikayet et" border="0" /></a>
+ </div>
<div class="post_message_top_button">
<a href="{{ post.get_quote_url }}"><img src="/media/dijital/img/forum/quote.gif" alt="alıntıla" border="0" /></a>
</div>
@@ -83,6 +87,7 @@
{% endifequal %}
{% endifequal %}
{% endif %}
+ {% endif %}
</div>
<div class="post_message_content">
<div class="post_message_text">{{ post.text|renderbbcode|safe }}</div>
More information about the Oi-commits
mailing list