Example #1
0
def deletePerson(person_id):
    try:
        PeopleManager.deletePerson(person_id)
        return makeResponse(message="Deleted person", payload={})
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Example #2
0
def deletePerson(person_id):
    try:
        PeopleManager.deletePerson(person_id)
        return makeResponse(message="Deleted person", payload={})
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Example #3
0
def editPerson():
    surname = request.form.get('surname')
    forename = request.form.get('forename')
    location = request.form.get('location')
    email = request.form.get('email')
    url = request.form.get('url')
    tagline = request.form.get('tagline')
    is_disabled = request.form.get('is_disabled')
    nyunetid = request.form.get('nyunetid')


    # Get person by auth token 
    current_token = get_raw_jwt()
    jti = current_token['jti']

    # email address
    if request.form.get('person_id') is None:
        identity = current_token['identity']
    else:
        identity = request.form.get('person_id')

    try:
        return makeResponse(payload=PeopleManager.editPerson(identity, forename, surname, location, email, url, tagline, is_disabled, nyunetid), message="")
    except FindError as e:
        return makeResponse(error=e)
    except ValidationError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
    except SaveError as e:
        return makeResponse(error=e)
    except Exception as e:
        return makeResponse(error=e)
Example #4
0
def editPerson():
    surname = request.form.get('surname')
    forename = request.form.get('forename')
    location = request.form.get('location')
    email = request.form.get('email')
    url = request.form.get('url')
    tagline = request.form.get('tagline')
    is_disabled = request.form.get('is_disabled')
    nyunetid = request.form.get('nyunetid')

    # Get person by auth token
    current_token = get_raw_jwt()
    jti = current_token['jti']

    # email address
    if request.form.get('person_id') is None:
        identity = current_token['identity']
    else:
        identity = request.form.get('person_id')

    try:
        return makeResponse(payload=PeopleManager.editPerson(
            identity, forename, surname, location, email, url, tagline,
            is_disabled, nyunetid),
                            message="")
    except FindError as e:
        return makeResponse(error=e)
    except ValidationError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
    except SaveError as e:
        return makeResponse(error=e)
    except Exception as e:
        return makeResponse(error=e)
Example #5
0
def deleteType(repo_id, type_id):
    current_user = get_jwt_identity()
    if PeopleManager.checkRepoPermissions(current_user, repo_id) == False:
        return makeResponse(status=401, message="You do not have permissions to access this repository!")
    try:
        return makeResponse(payload=SchemaManager.deleteType(repo_id, type_id), message="Deleted type")
    except Exception as e:
        return makeResponse(error=e)
Example #6
0
def getType(repo_id, schema_id):
    current_user = get_jwt_identity()
    if PeopleManager.checkRepoPermissions(current_user, repo_id) == False:
        return makeResponse(
            status=401,
            message="You do not have permissions to access this repository!")
    try:
        return makeResponse(payload=SchemaManager.getType(repo_id, schema_id))
    except Exception as e:
        return makeResponse(error=e)
Example #7
0
def getPersonRepos():
    identity = request.form.get('person_id')
    if identity is None:
        current_token = get_raw_jwt()
        identity = current_token['identity']

    try:
        return makeResponse(payload=PeopleManager.getReposForPerson(identity))
    except FindError as e:
        return makeResponse(error=e)
Example #8
0
def getPersonRepos():
    identity = request.form.get('person_id')
    if identity is None:
        current_token = get_raw_jwt()
        identity = current_token['identity']

    try:
        return makeResponse(payload=PeopleManager.getReposForPerson(identity))
    except FindError as e:
        return makeResponse(error=e)
Example #9
0
def addType(repo_id):
    name = request.form.get('name')
    code = request.form.get('code')
    description = request.form.get('description')
    current_user = get_jwt_identity()
    if PeopleManager.checkRepoPermissions(current_user, repo_id) == False:
        return makeResponse(status=401, message="You do not have permissions to access this repository!")
    try:
        return makeResponse(message="Added type", payload=SchemaManager.addType(repo_id, name, code, description, extractRepeatingParameterBlocksFromRequest(request, 'fields')))
    except Exception as e:
        return makeResponse(error=e)
Example #10
0
def addField(repo_id, typecode):
    name = request.form.get('name')
    code = request.form.get('code')
    fieldtype = request.form.get('type')
    description = request.form.get('description')
    current_user = get_jwt_identity()
    if PeopleManager.checkRepoPermissions(current_user, repo_id) == False:
        return makeResponse(status=401, message="You do not have permissions to access this repository!")
    try:
        return makeResponse(payload=SchemaManager.addField(repo_id, typecode, name, code, fieldtype, description), message="Added field")
    except Exception as e:
        return makeResponse(error=e)
Example #11
0
def addData(repo_id, typecode):
    data = request.form.get('data')
    current_user = get_jwt_identity()
    if PeopleManager.checkRepoPermissions(current_user, repo_id) == False:
        return makeResponse(status=401, message="You do not have permissions to access this repository!")
    try:
        if SchemaManager.addDataToRepo(repo_id, typecode, json.loads(data)):
            return makeResponse(payload={"msg": "Added data to repository"})
        else:
            return makeResponse(payload={"msg": "No data to add"})
    except Exception as e:
        return makeResponse(error=e)
Example #12
0
def getPerson():
    if request.method == 'GET':
      # Get person by auth token 
      current_token = get_raw_jwt()
      jti = current_token['jti']

      # email address
      identity = current_token['identity']

    if request.method == 'POST':
      identity = int(request.form.get('person_id'))

    person = PeopleManager.getInfo(identity)

    ret = {}
    if person is not None:
      ret['person'] = person

    # If request method is GET, then it's our logged in user, get Repos and repo data too!
    if request.method == 'GET':
      ret['repos'] = PeopleManager.getRepos(identity)

    return makeResponse(payload=ret)
