Ejemplo n.º 1
0
def edit(request, sodaId):
    soda=get_object_or_404(Soda, pk=sodaId)
    soda_form=None;
    from_arg=request.session.get('from', fromLocations.ALL_SODAS)

    previous_url = reverse('cm_soda_allsodas')
    if from_arg == fromLocations.TRAYS:
        previous_url = reverse('cm_trays_view')

    if request.method == 'POST':
        soda_form=SodaForm(request.POST, instance=soda)
        if soda_form.is_valid():
            soda_form.save()
            return redirect(previous_url)
    else:
        soda_form=SodaForm(instance=soda)

    return render_to_response(
       'intranet/caffeine_manager/soda/edit_soda.html',
       {
         'section':'intranet',
         'page':'caffeine',
         'form':soda_form,
         'id':sodaId,
         'previous_url':previous_url,
         'from_arg':from_arg
       }, context_instance=RequestContext(request))
Ejemplo n.º 2
0
def edit(request, sodaId):
    soda = get_object_or_404(Soda, pk=sodaId)
    soda_form = None
    from_arg = request.session.get('from', fromLocations.ALL_SODAS)

    previous_url = reverse('cm_soda_allsodas')
    if from_arg == fromLocations.TRAYS:
        previous_url = reverse('cm_trays_view')

    if request.method == 'POST':
        soda_form = SodaForm(request.POST, instance=soda)
        if soda_form.is_valid():
            soda_form.save()
            return redirect(previous_url)
    else:
        soda_form = SodaForm(instance=soda)

    return render_to_response('intranet/caffeine_manager/soda/edit_soda.html',
                              {
                                  'section': 'intranet',
                                  'page': 'caffeine',
                                  'form': soda_form,
                                  'id': sodaId,
                                  'previous_url': previous_url,
                                  'from_arg': from_arg
                              },
                              context_instance=RequestContext(request))
Ejemplo n.º 3
0
def add(request):
    soda_form=None;
    from_arg=request.session.get('from', fromLocations.ALL_SODAS)
    if request.method == 'POST':
        soda_form=SodaForm(request.POST)
        if soda_form.is_valid():
            soda_form.save()
            return redirect(reverse('cm_soda_all_sodas'))
    else:
        soda_form=SodaForm()

    return render_to_response(
       'intranet/caffeine_manager/soda/edit_soda.html',
       {
         'section':'intranet',
         'page':'caffeine',
         'form':soda_form,
         'from_arg':from_arg
       },
       context_instance=RequestContext(request))
Ejemplo n.º 4
0
def add(request):
    soda_form = None
    from_arg = request.session.get('from', fromLocations.ALL_SODAS)
    if request.method == 'POST':
        soda_form = SodaForm(request.POST)
        if soda_form.is_valid():
            soda_form.save()
            return redirect(reverse('cm_soda_allsodas'))
    else:
        soda_form = SodaForm()

    return render_to_response('intranet/caffeine_manager/soda/edit_soda.html',
                              {
                                  'section': 'intranet',
                                  'page': 'caffeine',
                                  'form': soda_form,
                                  'from_arg': from_arg
                              },
                              context_instance=RequestContext(request))