コード例 #1
0
ファイル: views.py プロジェクト: lonnen/socorro
def update_featured_versions(request):
    api = ProductVersions()
    products = set(
        x['product'] for x in api.get()['hits']
    )

    data = {}
    for product in request.POST:
        if product in products:
            data[product] = request.POST.getlist(product)

    featured_api = ReleasesFeatured()
    success = featured_api.put(**data)
    if success:
        messages.success(
            request,
            'Featured versions successfully updated. '
            'Cache might take some time to update.'
        )

    log(request.user, 'featured_versions.update', {
        'data': data,
        'success': success
    })

    url = reverse('manage:featured_versions')
    return redirect(url)
コード例 #2
0
ファイル: views.py プロジェクト: g-k/socorro
def products(request):
    context = {}
    api = ProductVersions()
    if request.method == 'POST':
        existing_products = set(x['product'] for x in api.get()['hits'])
        form = forms.ProductForm(request.POST,
                                 existing_products=existing_products)
        if form.is_valid():
            api.post(product=form.cleaned_data['product'],
                     version=form.cleaned_data['initial_version'])
            log(request.user, 'product.add', form.cleaned_data)
            messages.success(
                request, 'Product %s (%s) added.' %
                (form.cleaned_data['product'],
                 form.cleaned_data['initial_version']))
            return redirect('manage:products')
    else:
        product = request.GET.get('product')
        if product is not None:
            messages.error(
                request,
                'Product %s not found. Submit the form below to add it.' %
                (product))
        form = forms.ProductForm(initial={
            'product': product,
            'initial_version': '1.0'
        })
    context['form'] = form
    context['page_title'] = "Products"
    return render(request, 'manage/products.html', context)
コード例 #3
0
ファイル: views.py プロジェクト: lonnen/socorro
def featured_versions(request, default_context=None):
    context = default_context or {}

    api = ProductVersions()
    api.cache_seconds = 0
    product_versions = api.get(active=True)['hits']

    releases = collections.OrderedDict()
    for pv in product_versions:
        if pv['product'] not in releases:
            releases[pv['product']] = []
        releases[pv['product']].append(pv)
    context['releases'] = releases
    return render(request, 'manage/featured_versions.html', context)
コード例 #4
0
ファイル: views.py プロジェクト: g-k/socorro
def featured_versions(request, default_context=None):
    context = default_context or {}

    api = ProductVersions()
    api.cache_seconds = 0
    product_versions = api.get(active=True)['hits']

    releases = collections.OrderedDict()
    for pv in product_versions:
        if pv['product'] not in releases:
            releases[pv['product']] = []
        releases[pv['product']].append(pv)
    context['releases'] = releases
    return render(request, 'manage/featured_versions.html', context)
コード例 #5
0
ファイル: views.py プロジェクト: lonnen/socorro
def products(request):
    context = {}
    api = ProductVersions()
    if request.method == 'POST':
        existing_products = set(
            x['product'] for x in api.get()['hits']
        )
        form = forms.ProductForm(
            request.POST,
            existing_products=existing_products
        )
        if form.is_valid():
            api.post(
                product=form.cleaned_data['product'],
                version=form.cleaned_data['initial_version']
            )
            log(request.user, 'product.add', form.cleaned_data)
            messages.success(
                request,
                'Product %s (%s) added.' % (
                    form.cleaned_data['product'],
                    form.cleaned_data['initial_version']
                )
            )
            return redirect('manage:products')
    else:
        product = request.GET.get('product')
        if product is not None:
            messages.error(
                request,
                'Product %s not found. Submit the form below to add it.' % (
                    product
                )
            )
        form = forms.ProductForm(initial={
            'product': product,
            'initial_version': '1.0'
        })
    context['form'] = form
    context['page_title'] = "Products"
    return render(request, 'manage/products.html', context)
コード例 #6
0
ファイル: views.py プロジェクト: g-k/socorro
def update_featured_versions(request):
    api = ProductVersions()
    products = set(x['product'] for x in api.get()['hits'])

    data = {}
    for product in request.POST:
        if product in products:
            data[product] = request.POST.getlist(product)

    featured_api = ReleasesFeatured()
    success = featured_api.put(**data)
    if success:
        messages.success(
            request, 'Featured versions successfully updated. '
            'Cache might take some time to update.')

    log(request.user, 'featured_versions.update', {
        'data': data,
        'success': success
    })

    url = reverse('manage:featured_versions')
    return redirect(url)