def get(self, request, id_rule): """RulesDetailHandler READ method for GET requests @param request: is a django request object @param id_rule: is an id (PK) of a document type rule we are trying to return """ operator = PluginsOperator() try: mapping = operator.get_plugin_mapping_by_docrule_id(id_rule) except DmsException: log.error('RulesDetailHandler.read DmsException: Rule not found. 404') if settings.DEBUG: raise else: return Response(status=status.HTTP_400_BAD_REQUEST) # Removing mapping key that is not json serializable. resp_data = dict( active=mapping.active, doccode_id=mapping.doccode_id, id=mapping.id, doccode=mapping.doccode.title, before_retrieval_plugins=[plugin.name for plugin in mapping.before_retrieval_plugins.all()], storage_plugins=[plugin.name for plugin in mapping.storage_plugins.all()], database_storage_plugins=[plugin.name for plugin in mapping.database_storage_plugins.all()], before_removal_plugins=[plugin.name for plugin in mapping.before_removal_plugins.all()], before_storage_plugins=[plugin.name for plugin in mapping.before_storage_plugins.all()], ) log.info('RulesDetailHandler.read request fulfilled for rule %s' % id_rule) return Response(json.dumps(resp_data), status=status.HTTP_200_OK)
def read(self, request, id_rule): """RulesDetailHandler READ method for GET requests @param request: is a django request object @param id_rule: is an id (PK) of a document type rule we are trying to return """ operator = PluginsOperator() try: mapping = operator.get_plugin_mapping_by_docrule_id(id_rule) except Exception, e: # FIXME log.error('RulesDetailHandler.read Exception %s' % e) if settings.DEBUG: raise else: return rc.BAD_REQUEST
def read(self, request, id_rule): # FIXME: Requirement for this whole API hook is wrong. # Tags should be got with document metadata. Not with a separate reequest. try: operator = PluginsOperator() mapping = operator.get_plugin_mapping_by_docrule_id(id_rule) docrule = mapping.get_docrule() tags = TagsPlugin().get_all_tags(docrule=docrule) log.info('TagsHandler.read request fulfilled for rule %s' % id_rule) return map(lambda x: x.name, tags) except Exception, e: # FIXME log.error('TagsHandler.read Exception %s' % e) if settings.DEBUG: raise else: return rc.BAD_REQUEST
def get(self, request, id_rule): # FIXME: Requirement for this whole API hook is wrong. # Tags should be got with document metadata. Not with a separate reequest. try: operator = PluginsOperator() mapping = operator.get_plugin_mapping_by_docrule_id(id_rule) docrule = mapping.get_docrule() tags = TagsPlugin().get_all_tags(docrule=docrule) log.info('TagsHandler.read request fulfilled for rule %s' % id_rule) return Response(json.dumps(tags), status=status.HTTP_200_OK) except Exception, e: # FIXME log.error('TagsHandler.read Exception %s' % e) if settings.DEBUG: raise else: return Response(status=status.HTTP_400_BAD_REQUEST)
def get(self, request, id_rule): # FIXME: Requirement for this whole API hook is wrong. # Tags should be got with document metadata. Not with a separate reequest. try: operator = PluginsOperator() mapping = operator.get_plugin_mapping_by_docrule_id(id_rule) docrule = mapping.get_docrule() tags = TagsPlugin().get_all_tags(docrule=docrule) log.info('TagsHandler.read request fulfilled for rule %s' % id_rule) return Response(json.dumps(tags), status=status.HTTP_200_OK) except Exception, e: # FIXME log.error('TagsHandler.read Exception %s' % e) if settings.DEBUG: raise else: return Response(status=status.HTTP_400_BAD_REQUEST)
def get(self, request, id_rule): operator = PluginsOperator() try: mapping = operator.get_plugin_mapping_by_docrule_id(id_rule) except DmsException: return Response(status=status.HTTP_404_NOT_FOUND) start = int(request.GET.get('start', 0)) finish = request.GET.get('finish', None) order = request.GET.get('order', None) searchword = request.GET.get('q', None) tag = request.GET.get('tag', None) filter_date = request.GET.get('created_date', None) if finish: finish = int(finish) file_list = operator.get_file_list(mapping, start, finish, order, searchword, tags=[tag], filter_date=filter_date) for item in file_list: document_name = item['name'] code, suggested_format = os.path.splitext(document_name) if not suggested_format: api_url = reverse('api_file', kwargs={ 'code': code, }) else: suggested_format = suggested_format[ 1:] # Remove . from file ext api_url = reverse('api_file', kwargs={ 'code': code, 'suggested_format': suggested_format, }) thumb_url = reverse('api_thumbnail', kwargs={'code': item['name']}) item.update({ 'ui_url': api_url, 'thumb_url': thumb_url, 'rule': mapping.get_name(), }) log.info("""FileListHandler.read request fulfilled for: start %s, finish %s, order %s, searchword %s, tag %s, filter_date %s.""" % (start, finish, order, searchword, tag, filter_date)) return Response(file_list, status=status.HTTP_200_OK)
def get(self, request, id_rule): """RulesDetailHandler READ method for GET requests @param request: is a django request object @param id_rule: is an id (PK) of a document type rule we are trying to return """ operator = PluginsOperator() try: mapping = operator.get_plugin_mapping_by_docrule_id(id_rule) except DmsException: log.error( 'RulesDetailHandler.read DmsException: Rule not found. 404') if settings.DEBUG: raise else: return Response(status=status.HTTP_400_BAD_REQUEST) # Removing mapping key that is not json serializable. resp_data = dict( active=mapping.active, doccode_id=mapping.doccode_id, id=mapping.id, doccode=mapping.doccode.title, before_retrieval_plugins=[ plugin.name for plugin in mapping.before_retrieval_plugins.all() ], storage_plugins=[ plugin.name for plugin in mapping.storage_plugins.all() ], database_storage_plugins=[ plugin.name for plugin in mapping.database_storage_plugins.all() ], before_removal_plugins=[ plugin.name for plugin in mapping.before_removal_plugins.all() ], before_storage_plugins=[ plugin.name for plugin in mapping.before_storage_plugins.all() ], ) log.info('RulesDetailHandler.read request fulfilled for rule %s' % id_rule) return Response(json.dumps(resp_data), status=status.HTTP_200_OK)
def get(self, request, id_rule): operator = PluginsOperator() try: mapping = operator.get_plugin_mapping_by_docrule_id(id_rule) except DmsException: return Response(status=status.HTTP_404_NOT_FOUND) start = int(request.GET.get('start', 0)) finish = request.GET.get('finish', None) order = request.GET.get('order', None) searchword = request.GET.get('q', None) tag = request.GET.get('tag', None) filter_date = request.GET.get('created_date', None) if finish: finish = int(finish) file_list = operator.get_file_list( mapping, start, finish, order, searchword, tags=[tag], filter_date=filter_date ) for item in file_list: document_name = item['name'] code, suggested_format = os.path.splitext(document_name) if not suggested_format: api_url = reverse('api_file', kwargs={'code': code, }) else: suggested_format = suggested_format[1:] # Remove . from file ext api_url = reverse('api_file', kwargs={'code': code, 'suggested_format': suggested_format, }) thumb_url = reverse('api_thumbnail', kwargs={'code': item['name']}) item.update({ 'ui_url': api_url, 'thumb_url': thumb_url, 'rule': mapping.get_name(), }) log.info( """FileListHandler.read request fulfilled for: start %s, finish %s, order %s, searchword %s, tag %s, filter_date %s.""" % (start, finish, order, searchword, tag, filter_date) ) return Response(file_list, status=status.HTTP_200_OK)
def read(self, request, id_rule): try: operator = PluginsOperator() mapping = operator.get_plugin_mapping_by_docrule_id(id_rule) start = int(request.GET.get('start', 0)) finish = request.GET.get('finish', None) order = request.GET.get('order', None) searchword = request.GET.get('q', None) tag = request.GET.get('tag', None) filter_date = request.GET.get('created_date', None) if finish: finish = int(finish) file_list = operator.get_file_list( mapping, start, finish, order, searchword, tags=[tag], filter_date=filter_date ) for item in file_list: ui_url = reverse('ui_document', kwargs={'document_name': item['name']}) thumb_url = reverse('api_thumbnail', kwargs={'code': item['name']}) item.update({ 'ui_url': ui_url, 'thumb_url': thumb_url, 'rule': mapping.get_name(), }) log.info( """FileListHandler.read request fulfilled for: start %s, finish %s, order %s, searchword %s, tag %s, filter_date %s.""" % (start, finish, order, searchword, tag, filter_date) ) return file_list except Exception, e: log.error('FileListHandler.read Exception %s' % e) if settings.DEBUG: print e raise else: return rc.BAD_REQUEST