src/cm/client.py
changeset 605 830993bdf983
parent 504 b2e0186daa5b
equal deleted inserted replaced
604:0dad543d4ed0 605:830993bdf983
    22 from cm.cm_settings import AUTO_CONTRIB_REGISTER, DECORATED_CREATORS
    22 from cm.cm_settings import AUTO_CONTRIB_REGISTER, DECORATED_CREATORS
    23 from settings import CLIENT_DATE_FMT
    23 from settings import CLIENT_DATE_FMT
    24 import re
    24 import re
    25 import time
    25 import time
    26 import operator
    26 import operator
       
    27 from django.core.cache import cache
    27 
    28 
    28 
    29 
    29 selection_place_error_msg = _(u'A selection is required. Select in the text the part your comment applies to.')
    30 selection_place_error_msg = _(u'A selection is required. Select in the text the part your comment applies to.')
    30 comment_states = ('approved', 'unapproved', 'pending')
    31 comment_states = ('approved', 'unapproved', 'pending')
    31 
    32 
   164         text = Text.objects.get(key=key)
   165         text = Text.objects.get(key=key)
   165         comment = Comment.objects.get(key = comment_key)
   166         comment = Comment.objects.get(key = comment_key)
   166         comment.delete()
   167         comment.delete()
   167         ret['msg'] = _(u'comment removed')
   168         ret['msg'] = _(u'comment removed')
   168         register_activity(request, "comment_removed", text=text, comment=comment)
   169         register_activity(request, "comment_removed", text=text, comment=comment)
       
   170         cache.clear()
   169     except ObjectDoesNotExist: 
   171     except ObjectDoesNotExist: 
   170         pass
   172         pass
   171     return ret ;
   173     return ret ;
   172 
   174 
   173 @has_perm_on_comment("can_edit_comment")
   175 @has_perm_on_comment("can_edit_comment")
   286             ret['msg'] = _(u"comment saved, it is being held for moderation")
   288             ret['msg'] = _(u"comment saved, it is being held for moderation")
   287         
   289         
   288         if AUTO_CONTRIB_REGISTER:
   290         if AUTO_CONTRIB_REGISTER:
   289             Notification.objects.set_notification(text=text, type='own', active=True, email_or_user=user or email)            
   291             Notification.objects.set_notification(text=text, type='own', active=True, email_or_user=user or email)            
   290         register_activity(request, "comment_created", text, comment)
   292         register_activity(request, "comment_created", text, comment)
       
   293         cache.clear()
   291     return ret
   294     return ret
   292 
   295 
   293 #we need to call comments_thread from here this function will be very expensive 
   296 #we need to call comments_thread from here this function will be very expensive 
   294 # TODO: stupid get rid of text argument
   297 # TODO: stupid get rid of text argument
   295 def get_filter_datas(request, text_version, text):
   298 def get_filter_datas(request, text_version, text):