Browse Source

Starting with warn action. #37

Rafał Pitoń 11 years ago
parent
commit
4ebe4da39a

+ 0 - 0
misago/apps/warnuser/__init__.py


+ 6 - 0
misago/apps/warnuser/forms.py

@@ -0,0 +1,6 @@
+from django.utils.translation import ugettext_lazy as _
+import floppyforms as forms
+from misago.forms import Form
+
+class WarnMemberForm(Form):
+    reason = forms.CharField(label=_("Warning reason"), max_length=2048)

+ 28 - 0
misago/apps/warnuser/views.py

@@ -0,0 +1,28 @@
+from django.shortcuts import redirect
+from django.template import RequestContext
+from django.utils.translation import ugettext as _
+from misago import messages
+from misago.acl.exceptions import ACLError403
+from misago.apps.errors import error403, error404
+from misago.decorators import block_guest, check_csrf
+from misago.models import User
+from misago.shortcuts import render_to_response
+
+@block_guest
+@check_csrf
+def warn_user(request, user, slug):
+    try:
+        user = User.objects.get(pk=user)
+    except User.DoesNotExist:
+        return error404(request, _("Requested user could not be found"))
+
+    try:
+        request.acl.warnings.allow_warning_members():
+        user.acl().warnings.allow_warning()
+    except ACLError403 as e:
+        return error403(request, e)
+
+    form = 123
+    if ('origin' in request.POST
+            and request.POST.get('origin') == 'warning_form'):
+        pass

+ 1 - 0
misago/urls.py

@@ -22,6 +22,7 @@ urlpatterns = patterns('misago.apps',
     url(r'^popular/(?P<page>[1-9]([0-9]+)?)/$', 'popularthreads.popular_threads', name="popular_threads"),
     url(r'^popular/(?P<page>[1-9]([0-9]+)?)/$', 'popularthreads.popular_threads', name="popular_threads"),
     url(r'^new/$', 'newthreads.new_threads', name="new_threads"),
     url(r'^new/$', 'newthreads.new_threads', name="new_threads"),
     url(r'^new/(?P<page>[1-9]([0-9]+)?)/$', 'newthreads.new_threads', name="new_threads"),
     url(r'^new/(?P<page>[1-9]([0-9]+)?)/$', 'newthreads.new_threads', name="new_threads"),
+    url(r'^warn-user/(?P<slug>\w+)-(?P<user>\d+)/', 'warnuser.warn_user', name="warn_user"),
 )
 )
 
 
 urlpatterns += patterns('',
 urlpatterns += patterns('',