Beispiel #1
0
 def test_add_user(self):
     """Test for add user function."""
     number_of_users_before = len(get_all_users())
     guid = add_user(**self.user_to_add)
     self.assertIsNotNone(guid)
     number_of_users_after = len(get_all_users())
     self.assertEqual(number_of_users_before + 1, number_of_users_after)
 def test_add_user(self):
     """Test for add user function."""
     number_of_users_before = len(get_all_users())
     guid = add_user(**self.user_to_add)
     self.assertIsNotNone(guid)
     number_of_users_after = len(get_all_users())
     self.assertEqual(number_of_users_before + 1, number_of_users_after)
Beispiel #3
0
def download_view():
    """View to download users.

    Handle post request via ajax and return file to browser

    :returns: A csv file containing all users
    :rtype: HttpResponse
    """
    csv_users = "ID|NAME|WEBSITE|ROLE|LONGITUDE|LATITUDE"
    all_user_role = (0, 1, 2)
    i = 0
    for user_role in all_user_role:
        users = get_all_users(user_role)
        for user in users:
            i += 1
            csv_users += '\n%i|%s|%s|%s|%s|%s' % (
                i,
                user['name'],
                user['website'],
                get_role_name(user['role']),
                user['longitude'],
                user['latitude'])

    filename = '%s-users.csv' % APP.config['PROJECT_NAME']
    content = "attachment;filename='%s'" % filename
    return Response(
        csv_users,
        mimetype='text/csv',
        headers={'Content-Disposition': content})
Beispiel #4
0
def users_view():
    """Return a json document of users with given role who have registered."""
    # Get data:
    user_role = int(request.form['user_role'])

    # Create model user
    all_users = get_all_users(role=user_role)
    #noinspection PyUnresolvedReferences
    json_users = render_template('json/users.json', users=all_users)

    users_json = ('{' ' "users": %s' '}' % json_users)
    # Return Response
    return Response(users_json, mimetype='application/json')
Beispiel #5
0
def users_view():
    """Return a json document of users with given role who have registered."""
    # Get data:
    user_role = int(request.form['user_role'])

    # Create model user
    all_users = get_all_users(role=user_role)
    #noinspection PyUnresolvedReferences
    json_users = render_template('json/users.json', users=all_users)

    users_json = (
        '{'
        ' "users": %s'
        '}' % json_users
    )
    # Return Response
    return Response(users_json, mimetype='application/json')
Beispiel #6
0
def download_view():
    """View to download users.

    Handle post request via ajax and return file to browser

    :returns: A csv file containing all users
    :rtype: HttpResponse
    """
    csv_users = "ID|NAME|WEBSITE|ROLE|LONGITUDE|LATITUDE"
    all_user_role = (0, 1, 2)
    i = 0
    for user_role in all_user_role:
        users = get_all_users(user_role)
        for user in users:
            i += 1
            csv_users += '\n%i|%s|%s|%s|%s|%s' % (
                i, user['name'], user['website'], get_role_name(
                    user['role']), user['longitude'], user['latitude'])

    filename = '%s-users.csv' % APP.config['PROJECT_NAME']
    content = "attachment;filename='%s'" % filename
    return Response(csv_users,
                    mimetype='text/csv',
                    headers={'Content-Disposition': content})
Beispiel #7
0
def get_all_users():
    return Config.create_response(response=user.get_all_users())
Beispiel #8
0
 def test_get_all_users(self):
     """Test for retrieving all user function."""
     users = get_all_users()
     # Test if all the attribute exist
     for user in users:
         self.assertEqual(len(user), 10)
 def test_get_all_users(self):
     """Test for retrieving all user function."""
     users = get_all_users()
     # Test if all the attribute exist
     for user in users:
         self.assertEqual(len(user), 10)