Пример #1
0
def receive_form(request, obj=False):

    obj = get_object_or_404(Receive, pk=obj)
    pfx = 'receive_form---%s' % obj.id  # hardcode JQuery, currency mask.

    if request.POST:
        form = ReceiveFormUpdate(request.POST, instance=obj, prefix=pfx)

        if form.is_valid():
            obj = form.save()
            messages.success(request, _(u'Salvo com sucesso!'))
            return HttpResponseRedirect('/financial/receive/%s/' % obj.id)

    # mount form
    else:
        if not obj.launch_date:
            form = ReceiveFormUpdate(
                    instance=obj,
                    prefix=pfx,
                    initial={'launch_date': date.today()}
                    )
        else:
            form = ReceiveFormUpdate(instance=obj, prefix=pfx)

    # mount form or not valid form
    return render_to_response('financial/financial_receive_form.html', {
            'form': form,
            'obj': obj
        }, context_instance=RequestContext(request))
Пример #2
0
def receive_form(request, obj=False):

    obj = get_object_or_404(Receive, pk=obj)
    pfx = 'receive_form---%s' % obj.id  # hardcode JQuery, currency mask.

    if request.POST:
        form = ReceiveFormUpdate(request.POST, instance=obj, prefix=pfx)

        if form.is_valid():
            obj = form.save()
            messages.success(request, _(u'Salvo com sucesso!'))
            return HttpResponseRedirect('/financial/receive/%s/' % obj.id)

    # mount form
    else:
        if not obj.launch_date:
            form = ReceiveFormUpdate(instance=obj,
                                     prefix=pfx,
                                     initial={'launch_date': date.today()})
        else:
            form = ReceiveFormUpdate(instance=obj, prefix=pfx)

    # mount form or not valid form
    return render_to_response('financial/financial_receive_form.html', {
        'form': form,
        'obj': obj
    },
                              context_instance=RequestContext(request))
Пример #3
0
def occurrence_confirmation_form(
        request, 
        pk, 
        template='schedule/schedule_occurrence_confirmation_form.html',
        form_class=OccurrenceConfirmationForm,
        client_id = None,
        redirect_to = None,
    ):

    '''
        confirmation event
    '''

    occurrence = get_object_or_404(ScheduleOccurrence, pk=pk, event__referral__service__organization=request.user.get_profile().org_active)
    receive_list = []
    
    if not occurrence.scheduleoccurrence.was_confirmed():
        initial_device = [device.pk for device in occurrence.device.all()]
    else:
        initial_device = [device.pk for device in occurrence.occurrenceconfirmation.device.all()]
        
    # check if requested user have perms to read it
    if not _access_check_by_occurrence(request, occurrence):
        return render_to_response('403.html', {'object': _("Oops! You don't have access for this service!"), }, context_instance=RequestContext(request))

    try:
        occurrence_confirmation = OccurrenceConfirmation.objects.get(pk = occurrence.occurrenceconfirmation.id)
    except:
        occurrence_confirmation = None
    
    object = get_object_or_None(Client, pk = client_id, person__organization=request.user.get_profile().org_active)

    from gestorpsi.client.views import _access_check_referral_write
    denied_to_write = None

    if not _access_check_referral_write(request, occurrence.event.referral):
        denied_to_write = True

    if request.method == 'POST':

        if denied_to_write:
            return render_to_response('403.html', {'object': _("Oops! You don't have access for this service!"), }, context_instance=RequestContext(request))

        form = form_class(request.POST, instance = occurrence_confirmation, initial={ 'device':initial_device, })

        # receive
        payment_valid = True

        for x in Receive.objects.filter(occurrence=occurrence):

            pfx = 'receive_form---%s' % x.id # hardcore Jquery 
            form_receive = ReceiveFormUpdate(request.POST, instance=x, prefix=pfx)

            receive_list.append(form_receive)

            if form_receive.is_valid():
                fp = form_receive.save()
            else:
                payment_valid = False

        # occurrence
        if form.is_valid() and payment_valid :

            data = form.save(commit=False)
            data.occurrence = occurrence

            if int(data.presence) not in (1,2): # client not arrive, dont save datetime field
                data.date_started = None
                data.date_finished = None

            data.save()
            form.save_m2m()

            # save occurrence comment
            occurrence.annotation = request.POST['occurrence_annotation']
            occurrence.save()

            messages.success(request, _('Occurrence confirmation updated successfully'))
            return http.HttpResponseRedirect(redirect_to or request.path)

        else:

            form.fields['device'].widget.choices = [(i.id, i) for i in DeviceDetails.objects.active(request.user.get_profile().org_active).filter(Q(room=occurrence.room) | Q(mobility=2, lendable=True) | Q(place =  occurrence.room.place, mobility=2, lendable=False))]

            messages.error(request, _(u'Campo inválido ou obrigatório'))

    # not request.POST
    else:
        if hasattr(occurrence_confirmation, 'presence') and int(occurrence_confirmation.presence) not in (1,2): # load initial data if client dont arrive
            occurrence_confirmation.date_started = occurrence.start_time
            occurrence_confirmation.date_finished = occurrence.end_time

        form = form_class(instance=occurrence_confirmation, initial={
            'occurrence':occurrence, 
            'start_time':occurrence.start_time, 
            'end_time':occurrence.end_time,
            'device': initial_device,
            })

        form.fields['device'].widget.choices = [(i.id, i) for i in DeviceDetails.objects.active(request.user.get_profile().org_active).filter(Q(room=occurrence.room) | Q(mobility="2", lendable=True) | Q(place=occurrence.room.place, mobility="2", lendable=False))]

        # payment form
        for x in Receive.objects.filter(occurrence=occurrence):
            pfx = 'receive_form---%s' % x.id
            receive_list.append( ReceiveFormUpdate(instance=x, prefix=pfx) )

    return render_to_response(
        template,
        dict(
                occurrence=occurrence,
                form=form,
                object=object,
                referral=occurrence.event.referral,
                occurrence_confirmation=occurrence_confirmation,
                hide_date_field=True if occurrence_confirmation and int(occurrence_confirmation.presence) > 2 else None,
                denied_to_write = denied_to_write,
                receive_list = receive_list,
            ),
        context_instance=RequestContext(request)
    )
