예제 #1
0
파일: __init__.py 프로젝트: zdqf/ggrc-core
def is_document_exists():
    """Check if documents with gdrive_ids are exists"""
    DocumentEndpoint.validate_doc_request(request.json)
    ids = request.json["gdrive_ids"]
    result_set = db.session.query(all_models.Document.id,
                                  all_models.Document.gdrive_id).filter(
                                      all_models.Document.gdrive_id.in_(ids))
    response = DocumentEndpoint.build_doc_exists_response(
        request.json, result_set)
    return Response(json.dumps(response), mimetype='application/json')
예제 #2
0
def is_document_exists():
  """Check if documents with gdrive_ids are exists"""
  DocumentEndpoint.validate_doc_request(request.json)
  ids = request.json["gdrive_ids"]
  result_set = db.session.query(all_models.Document.id,
                                all_models.Document.gdrive_id).filter(
      all_models.Document.gdrive_id.in_(ids))
  response = DocumentEndpoint.build_doc_exists_response(request.json,
                                                        result_set)
  return Response(json.dumps(response), mimetype='application/json')
예제 #3
0
def make_document_admin():
    """Add current user as document admin"""
    DocumentEndpoint.validate_doc_request(request.json)
    ids = request.json["gdrive_ids"]
    docs = all_models.Document.query.filter(
        all_models.Document.gdrive_id.in_(ids))
    for doc in docs:
        doc.add_admin_role()
    db.session.commit()
    response = DocumentEndpoint.build_make_admin_response(request.json, docs)
    return Response(json.dumps(response), mimetype='application/json')
예제 #4
0
def make_document_admin():
  """Add current user as document admin"""
  DocumentEndpoint.validate_doc_request(request.json)
  ids = request.json["gdrive_ids"]
  docs = all_models.Document.query.filter(
      all_models.Document.gdrive_id.in_(ids))
  for doc in docs:
    doc.add_admin_role()
  db.session.commit()
  response = DocumentEndpoint.build_make_admin_response(request.json, docs)
  return Response(json.dumps(response), mimetype='application/json')