def tier_change(request, object_id):
    """Update/Delete tier for the logged in manager

    **Attributes**:

        * ``object_id`` - Selected tier object
        * ``form`` - TierFrontEndForm
        * ``template`` - callcenter/tier/change.html

    **Logic Description**:

        * Update/delete selected tier from the tier list
          via TierFrontEndForm & get redirected to the tier list
    """
    tier = get_object_or_404(Tier, pk=object_id, manager=request.user)
    form = TierFrontEndForm(request.user.id, request.POST or None, instance=tier)
    if form.is_valid():
        # Delete tier
        if request.POST.get('delete'):
            tier_del(request, object_id)
            return HttpResponseRedirect(redirect_url_to_tier_list)
        else:
            # Update tier
            form.save()
            request.session["msg"] = _('"%(id)s" tier is updated.') % {'id': tier.id}
            return HttpResponseRedirect(redirect_url_to_tier_list)

    data = {
        'form': form,
        'action': 'update',
    }
    return render_to_response('callcenter/tier/change.html', data, context_instance=RequestContext(request))
Exemple #2
0
def tier_add(request):
    """Add new tier for the logged in manager

    **Attributes**:

        * ``form`` - TierFrontEndForm
        * ``template`` - callcenter/tier/change.html

    **Logic Description**:

        * Add a new tier which will belong to the logged in manager
          via the TierFrontEndForm & get redirected to the tier list
    """
    form = TierFrontEndForm(request.user.id, request.POST or None)
    if form.is_valid():
        obj = form.save(commit=False)
        obj.manager = Manager.objects.get(username=request.user)
        obj.save()

        request.session["msg"] = _('"%(name)s" tier is added.') % {
            'name': obj.id
        }
        return HttpResponseRedirect(redirect_url_to_tier_list)
    data = {
        'form': form,
        'action': 'add',
    }
    return render_to_response('callcenter/tier/change.html',
                              data,
                              context_instance=RequestContext(request))
def tier_add(request):
    """Add new tier for the logged in manager

    **Attributes**:

        * ``form`` - TierFrontEndForm
        * ``template`` - callcenter/tier/change.html

    **Logic Description**:

        * Add a new tier which will belong to the logged in manager
          via the TierFrontEndForm & get redirected to the tier list
    """
    form = TierFrontEndForm(request.user.id, request.POST or None)
    if form.is_valid():
        obj = form.save(commit=False)
        obj.manager = Manager.objects.get(username=request.user)
        obj.save()

        request.session["msg"] = _('"%(name)s" tier is added.') % {'name': obj.id}
        return HttpResponseRedirect(redirect_url_to_tier_list)
    data = {
        'form': form,
        'action': 'add',
    }
    return render_to_response('callcenter/tier/change.html', data,
                              context_instance=RequestContext(request))
Exemple #4
0
def tier_change(request, object_id):
    """Update/Delete tier for the logged in manager

    **Attributes**:

        * ``object_id`` - Selected tier object
        * ``form`` - TierFrontEndForm
        * ``template`` - callcenter/tier/change.html

    **Logic Description**:

        * Update/delete selected tier from the tier list
          via TierFrontEndForm & get redirected to the tier list
    """
    tier = get_object_or_404(Tier, pk=object_id, manager=request.user)
    form = TierFrontEndForm(request.user.id, request.POST or None, instance=tier)
    if form.is_valid():
        # Delete tier
        if request.POST.get('delete'):
            tier_del(request, object_id)
            return HttpResponseRedirect(redirect_url_to_tier_list)
        else:
            # Update tier
            form.save()
            request.session["msg"] = _('"%(id)s" tier is updated.') % {'id': tier.id}
            return HttpResponseRedirect(redirect_url_to_tier_list)

    data = {
        'form': form,
        'action': 'update',
    }
    return render_to_response('callcenter/tier/change.html', data, context_instance=RequestContext(request))