Пример #4
0
def occurrence_confirmation_form_group(
        request, 
        pk, 
        template='schedule/schedule_occurrence_confirmation_form_group.html',
        form_class=OccurrenceConfirmationForm,
        client_id = None,
        redirect_to = None,
    ):

    '''
        confirmation event for a member of group
        choose a covenant of service and create a payment based in covenant
    '''

    occurrence = get_object_or_404(ScheduleOccurrence, pk=pk, event__referral__service__organization=request.user.get_profile().org_active)
    covenant_list = occurrence.event.referral.service.covenant.all().order_by('name')
    receive_list = []

    if not occurrence.scheduleoccurrence.was_confirmed():
        initial_device = [device.pk for device in occurrence.device.all()]
    else:
        initial_device = [device.pk for device in occurrence.occurrenceconfirmation.device.all()]
        
    # check if requested user have perms to read it
    if not _access_check_by_occurrence(request, occurrence):
        return render_to_response('403.html', {'object': _("Oops! You don't have access for this service!"), }, context_instance=RequestContext(request))

    try:
        occurrence_confirmation = OccurrenceConfirmation.objects.get(pk = occurrence.occurrenceconfirmation.id)
    except:
        occurrence_confirmation = None
    
    object = get_object_or_None(Client, pk = client_id, person__organization=request.user.get_profile().org_active)

    from gestorpsi.client.views import _access_check_referral_write
    denied_to_write = None

    if not _access_check_referral_write(request, occurrence.event.referral):
        denied_to_write = True

    # update occurrence and payments or new payment.
    if request.method == 'POST':

        # permission
        if denied_to_write:
            return render_to_response('403.html', {'object': _("Oops! You don't have access for this service!"), }, context_instance=RequestContext(request))


        # new payment form, not required.
        if not request.POST.get('select_covenant_receive') == '000' :

            covenant = Covenant.objects.get( pk=request.POST.get('select_covenant_receive'), organization=request.user.get_profile().org_active ) 

            pfx = 'receive_form---TEMPID999FORM' # hardcore Jquery 
            form_receive_new = ReceiveFormNew(request.POST, prefix=pfx)

            if form_receive_new.is_valid():

                fpn = form_receive_new.save()
                fpn.occurrence.add(occurrence)

                # from covenant
                fpn.covenant_payment_way_options = ''
                for pw in covenant.payment_way.all():
                    x = "(%s,'%s')," % ( pw.id , pw.name ) # need be a dict
                    fpn.covenant_payment_way_options += x

                fpn.covenant_payment_way_selected = request.POST.getlist('TEMPID999FORM-pw')
                fpn.save()


        # update payments, not required.
        for x in Receive.objects.filter(occurrence=occurrence):

            pfx = 'receive_form---%s' % x.id # hardcore Jquery 
            form_receive = ReceiveFormUpdate(request.POST, instance=x, prefix=pfx)

            receive_list.append(form_receive)

            if form_receive.is_valid():
                fp = form_receive.save()


        # occurrence
        form = form_class(request.POST, instance = occurrence_confirmation, initial={ 'device':initial_device, })

        if form.is_valid():

            data = form.save(commit=False)
            data.occurrence = occurrence

            if int(data.presence) not in (1,2): # client not arrive, dont save datetime field
                data.date_started = None
                data.date_finished = None

            data.save()
            form.save_m2m()

            # save occurrence comment
            occurrence.annotation = request.POST['occurrence_annotation']
            occurrence.save()

            messages.success(request, _('Occurrence confirmation updated successfully'))
            return http.HttpResponseRedirect(redirect_to or request.path)

        else:

            form.fields['device'].widget.choices = [(i.id, i) for i in DeviceDetails.objects.active(request.user.get_profile().org_active).filter(Q(room=occurrence.room) | Q(mobility=2, lendable=True) | Q(place =  occurrence.room.place, mobility=2, lendable=False))]

            messages.error(request, _(u'Campo inválido ou obrigatório'))

    else:
        if hasattr(occurrence_confirmation, 'presence') and int(occurrence_confirmation.presence) not in (1,2): # load initial data if client dont arrive
            occurrence_confirmation.date_started = occurrence.start_time
            occurrence_confirmation.date_finished = occurrence.end_time

        form = form_class(instance=occurrence_confirmation, initial={
            'occurrence':occurrence, 
            'start_time':occurrence.start_time, 
            'end_time':occurrence.end_time,
            'device': initial_device,
            })

        form.fields['device'].widget.choices = [(i.id, i) for i in DeviceDetails.objects.active(request.user.get_profile().org_active).filter(Q(room=occurrence.room) | Q(mobility="2", lendable=True) | Q(place=occurrence.room.place, mobility="2", lendable=False))]

        # payments of occurrence, update form.
        for x in Receive.objects.filter(occurrence=occurrence):
            pfx = 'receive_form---%s' % x.id # for many forms and one submit.
            receive_list.append( ReceiveFormUpdate(instance=x, prefix=pfx) )


    # just one out if errors
    return render_to_response(
        template,
        dict(
                occurrence=occurrence,
                form=form,
                object=object,
                referral=occurrence.event.referral,
                occurrence_confirmation=occurrence_confirmation,
                hide_date_field=True if occurrence_confirmation and int(occurrence_confirmation.presence) > 2 else None,
                denied_to_write = denied_to_write,
                receive_list = receive_list,
                covenant_list = covenant_list,
                receive_new_form = ReceiveFormNew(prefix='receive_form---TEMPID999FORM'),
            ),
        context_instance=RequestContext(request)
    )
