Fix bugs in permissions
authorverrierj
Thu, 02 Feb 2012 17:39:54 +0100
changeset 515 d1be4a4f6639
parent 513 d7a40f4dc38b
child 516 1166fb6bc9b4
Fix bugs in permissions
src/ldt/ldt/ldt_utils/models.py
src/ldt/ldt/ldt_utils/views/content.py
src/ldt/ldt/security/command.py
--- a/src/ldt/ldt/ldt_utils/models.py	Thu Feb 02 16:12:46 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/models.py	Thu Feb 02 17:39:54 2012 +0100
@@ -224,7 +224,10 @@
             create_front_project = True
             
             if not self.nb_annotation:
-                self.nb_annotation = 0    
+                self.nb_annotation = 0  
+            if not self.stat_annotation:
+                self.stat_annotation =  self.__list2str([0] * (settings.DIVISIONS_FOR_STAT_ANNOTATION + len(settings.SYNTAX.keys())))
+  
 
         super(Content, self).save(*args, **kwargs)
         
@@ -373,10 +376,10 @@
             
         set_current_user(admin)
         self.front_project = Project.create_project(admin, 'front project : %s' % self.title, [self], cuttings=['chapitrage', 'contributions'] )
-        self.front_project.publish(allow_write=True)
+        self.front_project.publish(allow_write=True)            
+        self.save()
         set_current_user(old_user)
-            
-        self.save()
+
     
     # Tag management
     def get_tags(self):
--- a/src/ldt/ldt/ldt_utils/views/content.py	Thu Feb 02 16:12:46 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/views/content.py	Thu Feb 02 17:39:54 2012 +0100
@@ -222,8 +222,8 @@
                     if media:
                         cached_assign('view_media', everyone, media)
                 else:
-                    remove_perm('view_content', everyone, content)
-                    remove_perm('view_media', everyone, media)
+                    remove_perm('ldt_utils.view_content', everyone, content)
+                    remove_perm('ldt_utils.view_media', everyone, media)
                     assign_perm_to_obj(content, content_form.cleaned_data['read_list'], content_form.cleaned_data['write_list'], request.user)
                     if media:
                         assign_perm_to_obj(media, content_form.cleaned_data['read_list'], content_form.cleaned_data['write_list'], request.user)
--- a/src/ldt/ldt/security/command.py	Thu Feb 02 16:12:46 2012 +0100
+++ b/src/ldt/ldt/security/command.py	Thu Feb 02 17:39:54 2012 +0100
@@ -28,8 +28,12 @@
         total = list_model['Project'].objects.count()
         
     for proj in list_model['Project'].objects.all():
-        assign('ldt_utils.change_project', proj.owner, proj)
-        assign('ldt_utils.view_project', proj.owner, proj)
+        
+        if proj.state == 2:
+            proj.publish()
+        else:
+            proj.unpublish()
+            
         if verbose:
             show_progress(i, total, "Assign permissions to projects", 40, writer)
             i += 1