Esempio n. 1
0
def sla_add(request, response_format='html'):
    "ServiceLevelAgreement add"

    if not request.user.get_profile().is_admin('treeio.services'):
        return user_denied(request,
                           message="You don't have administrator access to the Service Support module")

    if request.POST:
        if not 'cancel' in request.POST:
            sla = ServiceLevelAgreement()
            form = ServiceLevelAgreementForm(
                request.user.get_profile(), request.POST, instance=sla)
            if form.is_valid():
                sla = form.save()
                sla.set_user_from_request(request)
                return HttpResponseRedirect(reverse('services_sla_view', args=[sla.id]))
        else:
            return HttpResponseRedirect(reverse('services'))
    else:
        form = ServiceLevelAgreementForm(request.user.get_profile())

    context = _get_default_context(request)
    context.update({'form': form})

    return render_to_response('services/sla_add', context,
                              context_instance=RequestContext(request), response_format=response_format)
Esempio n. 2
0
def sla_edit(request, sla_id, response_format='html'):
    "ServiceLevelAgreement edit"

    sla = get_object_or_404(ServiceLevelAgreement, pk=sla_id)
    if not request.user.get_profile().has_permission(sla, mode='w'):
        return user_denied(request, message="You don't have access to this Service Level Agreement")

    if request.POST:
        if not 'cancel' in request.POST:
            form = ServiceLevelAgreementForm(
                request.user.get_profile(), request.POST, instance=sla)
            if form.is_valid():
                sla = form.save()
                return HttpResponseRedirect(reverse('services_sla_view', args=[sla.id]))
        else:
            return HttpResponseRedirect(reverse('services_sla_view', args=[sla.id]))
    else:
        form = ServiceLevelAgreementForm(
            request.user.get_profile(), instance=sla)

    context = _get_default_context(request)
    context.update({'sla': sla, 'form': form})

    return render_to_response('services/sla_edit', context,
                              context_instance=RequestContext(request), response_format=response_format)
Esempio n. 3
0
def sla_add(request, response_format='html'):
    "ServiceLevelAgreement add"

    if not request.user.get_profile().is_admin('treeio.services'):
        return user_denied(
            request,
            message=
            "You don't have administrator access to the Service Support module"
        )

    if request.POST:
        if not 'cancel' in request.POST:
            sla = ServiceLevelAgreement()
            form = ServiceLevelAgreementForm(request.user.get_profile(),
                                             request.POST,
                                             instance=sla)
            if form.is_valid():
                sla = form.save()
                sla.set_user_from_request(request)
                return HttpResponseRedirect(
                    reverse('services_sla_view', args=[sla.id]))
        else:
            return HttpResponseRedirect(reverse('services'))
    else:
        form = ServiceLevelAgreementForm(request.user.get_profile())

    context = _get_default_context(request)
    context.update({'form': form})

    return render_to_response('services/sla_add',
                              context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
Esempio n. 4
0
def sla_edit(request, sla_id, response_format='html'):
    "ServiceLevelAgreement edit"

    sla = get_object_or_404(ServiceLevelAgreement, pk=sla_id)
    if not request.user.get_profile().has_permission(sla, mode='w'):
        return user_denied(
            request,
            message="You don't have access to this Service Level Agreement")

    if request.POST:
        if not 'cancel' in request.POST:
            form = ServiceLevelAgreementForm(request.user.get_profile(),
                                             request.POST,
                                             instance=sla)
            if form.is_valid():
                sla = form.save()
                return HttpResponseRedirect(
                    reverse('services_sla_view', args=[sla.id]))
        else:
            return HttpResponseRedirect(
                reverse('services_sla_view', args=[sla.id]))
    else:
        form = ServiceLevelAgreementForm(request.user.get_profile(),
                                         instance=sla)

    context = _get_default_context(request)
    context.update({'sla': sla, 'form': form})

    return render_to_response('services/sla_edit',
                              context,
                              context_instance=RequestContext(request),
                              response_format=response_format)