Пример #5
0
def occurrence_confirmation_form(
        request, 
        pk, 
        template='schedule/schedule_occurrence_confirmation_form.html',
        form_class=OccurrenceConfirmationForm,
        client_id = None,
        redirect_to = None,
    ):

    '''
        confirmation event
    '''

    occurrence = get_object_or_404(ScheduleOccurrence, pk=pk, event__referral__service__organization=request.user.get_profile().org_active)
    receive_list = []
    
    if not occurrence.scheduleoccurrence.was_confirmed():
        initial_device = [device.pk for device in occurrence.device.all()]
    else:
        initial_device = [device.pk for device in occurrence.occurrenceconfirmation.device.all()]
        
    # check if requested user have perms to read it
    if not _access_check_by_occurrence(request, occurrence):
        return render_to_response('403.html', {'object': _("Oops! You don't have access for this service!"), }, context_instance=RequestContext(request))

    try:
        occurrence_confirmation = OccurrenceConfirmation.objects.get(pk=occurrence.occurrenceconfirmation.id)
    except:
        occurrence_confirmation = None
    
    object = get_object_or_None(Client, pk=client_id, person__organization=request.user.get_profile().org_active)

    from gestorpsi.client.views import _access_check_referral_write
    denied_to_write = None

    if not _access_check_referral_write(request, occurrence.event.referral):
        denied_to_write = True

    if request.method == 'POST':

        if denied_to_write:
            return render_to_response('403.html', {'object': _("Oops! You don't have access for this service!"), }, context_instance=RequestContext(request))

        form = form_class(request.POST, instance=occurrence_confirmation, initial={'device':initial_device})

        # receive
        payment_valid = True

        for x in Receive.objects.filter(occurrence=occurrence):

            pfx = 'receive_form---%s' % x.id # hardcode Jquery 
            form_receive = ReceiveFormUpdate(request.POST, instance=x, prefix=pfx)

            receive_list.append(form_receive)

            if form_receive.is_valid():
                fp = form_receive.save()
            else:
                payment_valid = False

        # occurrence
        if form.is_valid() and payment_valid :

            occurrence_confirmation = form.save(commit=False)
            occurrence_confirmation.occurrence = occurrence

            if int(occurrence_confirmation.presence) not in (1,2): # client not arrive, dont save datetime field
                occurrence_confirmation.date_started = None
                occurrence_confirmation.date_finished = None

            occurrence_confirmation.save()
            form.save_m2m()

            # save occurrence comment
            occurrence.annotation = request.POST['occurrence_annotation']
            occurrence.save()

            # sendmail for careprofessional when presence is 4 or 5
            if hasattr(occurrence_confirmation,'presence'):
                if occurrence_confirmation.presence == 4 or occurrence_confirmation.presence == 5 :
                    schedule_notify_email(request.user.get_profile().org_active, occurrence, occurrence_confirmation)

            messages.success(request, _('Occurrence confirmation updated successfully'))
            return http.HttpResponseRedirect(redirect_to or request.path)

        else:
            form.fields['device'].widget.choices = [(i.id, i) for i in DeviceDetails.objects.active(request.user.get_profile().org_active).filter(Q(room=occurrence.room) | Q(mobility=2, lendable=True) | Q(place = occurrence.room.place, mobility=2, lendable=False))]
            messages.error(request, _(u'Campo inválido ou obrigatório'))

    # not request.POST
    else:
        if hasattr(occurrence_confirmation, 'presence') and int(occurrence_confirmation.presence) not in (1,2): # load initial data if client dont arrive
            occurrence_confirmation.date_started = occurrence.start_time
            occurrence_confirmation.date_finished = occurrence.end_time

        form = form_class(instance=occurrence_confirmation, initial={
            'occurrence':occurrence, 
            'start_time':occurrence.start_time, 
            'end_time':occurrence.end_time,
            'device': initial_device,
            })

        form.fields['device'].widget.choices = [(i.id, i) for i in DeviceDetails.objects.active(request.user.get_profile().org_active).filter(Q(room=occurrence.room) | Q(mobility="2", lendable=True) | Q(place=occurrence.room.place, mobility="2", lendable=False))]

        # payment form
        for x in Receive.objects.filter(occurrence=occurrence):
            pfx = 'receive_form---%s' % x.id

            # new! fill payment date today
            if not x.launch_date:
                receive_list.append( ReceiveFormUpdate(instance=x, prefix=pfx, initial={ 'launch_date':date.today() }) )
            else:
                receive_list.append( ReceiveFormUpdate(instance=x, prefix=pfx) )

    return render_to_response(
        template,
        dict(
                occurrence=occurrence,
                form=form,
                object=object,
                referral=occurrence.event.referral,
                occurrence_confirmation=occurrence_confirmation,
                hide_date_field=True if occurrence_confirmation and int(occurrence_confirmation.presence) > 2 else None,
                denied_to_write = denied_to_write,
                receive_list = receive_list,
            ),
        context_instance=RequestContext(request)
    )
