workspace followup available to anon user
authorraph
Thu, 14 Jan 2010 11:07:49 +0100
changeset 80 23294913284b
parent 79 116eb1f06072
child 81 720bafcca97d
workspace followup available to anon user
src/cm/templates/site/followup.html
src/cm/templates/site/text_followup.html
src/cm/views/followup.py
--- a/src/cm/templates/site/followup.html	Thu Jan 14 11:07:21 2010 +0100
+++ b/src/cm/templates/site/followup.html	Thu Jan 14 11:07:49 2010 +0100
@@ -17,8 +17,6 @@
 
 <div id="followup" class="tab-meta">   
 
-<form id="followup_form" enctype="multipart/form-data" action="." method="post">
-
 <h2 class="title_first">{% blocktrans %}Feeds{% endblocktrans %}</h2>
 
 <h3>{% blocktrans %}Public feed{% endblocktrans %} (<a title="{% blocktrans %}Help{% endblocktrans %}" target="_blank" href="{% url help %}#public_private_feed">?</a>)</h3>
@@ -30,6 +28,9 @@
 </div>
 {% blocktrans %}This is the public feed for the workspace.{% endblocktrans %}
 
+{% if user.is_authenticated %}
+<form id="followup_form" enctype="multipart/form-data" action="." method="post">
+
 {% if can_manage_workspace %}
 <h3>{% blocktrans %}Private feed{% endblocktrans %} (<a title="{% blocktrans %}Help{% endblocktrans %}" target="_blank" href="{% url help %}#public_private_feed">?</a>)</h3>
 
@@ -83,8 +84,9 @@
     }) ;
 	--> 
 	</script>
+</form>
+{% endif %}
 
-</form>
 </div>
 
 
--- a/src/cm/templates/site/text_followup.html	Thu Jan 14 11:07:21 2010 +0100
+++ b/src/cm/templates/site/text_followup.html	Thu Jan 14 11:07:49 2010 +0100
@@ -19,8 +19,6 @@
 
 <div id="followup_settings" class="tab-meta">   
 
-<form id="notifications" enctype="multipart/form-data" action="." method="post">
-
 <h2 class="title_first">{% blocktrans %}Feeds{% endblocktrans %}</h2>
 
 <h3>{% blocktrans %}Public feed{% endblocktrans %}</h3>
@@ -32,6 +30,9 @@
 </div>
 {% blocktrans %}This is the public feed for the text.{% endblocktrans %}
 
+{% if user.is_authenticated %}
+<form id="notifications" enctype="multipart/form-data" action="." method="post">
+
 {% if can_view_unapproved_comment %}
 <h3>{% blocktrans %}Private feed{% endblocktrans %}</h3>
 
@@ -75,8 +76,11 @@
         });
         
     }) ;
---> 
-</script>
+	--> 
+	</script>
+
+</form>
+{% endif %}
 
 </div>
 
--- a/src/cm/views/followup.py	Thu Jan 14 11:07:21 2010 +0100
+++ b/src/cm/views/followup.py	Thu Jan 14 11:07:49 2010 +0100
@@ -4,6 +4,7 @@
 from cm.models_base import generate_key
 from cm.views import get_text_by_keys_or_404
 from cm.utils.embed import embed_html
+from cm.security import get_request_user
 from django import forms
 from django.conf import settings
 from django.contrib.auth.decorators import login_required
@@ -18,10 +19,11 @@
 import re
 import time
 
-@login_required
+#@login_required
 def followup(request):
-    workspace_notify_check = Notification.objects.filter(text=None,type='workspace',user=request.user, active=True).count()
-    own_notify_check = Notification.objects.filter(text=None,type='own',user=request.user, active=True).count()
+    user = get_request_user(request)
+    workspace_notify_check = Notification.objects.filter(text=None,type='workspace',user=user, active=True).count()
+    own_notify_check = Notification.objects.filter(text=None,type='own',user=user, active=True).count()
     
     if request.method == 'POST':
         if 'activate' in request.POST:
@@ -35,7 +37,7 @@
             notif_type = 'own' if notif_id == 'own_notify_check' else 'workspace' 
             notif_val = request.POST.get(notif_id,None)
             if notif_val != None :
-                Notification.objects.set_notification(text=None, type=notif_type, active=(notif_val == 'true'), email_or_user=request.user)
+                Notification.objects.set_notification(text=None, type=notif_type, active=(notif_val == 'true'), email_or_user=user)
     
     return render_to_response('site/followup.html', {'workspace_notify_check':workspace_notify_check,
                                                           'own_notify_check' :own_notify_check,