src/cm/security.py
changeset 470 077be006891e
parent 449 5387c032df35
child 522 c9c2148f09c9
equal deleted inserted replaced
469:08d57b273596 470:077be006891e
   190 
   190 
   191             # for role_teacher role model, add 'teacher' comments
   191             # for role_teacher role model, add 'teacher' comments
   192             if (role_model == 'teacher'):
   192             if (role_model == 'teacher'):
   193               with_teachers = []
   193               with_teachers = []
   194               for u in list(User.objects.filter(userrole__role__name = 'Teacher')):
   194               for u in list(User.objects.filter(userrole__role__name = 'Teacher')):
   195                 if DECORATED_CREATORS:
   195                 with_teachers.append(u.id)
   196                   with_teachers.append(u.username)
       
   197                 else:
       
   198                   with_teachers.append(u.id)
       
   199 
   196 
   200               # add admin and current user
   197               # add admin and current user
   201               admin =  User.objects.get(id=1)
   198               admin =  User.objects.get(id=1)
       
   199               with_teachers.append(admin.id)
   202               if DECORATED_CREATORS:
   200               if DECORATED_CREATORS:
   203                 with_teachers.append(admin.username)
   201                 myself = request.GET.get('name', None)
   204                 with_teachers.append(request.GET.get('name', None))
   202                 visible_comments = comments.filter(Q(user__id__in=with_teachers) | Q(name=myself)).order_by(*order_by)
   205                 visible_comments = comments.filter(name__in=with_teachers).order_by(*order_by)
       
   206               else:
   203               else:
   207                 with_teachers.append(admin.id)
       
   208                 with_teachers.append(user.id)
   204                 with_teachers.append(user.id)
   209                 visible_comments = comments.filter(user__id__in=with_teachers).order_by(*order_by)
   205                 visible_comments = comments.filter(user__id__in=with_teachers).order_by(*order_by)
   210 
   206 
   211             # filter comments with a non visible (i.e. moderated) comment in the above thread 
   207             # filter comments with a non visible (i.e. moderated) comment in the above thread 
   212             comments_thread_viewable = [c for c in visible_comments if c.is_thread_full_visible(own_user=user)]
   208             comments_thread_viewable = [c for c in visible_comments if c.is_thread_full_visible(own_user=user)]