bug fix : can view own comment on comment add on mod priori
authorreno
Thu, 03 Dec 2009 15:55:39 +0100
changeset 17 a4be0b8a905d
parent 16 036705244cab
child 18 f0f9929a4900
bug fix : can view own comment on comment add on mod priori bug fix : client : add no-notif record when user declines it
README.txt
src/cm/client.py
src/cm/fixtures/roles_teacher.yaml
src/cm/media/js/client/c_sync.js
src/cm/models.py
--- a/README.txt	Thu Dec 03 11:55:50 2009 +0100
+++ b/README.txt	Thu Dec 03 15:55:39 2009 +0100
@@ -68,7 +68,7 @@
 8. Create basic right management system
    - `./bin/django loaddata roles_generic --settings=settings`
 9. Launch development server
-   - `./bin/django manage.py runserver --settings=settings`
+   - `./bin/django runserver --settings=settings`
 10. Access your Comt instance by pointing your browser to http://127.0.0.1:8000/
 
 Installation (production environment)
--- a/src/cm/client.py	Thu Dec 03 11:55:50 2009 +0100
+++ b/src/cm/client.py	Thu Dec 03 15:55:39 2009 +0100
@@ -217,8 +217,9 @@
         if email_or_user :
             email_or_user = email_or_user.lower().strip()
 
+    active = (request.POST.get('active', False) == 'true')
     text = Text.objects.get(key=key)
-    Notification.objects.set_notification(text=None, type='own', active=True, email_or_user=email_or_user)
+    Notification.objects.set_notification(text=None, type='own', active=active, email_or_user=email_or_user)
     ret = HttpResponse()
     ret.status_code = 200 
     return ret 
@@ -266,8 +267,8 @@
             ask_for_notification = ( None == Notification.objects.get_notifications(text=None, type='own', email_or_user=(user if user else email)))
         ret['ask_for_notification'] = ask_for_notification
         ret['email'] = '' if user else email
-    
-        if text_version.mod_posteriori or has_perm(request, 'can_view_unapproved_comment', text=text) : 
+
+        if text_version.mod_posteriori or has_perm(request, 'can_view_unapproved_comment', text=text) or has_perm(request, 'can_view_comment_own', text=text) : 
             ret['comment'] = comment
             ret['msg'] = _(u"comment saved")
         else :
--- a/src/cm/fixtures/roles_teacher.yaml	Thu Dec 03 11:55:50 2009 +0100
+++ b/src/cm/fixtures/roles_teacher.yaml	Thu Dec 03 15:55:39 2009 +0100
@@ -14,10 +14,9 @@
   fields:
     name: "Student"
     description: "" 
-    permissions: [52, 11, 31, 35, 33, 34]
+    permissions: [52, 11, 31, 33, 34]
 # can_view_approved_comment 34    
 # can_delete_comment_own	33
-# can_view_comment_own		35
 # can_create_comment		31
 # can_view_text				11
 # can_view_workspace		52                    
@@ -27,7 +26,7 @@
   fields:
     name: "Individual student"
     description: "" 
-    permissions: [52, 11, 31, 35, 33]
+    permissions: [52, 11, 31, 33, 35]
 # can_delete_comment_own	33
 # can_view_comment_own		35
 # can_create_comment		31
--- a/src/cm/media/js/client/c_sync.js	Thu Dec 03 11:55:50 2009 +0100
+++ b/src/cm/media/js/client/c_sync.js	Thu Dec 03 15:55:39 2009 +0100
@@ -127,11 +127,18 @@
 				if ("ask_for_notification" in ret) {  
 					if (ret['ask_for_notification']) {
 						// TODO ask for notification ...or use AUTO_CONTRIB ?
-						parent.f_yesNoDialog(gettext("Do you want to subscribe to all replies notifications in discussions you participated in?"), gettext("Follow up"), null, null, null, 
+						parent.f_yesNoDialog(gettext("Do you want to subscribe to all replies notifications in discussions you participated in?"), gettext("Follow up"), 
 							function() { // special case : no waiting for the return, no error check, nothing !
 									var cfg = {
 									method: "POST", 
-									data: urlEncode({'fun':'ownNotify', 'key':sv_key, 'email':ret['email']}) 
+									data: urlEncode({'fun':'ownNotify', 'key':sv_key, 'email':ret['email'], 'active':false}) 
+								} ; 
+								CY.io(sv_client_url, cfg);
+							}, this, null,
+							function() { // special case : no waiting for the return, no error check, nothing !
+									var cfg = {
+									method: "POST", 
+									data: urlEncode({'fun':'ownNotify', 'key':sv_key, 'email':ret['email'], 'active':true}) 
 								} ; 
 								CY.io(sv_client_url, cfg);
 							}, this, null) ;
--- a/src/cm/models.py	Thu Dec 03 11:55:50 2009 +0100
+++ b/src/cm/models.py	Thu Dec 03 15:55:39 2009 +0100
@@ -199,7 +199,7 @@
 #            comments = self.comment_set.all()
 #        elif has_perm(user, 'can_view_approved_comment', self.text):
 #            comments = self.comment_set.filter(visible=True)
-#        elif has_perm(user, 'can_view_own_comment', self.text):
+#        elif has_perm(user, 'can_view_comment_own', self.text):
 #            comments = self.comment_set.filter(user=user)
 #        else:
 #            return Comment.objects.none() # empty queryset