Ejemplo n.º 1
0
def img_ajax_get_group_table(request):
    """
    Ajax view for fetching group images list.
    """
    if request.method == "GET":
        rest_data = prep_data(
            {
                "own_groups": "user/group/list_own_groups/",
                "group_images": ("user/system_image/get_list/", {"access": image_access["group"]}),
            },
            request.session,
        )

        leader = parsing.parse_own_groups(rest_data)

        group_list = []
        for group in rest_data["group_images"]:

            group_images_list = []
            for item in group["images"]:
                item["stateName"] = unicode(image_states_reversed[item["state"]])
                item["size"] = filesizeformatmb(item["size"])
                item["mine"] = True if item["user_id"] == request.session["user"].user_id else False
                item["myGroup"] = True if item["group_id"] in leader else False
                group_images_list.append(item)

            group_list.append({"name": group["name"], "items": group_images_list, "group_id": group["group_id"]})
        return messages_ajax.success(group_list)
Ejemplo n.º 2
0
def img_ajax_get_group_table(request):
    """
    Ajax view for fetching group images list.
    """
    if request.method == 'GET':
        rest_data = prep_data(
            {
                'own_groups':
                'user/group/list_own_groups/',
                'group_images': ('user/system_image/get_list/', {
                    'access': image_access['group']
                }),
            }, request.session)

        leader = parsing.parse_own_groups(rest_data)

        group_list = []
        for group in rest_data['group_images']:

            group_images_list = []
            for item in group['images']:
                item['stateName'] = unicode(
                    image_states_reversed[item['state']])
                item['size'] = filesizeformatmb(item['size'])
                item['mine'] = True if item['user_id'] == request.session[
                    'user'].user_id else False
                item['myGroup'] = True if item['group_id'] in leader else False
                group_images_list.append(item)

            group_list.append({
                'name': group['name'],
                'items': group_images_list,
                'group_id': group['group_id']
            })
        return messages_ajax.success(group_list)
Ejemplo n.º 3
0
def grp_ajax_get_table_my(request):
    """
    Ajax view for fetching user's group list.
    """
    if request.method == 'GET':
        rest_data = prep_data({'own_groups': 'user/group/list_own_groups/',
                               'my_groups': 'user/group/list_groups/'}, request.session)

        leader = parsing.parse_own_groups(rest_data)

        for item in rest_data['my_groups']:
            item['amILeader'] = True if item['group_id'] in leader else False

        return messages_ajax.success(rest_data['my_groups'])
Ejemplo n.º 4
0
def grp_ajax_get_table_my(request):
    """
    Ajax view for fetching user's group list.
    """
    if request.method == 'GET':
        rest_data = prep_data(
            {
                'own_groups': 'user/group/list_own_groups/',
                'my_groups': 'user/group/list_groups/'
            }, request.session)

        leader = parsing.parse_own_groups(rest_data)

        for item in rest_data['my_groups']:
            item['amILeader'] = True if item['group_id'] in leader else False

        return messages_ajax.success(rest_data['my_groups'])