Esempio n. 1
0
def catalog_view(request, catalog_name=None, item_index=None):
    catalog_list = Catalog.list()
    if request.is_ajax():
        return HttpResponse(json.dumps(catalog_list),
                            mimetype='application/json')
    catalog = None
    catalog_item = None
    if not catalog_name:
        if 'production' in catalog_list:
            catalog_name = 'production'
        else:
            catalog_name = catalog_list[0]
    catalog = Catalog.detail(catalog_name)
    if item_index:
        catalog_item = Catalog.item_detail(catalog_name, item_index)
    return render_to_response(
        'catalogs/catalog.html', {
            'catalog_list': catalog_list,
            'catalog_name': catalog_name,
            'catalog': catalog,
            'item_index': item_index,
            'catalog_item': catalog_item,
            'user': request.user,
            'page': 'catalogs'
        })
Esempio n. 2
0
def item_detail(request, catalog_name, item_index):
    catalog_item = Catalog.item_detail(catalog_name, item_index)
    featured_keys = [
        'name', 'version', 'display_name', 'description', 'catalogs',
        'icon_name'
    ]

    # get icon
    if not "icon_name" in catalog_item:
        catalog_item["icon_name"] = ""

    # sort the item by key so keys are displayed
    # in expected order
    sorted_dict = SortedDict()
    for key in featured_keys:
        if key in catalog_item:
            sorted_dict[key] = catalog_item[key]
    key_list = catalog_item.keys()
    key_list.sort()
    for key in key_list:
        if key not in featured_keys:
            sorted_dict[key] = catalog_item[key]

    c = RequestContext(request, {'catalog_item': sorted_dict})
    c.update(csrf(request))
    return render_to_response('catalogs/item_detail.html', c)
Esempio n. 3
0
def catalog_view(request, catalog_name=None, item_index=None):
    catalog_list = Catalog.list()
    if request.is_ajax():
        return HttpResponse(json.dumps(catalog_list),
                            mimetype='application/json')
    catalog = None
    catalog_item = None
    if not catalog_name:
        if 'production' in catalog_list:
            catalog_name = 'production'
        else:
            catalog_name = catalog_list[0]
    catalog = Catalog.detail(catalog_name)
    if item_index:
        catalog_item = Catalog.item_detail(catalog_name, item_index)
    return render_to_response('catalogs/catalog.html',
                          {'catalog_list': catalog_list,
                           'catalog_name': catalog_name,
                           'catalog': catalog,
                           'item_index': item_index,
                           'catalog_item': catalog_item,
                           'user': request.user,
                           'page': 'catalogs'})
    #else:
    #    return render_to_response('catalogs/index.html',
    #                              {'catalog_list': catalog_list,
    #                               'user': request.user,
    #                               'page': 'catalogs'})
        
    
                              
Esempio n. 4
0
def catalog_view(request, catalog_name=None, item_index=None):
    view = request.COOKIES.get('view_catalogs')
    if not view:
        view = "grid"

    catalog_list = Catalog.list()
    if request.is_ajax():
        return HttpResponse(json.dumps(catalog_list),
                            mimetype='application/json')
    catalog = None
    catalog_item = None
    if not catalog_name:
        catalog_name = "all"

    catalog = Catalog.detail(catalog_name)

    catalog_items = list()
    for item in catalog:
        if 'display_name' not in item:
            item['display_name'] = item['name']
        if item.display_name not in catalog_items:
            catalog_items.append(item.display_name)
    catalog_items_json = json.dumps(catalog_items)

    if item_index:
        catalog_item = Catalog.item_detail(catalog_name, item_index)

    # get icon
    counter = 0
    for item in catalog:
        if "icon_name" in item:
            icon = Catalog.get_icon(item.icon_name)
        else:
            icon = Catalog.get_icon(item.name)
        catalog[counter].icon_name = icon
        counter += 1

    c = RequestContext(request,{'catalog_list': catalog_list,
                                'catalog_name': catalog_name,
                                'catalog': catalog,
                                'item_index': item_index,
                                'catalog_item': catalog_item,
                                'catalog_items': catalog_items_json,
                                'user': request.user,
                                'view': view,
                                'page': 'catalogs'})
    c.update(csrf(request))
    return render_to_response('catalogs/catalog.html', c)