Пример #6
0
def occurrence_confirmation_form_group(
        request, 
        pk, 
        template='schedule/schedule_occurrence_confirmation_form_group.html',
        form_class=OccurrenceConfirmationForm,
        client_id = None,
        redirect_to = None,
    ):

    '''
        confirmation event for a member of group
        choose a covenant of service and create a payment based in covenant
    '''

    occurrence = get_object_or_404(ScheduleOccurrence, pk=pk, event__referral__service__organization=request.user.get_profile().org_active)
    covenant_list = occurrence.event.referral.service.covenant.all().order_by('name')
    receive_list = []

    if not occurrence.scheduleoccurrence.was_confirmed():
        initial_device = [device.pk for device in occurrence.device.all()]
    else:
        initial_device = [device.pk for device in occurrence.occurrenceconfirmation.device.all()]
        
    # check if requested user have perms to read it
    if not _access_check_by_occurrence(request, occurrence):
        return render_to_response('403.html', {'object': _("Oops! You don't have access for this service!"), }, context_instance=RequestContext(request))

    try:
        occurrence_confirmation = OccurrenceConfirmation.objects.get(pk = occurrence.occurrenceconfirmation.id)
    except:
        occurrence_confirmation = None
    
    object = get_object_or_None(Client, pk = client_id, person__organization=request.user.get_profile().org_active)

    from gestorpsi.client.views import _access_check_referral_write
    denied_to_write = None

    if not _access_check_referral_write(request, occurrence.event.referral):
        denied_to_write = True

    # update occurrence and payments or new payment.
    if request.method == 'POST':

        # permission
        if denied_to_write:
            return render_to_response('403.html', {'object': _("Oops! You don't have access for this service!"), }, context_instance=RequestContext(request))


        # new payment form, not required.
        if not request.POST.get('select_covenant_receive') == '000' :

            covenant = Covenant.objects.get( pk=request.POST.get('select_covenant_receive'), organization=request.user.get_profile().org_active ) 
            pfx = 'receive_form---TEMPID999FORM' # hardcode Jquery 
            form_receive_new = ReceiveFormNew(request.POST, prefix=pfx, initial={ 'launch_date': date.today() })

            if form_receive_new.is_valid():

                fpn = form_receive_new.save()
                fpn.occurrence.add(occurrence)

                # from covenant
                fpn.covenant_payment_way_options = ''
                for pw in covenant.payment_way.all():
                    x = "(%s,'%s')," % ( pw.id , pw.name ) # need be a dict
                    fpn.covenant_payment_way_options += x

                fpn.covenant_payment_way_selected = request.POST.getlist('TEMPID999FORM-pw')
                fpn.save()


        # update payments, not required.
        for x in Receive.objects.filter(occurrence=occurrence):
            pfx = 'receive_form---%s' % x.id # hardcode Jquery 
            # new! fill payment date today
            if not x.launch_date:
                receive_list.append(ReceiveFormUpdate(request.POST, instance=x, prefix=pfx, initial={'launch_date':date.today()}))
            else:
                receive_list.append(ReceiveFormUpdate(request.POST, instance=x, prefix=pfx))

            if form_receive.is_valid():
                fp = form_receive.save()


        # occurrence
        form = form_class(request.POST, instance=occurrence_confirmation, initial={ 'device':initial_device, })

        if form.is_valid():
            data = form.save(commit=False)
            data.occurrence = occurrence

            if int(data.presence) not in (1,2): # client not arrive, dont save datetime field
                data.date_started = None
                data.date_finished = None

            data.save()
            form.save_m2m()

            # save occurrence comment
            occurrence.annotation = request.POST['occurrence_annotation']
            occurrence.save()

            messages.success(request, _('Occurrence confirmation updated successfully'))
            return http.HttpResponseRedirect(redirect_to or request.path)
        else:
            form.fields['device'].widget.choices = [(i.id, i) for i in DeviceDetails.objects.active(request.user.get_profile().org_active).filter(Q(room=occurrence.room) | Q(mobility=2, lendable=True) | Q(place =  occurrence.room.place, mobility=2, lendable=False))]

            messages.error(request, _(u'Campo inválido ou obrigatório'))

    else:
        if hasattr(occurrence_confirmation, 'presence') and int(occurrence_confirmation.presence) not in (1,2): # load initial data if client dont arrive
            occurrence_confirmation.date_started = occurrence.start_time
            occurrence_confirmation.date_finished = occurrence.end_time

        form = form_class(instance=occurrence_confirmation, initial={
            'occurrence':occurrence, 
            'start_time':occurrence.start_time, 
            'end_time':occurrence.end_time,
            'device': initial_device,
            })

        form.fields['device'].widget.choices = [(i.id, i) for i in DeviceDetails.objects.active(request.user.get_profile().org_active).filter(Q(room=occurrence.room) | Q(mobility="2", lendable=True) | Q(place=occurrence.room.place, mobility="2", lendable=False))]

        # payments of occurrence, update form.
        for x in Receive.objects.filter(occurrence=occurrence):
            pfx = 'receive_form---%s' % x.id # for many forms and one submit.
            receive_list.append( ReceiveFormUpdate(instance=x, prefix=pfx) )


    # just one out if errors
    return render_to_response(
        template,
        dict(
                occurrence=occurrence,
                form=form,
                object=object,
                referral=occurrence.event.referral,
                occurrence_confirmation=occurrence_confirmation,
                hide_date_field=True if occurrence_confirmation and int(occurrence_confirmation.presence) > 2 else None,
                denied_to_write = denied_to_write,
                receive_list = receive_list,
                covenant_list = covenant_list,
                receive_new_form = ReceiveFormNew(prefix='receive_form---TEMPID999FORM'),
            ),
        context_instance=RequestContext(request)
    )
