src/cm/api/handlers.py
changeset 299 34b4038e3069
parent 297 173710f4b6d1
child 300 7aaf5c0d6af4
equal deleted inserted replaced
298:f6dab88267b7 299:34b4038e3069
   323     args = None
   323     args = None
   324     
   324     
   325     @staticmethod
   325     @staticmethod
   326     def endpoint():
   326     def endpoint():
   327         return URL_PREFIX + '/text/{key}/comments_frame/?prefix=/api'
   327         return URL_PREFIX + '/text/{key}/comments_frame/?prefix=/api'
   328     
   328 
       
   329     @has_perm_on_text_api('can_view_text')    
   329     def read(self, request, key):
   330     def read(self, request, key):
   330         return text_view_frame(request, key=key)
   331         return text_view_frame(request, key=key)
   331 
   332 
   332 class CommentFrameHandler(BaseHandler):    
   333 class CommentFrameHandler(BaseHandler):    
   333     type = "Embed methods"
   334     type = "Embed methods"
   334     anonymous = AnonymousCommentFrameHandler
   335     anonymous = AnonymousCommentFrameHandler
   335     allowed_methods = ('GET',)  
   336     allowed_methods = ('GET',)  
   336     no_display = True 
   337     no_display = True 
   337 
   338 
       
   339     @has_perm_on_text_api('can_view_text')
   338     def read(self, request, key):
   340     def read(self, request, key):
   339         return text_view_frame(request, key=key)
   341         return text_view_frame(request, key=key)
   340 
   342 
   341 class AnonymousCommentHandler(AnonymousBaseHandler):
   343 class AnonymousCommentHandler(AnonymousBaseHandler):
   342     allowed_methods = ('GET',)    
   344     allowed_methods = ('GET',)    
   348     
   350     
   349     @staticmethod
   351     @staticmethod
   350     def endpoint():
   352     def endpoint():
   351         return URL_PREFIX + '/text/{key}/comments/{version_key}/?'
   353         return URL_PREFIX + '/text/{key}/comments/{version_key}/?'
   352     
   354     
       
   355     @has_perm_on_text_api('can_view_text')    
   353     def read(self, request, key, version_key):
   356     def read(self, request, key, version_key):
   354         return text_view_comments(request, key=key, version_key=version_key)
   357         return text_view_comments(request, key=key, version_key=version_key)
   355 
   358 
   356 class CommentHandler(BaseHandler):    
   359 class CommentHandler(BaseHandler):    
   357     type = "Embed methods"
   360     type = "Embed methods"
   358     anonymous = AnonymousCommentHandler
   361     anonymous = AnonymousCommentHandler
   359     allowed_methods = ('GET',)  
   362     allowed_methods = ('GET',)  
   360     no_display = True 
   363     no_display = True 
   361 
   364 
       
   365     @has_perm_on_text_api('can_view_text')
   362     def read(self, request, key, version_key):
   366     def read(self, request, key, version_key):
   363         return text_view_comments(request, key=key, version_key=version_key)
   367         return text_view_comments(request, key=key, version_key=version_key)
   364 
   368 
   365 
   369 
   366 class AnonymousTextExportHandler(AnonymousBaseHandler):
   370 class AnonymousTextExportHandler(AnonymousBaseHandler):
   373     
   377     
   374     @staticmethod
   378     @staticmethod
   375     def endpoint():
   379     def endpoint():
   376         return URL_PREFIX + ' undocumented'
   380         return URL_PREFIX + ' undocumented'
   377     
   381     
       
   382     @has_perm_on_text_api('can_view_text')    
   378     def create(self, request, key, format, download, whichcomments, withcolor):
   383     def create(self, request, key, format, download, whichcomments, withcolor):
   379         return text_export(request, key, format, download, whichcomments, withcolor, adminkey=None)
   384         return text_export(request, key, format, download, whichcomments, withcolor, adminkey=None)
   380 
   385 
   381 class TextExportHandler(BaseHandler):    
   386 class TextExportHandler(BaseHandler):    
   382     type = "Embed methods"
   387     type = "Embed methods"
   383     anonymous = AnonymousTextExportHandler
   388     anonymous = AnonymousTextExportHandler
   384     allowed_methods = ('POST',)  
   389     allowed_methods = ('POST',)  
   385     no_display = True 
   390     no_display = True 
   386 
   391 
       
   392     @has_perm_on_text_api('can_view_text')
   387     def create(self, request, key, format, download, whichcomments, withcolor):
   393     def create(self, request, key, format, download, whichcomments, withcolor):
   388         return text_export(request, key, format, download, whichcomments, withcolor, adminkey=None)
   394         return text_export(request, key, format, download, whichcomments, withcolor, adminkey=None)
   389 
   395 
   390 class AnonymousCommentsHandler(AnonymousBaseHandler):
   396 class AnonymousCommentsHandler(AnonymousBaseHandler):
   391     allowed_methods = ('GET',)    
   397     allowed_methods = ('GET',)