Ejemplo n.º 1
0
def services_s3(request):
    try:
        s3 = models.S3.objects.all()[0]
    except:
        s3 = models.S3()

    if request.method == "POST":
        form = S3Form(request.POST, instance=s3)
        if form.is_valid():
            form.save()
            return JsonResp(request, message=_("S3 successfully edited."))
        else:
            return JsonResp(request, form=form)

    else:
        form = S3Form(instance=s3)

    s3_ui_url = "http://%s:%s" % (s3.s3_bindip, s3.s3_bindport)
    if s3.s3_bindip == "0.0.0.0":
        s3_ui_url = "http://%s:%s" % (request.META['HTTP_HOST'].split(':')[0],
                                      s3.s3_bindport)

    s3_started = notifier().started("s3") and s3.s3_browser

    return render(request, 'services/s3.html', {
        'form': form,
        's3': s3,
        's3_ui_url': s3_ui_url,
        's3_started': s3_started
    })
Ejemplo n.º 2
0
def services_s3(request):
    try:
        s3 = models.S3.objects.all()[0]
    except:
        s3 = models.S3()

    if request.method == "POST":
        form = S3Form(request.POST, instance=s3)
        if form.is_valid():
            form.save()
        else:
            return JsonResp(request, form=form)

    else:
        form = S3Form(instance=s3)

    return render(request, 'services/s3.html', {
        'form': form,
    })