Пример #7
0
def occurrence_confirmation_form_group(
    request,
    pk,
    template='schedule/schedule_occurrence_confirmation_form_group.html',
    form_class=OccurrenceConfirmationForm,
    client_id=None,
    redirect_to=None,
):
    '''
        confirmation event for a member of group
        choose a covenant of service and create a payment based in covenant
    '''

    occurrence = get_object_or_404(
        ScheduleOccurrence, pk=pk, event__referral__service__organization=request.user.get_profile().org_active)
    covenant_list = occurrence.event.referral.service.covenant.all().order_by('name')
    receive_list = []

    if not occurrence.scheduleoccurrence.was_confirmed():
        initial_device = [device.pk for device in occurrence.device.all()]
    else:
        initial_device = [
            device.pk for device in occurrence.occurrenceconfirmation.device.all()]

    # check if requested user have perms to read it
    if not _access_check_by_occurrence(request, occurrence):
        return render_to_response('403.html', {'object': _("Oops! You don't have access for this service!"), }, context_instance=RequestContext(request))

    try:
        occurrence_confirmation = OccurrenceConfirmation.objects.get(
            pk=occurrence.occurrenceconfirmation.id)
    except:
        occurrence_confirmation = None

    object = get_object_or_None(
        Client, pk=client_id, person__organization=request.user.get_profile().org_active)

    from gestorpsi.client.views import _access_check_referral_write
    denied_to_write = None

    if not _access_check_referral_write(request, occurrence.event.referral):
        denied_to_write = True

    # update occurrence and payments or new payment.
    if request.method == 'POST':

        # permission
        if denied_to_write:
            return render_to_response('403.html', {'object': _("Oops! You don't have access for this service!"), }, context_instance=RequestContext(request))

        # Calls method to create new payment form.
        create_new_payment_form()

        # update payments, not required.
        for x in Receive.objects.filter(occurrence=occurrence):

            prefix = 'receive_form---%s' % x.id  # hardcore Jquery
            form_receive = ReceiveFormUpdate(
                request.POST, instance=x, prefix=prefix)

            receive_list.append(form_receive)

            if form_receive.is_valid():
                form_payment = form_receive.save()

        # occurrence
        form = form_class(request.POST, instance=occurrence_confirmation, initial={
                          'device': initial_device, })

        # Calls method that validates payment form.
        valid_payment_form()

    else:
        # load initial data if client dont arrive
        if hasattr(occurrence_confirmation, 'presence') and int(occurrence_confirmation.presence) not in (1, 2):
            occurrence_confirmation.date_started = occurrence.start_time
            occurrence_confirmation.date_finished = occurrence.end_time

        form = form_class(instance=occurrence_confirmation, initial={
            'occurrence': occurrence,
            'start_time': occurrence.start_time,
            'end_time': occurrence.end_time,
            'device': initial_device,
        })

        form.fields['device'].widget.choices = [(i.id, i) for i in DeviceDetails.objects.active(request.user.get_profile().org_active).filter(
            Q(room=occurrence.room) | Q(mobility="2", lendable=True) | Q(place=occurrence.room.place, mobility="2", lendable=False))]

        # payments of occurrence, update form.
        for x in Receive.objects.filter(occurrence=occurrence):
            # for many forms and one submit.
            prefix = 'receive_form---%s' % x.id
            receive_list.append(ReceiveFormUpdate(instance=x, prefix=prefix))


    # just one out if errors
    return render_to_response(
        template,
        dict(
            occurrence=occurrence,
            form=form,
            object=object,
            referral=occurrence.event.referral,
            occurrence_confirmation=occurrence_confirmation,
            hide_date_field=True if occurrence_confirmation and int(
                occurrence_confirmation.presence) > 2 else None,
            denied_to_write=denied_to_write,
            receive_list=receive_list,
            covenant_list=covenant_list,
            receive_new_form=ReceiveFormNew(
                prefix='receive_form---TEMPID999FORM'),
        ),
        context_instance=RequestContext(request)
    )