Esempio n. 5
0
def item_detail(request, catalog_name, item_index):
    catalog_item = Catalog.item_detail(catalog_name, item_index)
    featured_keys = ['name', 'version', 'display_name', 
                     'description', 'catalogs']
    # sort the item by key so keys are displayed
    # in expected order
    sorted_dict = SortedDict()
    for key in featured_keys:
        if key in catalog_item:
            sorted_dict[key] = catalog_item[key]
    key_list = catalog_item.keys()
    key_list.sort()
    for key in key_list:
        if key not in featured_keys:
            sorted_dict[key] = catalog_item[key]
    return render_to_response('catalogs/item_detail.html', 
                              {'catalog_item': sorted_dict})
Esempio n. 6
0
def item_detail(request, catalog_name, item_index):
    catalog_item = Catalog.item_detail(catalog_name, item_index)
    featured_keys = [
        'name', 'version', 'display_name', 'description', 'catalogs'
    ]
    # sort the item by key so keys are displayed
    # in expected order
    sorted_dict = SortedDict()
    for key in featured_keys:
        if key in catalog_item:
            sorted_dict[key] = catalog_item[key]
    key_list = catalog_item.keys()
    key_list.sort()
    for key in key_list:
        if key not in featured_keys:
            sorted_dict[key] = catalog_item[key]
    return render_to_response('catalogs/item_detail.html',
                              {'catalog_item': sorted_dict})
Esempio n. 7
0
def item_detail(request, catalog_name, item_index):
    catalog_item = Catalog.item_detail(catalog_name, item_index)
    featured_keys = ['name', 'version', 'display_name',
                     'description', 'catalogs', 'icon_name',
                     'category', 'developer', 'installcheck_script',
                     'preinstall_script', 'postinstall_script',
                     'preuninstall_script', 'postuninstall_script',
                     'uninstalll_script']

    catalog_list = Catalog.list()[1:]
    editable =['version', 'display_name','category', 'developer',
                'catalogs', 'icon_name', 'installcheck_script',
                'preinstall_script', 'postinstall_script',
                'preuninstall_script', 'postuninstall_script',
                'uninstalll_script']


    for item in featured_keys:
        if not item in catalog_item:
            catalog_item[item] = ""

    # sort the item by key so keys are displayed
    # in expected order
    sorted_dict = SortedDict()
    for key in featured_keys:
        if key in catalog_item:
            sorted_dict[key] = catalog_item[key]
    key_list = catalog_item.keys()
    key_list.sort()
    for key in key_list:
        if key not in featured_keys:
            sorted_dict[key] = catalog_item[key]

    c = RequestContext(request,{'catalog_item': sorted_dict,
                                'editable': editable,
                                'catalogs': catalog_list})
    c.update(csrf(request))
    return render_to_response('catalogs/item_detail.html', c)
Esempio n. 8
0
def item_detail(request, catalog_name, item_index):
    catalog_item = Catalog.item_detail(catalog_name, item_index)
    featured_keys = ['name', 'version', 'display_name', 
                     'description', 'catalogs', 'icon_name']
    
    # get icon
    if not "icon_name" in catalog_item:
        catalog_item["icon_name"] = ""

    # sort the item by key so keys are displayed
    # in expected order
    sorted_dict = SortedDict()
    for key in featured_keys:
        if key in catalog_item:
            sorted_dict[key] = catalog_item[key]
    key_list = catalog_item.keys()
    key_list.sort()
    for key in key_list:
        if key not in featured_keys:
            sorted_dict[key] = catalog_item[key]

    c = RequestContext(request,{'catalog_item': sorted_dict})
    c.update(csrf(request))
    return render_to_response('catalogs/item_detail.html', c)
Esempio n. 9
0
def item_detail(request, catalog_name, item_index):
    catalog_item = Catalog.item_detail(catalog_name, item_index)
    return render_to_response('catalogs/item_detail.html',
                              {'catalog_item': catalog_item})
Esempio n. 10
0
def item_detail(request, catalog_name, item_index):
    catalog_item = Catalog.item_detail(catalog_name, item_index)
    return render_to_response('catalogs/item_detail.html', 
                              {'catalog_item': catalog_item})