Example #13
0
def getPerson():
    if request.method == 'GET':
        # Get person by auth token
        current_token = get_raw_jwt()
        jti = current_token['jti']

        # email address
        identity = current_token['identity']

    if request.method == 'POST':
        identity = int(request.form.get('person_id'))

    person = PeopleManager.getInfo(identity)

    ret = {}
    if person is not None:
        ret['person'] = person

    # If request method is GET, then it's our logged in user, get Repos and repo data too!
    if request.method == 'GET':
        ret['repos'] = PeopleManager.getRepos(identity)

    return makeResponse(payload=ret)
Example #14
0
def addData(repo_id, typecode):
    data = request.form.get('data')
    current_user = get_jwt_identity()
    if PeopleManager.checkRepoPermissions(current_user, repo_id) == False:
        return makeResponse(
            status=401,
            message="You do not have permissions to access this repository!")
    try:
        if SchemaManager.addDataToRepo(repo_id, typecode, json.loads(data)):
            return makeResponse(payload={"msg": "Added data to repository"})
        else:
            return makeResponse(payload={"msg": "No data to add"})
    except Exception as e:
        return makeResponse(error=e)
Example #15
0
def findPerson():
    q = request.form.get('q')

    msg = 'No people found'
    ret = {'q': q, 'results': []}

    if q is not None and len(q) > 0:
        people = PeopleManager.find({'surname': q, 'email': q})

        if people is not None:
            msg = 'Success'
            ret['results'] = people

    return makeResponse(payload=ret, message=msg)
Example #16
0
def findPerson():
    q = request.form.get('q')

    msg = 'No people found'
    ret = {'q': q, 'results': []}

    if q is not None and len(q) > 0:
        people = PeopleManager.find({'surname': q, 'email': q})

        if people is not None:
            msg = 'Success'
            ret['results'] = people

    return makeResponse(payload=ret, message=msg)
Example #17
0
def addField(repo_id, typecode):
    name = request.form.get('name')
    code = request.form.get('code')
    fieldtype = request.form.get('type')
    description = request.form.get('description')
    current_user = get_jwt_identity()
    if PeopleManager.checkRepoPermissions(current_user, repo_id) == False:
        return makeResponse(
            status=401,
            message="You do not have permissions to access this repository!")
    try:
        return makeResponse(payload=SchemaManager.addField(
            repo_id, typecode, name, code, fieldtype, description),
                            message="Added field")
    except Exception as e:
        return makeResponse(error=e)
Example #18
0
def addType(repo_id):
    name = request.form.get('name')
    code = request.form.get('code')
    description = request.form.get('description')
    current_user = get_jwt_identity()
    if PeopleManager.checkRepoPermissions(current_user, repo_id) == False:
        return makeResponse(
            status=401,
            message="You do not have permissions to access this repository!")
    try:
        return makeResponse(message="Added type",
                            payload=SchemaManager.addType(
                                repo_id, name, code, description,
                                extractRepeatingParameterBlocksFromRequest(
                                    request, 'fields')))
    except Exception as e:
        return makeResponse(error=e)
Example #19
0
def addPerson():
    surname = request.form.get('surname')
    forename = request.form.get('forename')
    location = request.form.get('location')
    email = request.form.get('email')
    url = request.form.get('url')
    tagline = request.form.get('tagline')
    password = request.form.get('password')
    nyunetid = request.form.get('nyunetid')

    try:
        ret = PeopleManager.addPerson(forename, surname, location, email, nyunetid, url, tagline, password)
        return makeResponse(payload=ret, message="Added person")
    except DbError as e:
        return makeResponse(error=e)
    except SaveError as e:
        return makeResponse(error=e)
    except FindError as e:
        return makeResponse(error=e)
    except ValidationError as e:
        return makeResponse(error=e)
Example #20
0
def register():
    surname = request.form.get('surname')
    forename = request.form.get('forename')
    location = request.form.get('location')
    email = request.form.get('email')
    url = request.form.get('url')
    tagline = request.form.get('tagline')
    password = request.form.get('password')
    nyunetid = request.form.get('nyunetid')

    try:
        ret = PeopleManager.addPerson(forename, surname, location, email, nyunetid, url, tagline, password)
        return makeResponse(payload=ret, message="Added person")
    except DbError as e:
        return makeResponse(error=e)
    except SaveError as e:
        return makeResponse(error=e)
    except FindError as e:
        return makeResponse(error=e)
    except ValidationError as e:
        return makeResponse(error=e)
Example #21
0
def boot():
    current_user = get_jwt_identity()
    repo_id = request.form.get('repo_id')

    try:
        repo_id = int(repo_id)
    except:
        repo_id = None

    payload = {'repos': PeopleManager.getReposForPerson(current_user)}

    try:
        # Try to get first repo_id
        if repo_id is None or repo_id == 0:
            repo_id = payload['repos']['repos'][0]['id']

        payload['schema'] = {'types': SchemaManager.getTypes(repo_id)}
    except:
        pass

    try:
        return makeResponse(payload=payload)
    except Exception as e:
        return makeResponse(error=e)
Example #22
0
def peopleList():
    return makeResponse(payload={"people": PeopleManager.getAll()})
Example #23
0
def peopleList():
    return makeResponse(payload={"people": PeopleManager.getAll()})