src/pyams_content/features/review/zmi/__init__.py
changeset 527 5dd1aa8bedd9
parent 462 610a330cb669
child 591 b694d5667d17
equal deleted inserted replaced
526:b15153f45957 527:5dd1aa8bedd9
   134     """Shared content review form, JSON renderer"""
   134     """Shared content review form, JSON renderer"""
   135 
   135 
   136     def get_ajax_output(self, changes):
   136     def get_ajax_output(self, changes):
   137         translate = self.request.localizer.translate
   137         translate = self.request.localizer.translate
   138         if changes:
   138         if changes:
   139             return {'status': 'success',
   139             return {
   140                     'message': translate(_("Request successful. "
   140                 'status': 'success',
   141                                            "{count} new notification(s) have been sent")).format(count=changes),
   141                 'message': translate(_("Request successful. "
   142                     'events': [{
   142                                        "{count} new notification(s) have been sent")).format(count=changes),
   143                         'event': 'myams.refresh',
   143                 'events': [{
   144                         'options': {
   144                     'event': 'myams.refresh',
   145                             'handler': 'PyAMS_content.review.updateComments'
   145                     'options': {
   146                         }
   146                         'handler': 'PyAMS_content.review.updateComments'
   147                     }]}
   147                     }
       
   148                 }]
       
   149             }
   148         else:
   150         else:
   149             return {'status': 'info',
   151             return {
   150                     'message': translate(_("Request successful. No new notification have been sent")),
   152                 'status': 'info',
   151                     'events': [{
   153                 'message': translate(_("Request successful. No new notification have been sent")),
   152                         'event': 'myams.refresh',
   154                 'events': [{
   153                         'options': {
   155                     'event': 'myams.refresh',
   154                             'handler': 'PyAMS_content.review.updateComments'
   156                     'options': {
   155                         }
   157                         'handler': 'PyAMS_content.review.updateComments'
   156                     }]}
   158                     }
       
   159                 }]
       
   160             }
   157 
   161 
   158 
   162 
   159 #
   163 #
   160 # Share contents comments
   164 # Share contents comments
   161 #
   165 #
   255     def __call__(self):
   259     def __call__(self):
   256         request = self.request
   260         request = self.request
   257         translate = request.localizer.translate
   261         translate = request.localizer.translate
   258         comment_body = request.params.get('comment')
   262         comment_body = request.params.get('comment')
   259         if not comment_body:
   263         if not comment_body:
   260             return {'status': 'error',
   264             return {
   261                     'message': translate(_("Message is mandatory!"))}
   265                 'status': 'error',
       
   266                 'message': translate(_("Message is mandatory!"))
       
   267             }
   262         # add new comment
   268         # add new comment
   263         comments = IReviewComments(request.context)
   269         comments = IReviewComments(request.context)
   264         comment = ReviewComment(owner=request.principal.id,
   270         comment = ReviewComment(owner=request.principal.id,
   265                                 comment=request.params.get('comment'))
   271                                 comment=request.params.get('comment'))
   266         roles = IWfSharedContentRoles(request.context, None)
   272         roles = IWfSharedContentRoles(request.context, None)
   272         comment_body = self.template(request=request,
   278         comment_body = self.template(request=request,
   273                                      context=self.context,
   279                                      context=self.context,
   274                                      translate=query_utility(IChameleonTranslate),
   280                                      translate=query_utility(IChameleonTranslate),
   275                                      options={'comment': comment,
   281                                      options={'comment': comment,
   276                                               'profile': profile})
   282                                               'profile': profile})
   277         return {'status': 'success',
   283         return {
   278                 'callback': 'PyAMS_content.review.addCommentCallback',
   284             'status': 'success',
   279                 'options': {'content': comment_body,
   285             'callback': 'PyAMS_content.review.addCommentCallback',
   280                             'count': len(comments)}}
   286             'options': {
       
   287                 'content': comment_body,
       
   288                 'count': len(comments)
       
   289             }
       
   290         }