Пример #1
0
def confirmation(request):
    if request.method == 'POST':
        trainee = Trainee.objects.get(code=request.POST["code2"])
        form = ConfirmationForm(request.POST, request.FILES, instance=trainee)
        if form.is_valid():
            form.save()
            trainee.confirmado = True
            trainee.save()
            return HttpResponse("success")
        else:
            context = {
                'forms':[form,], 
                'form_message':"Congratulations for being accepted! Please fill out this additional information so we can get started processing your immigration papers",
                'locale':'en-US',
            }
            return render(request, 'fileManager/form.html', context)

    else:
        form = ConfirmationForm()
        context = {
            'forms':[form,], 
            'form_message':"Congratulations for being accepted! Please fill out this additional information so we can get started processing your immigration papers",
                'locale':'en-US',
            }
        return render(request, 'fileManager/form.html', context)
Пример #2
0
 def _receive_confirmation(self, request, origin):
     query_dict = dict((key.lower(), value) for key, value in request.GET.iteritems())
     query_dict.update({
         'order': query_dict.get('orderid', 0),
         'origin': origin,
     })
     confirmation = ConfirmationForm(query_dict)
     if confirmation.is_valid():
         confirmation.save()
     else:
         raise ValidationError('Confirmation sent by PSP did not validate: %s' % confirmation.errors)
     shaoutsign = self._get_sha_sign(query_dict, self.SHA_OUT_PARAMETERS,
                     settings.VIVEUM_PAYMENT.get('SHA1_OUT_SIGNATURE'))
     if shaoutsign != confirmation.cleaned_data['shasign']:
         raise SuspiciousOperation('Confirm redirection by PSP has a divergent SHA1 signature')
     self.logger.info('PSP redirected client with status %s for order %s',
         confirmation.cleaned_data['status'], confirmation.cleaned_data['orderid'])
     return confirmation
 def _receive_confirmation(self, request, origin):
     query_dict = dict((key.lower(), value) for key, value in request.GET.iteritems())
     query_dict.update({
         'order': query_dict.get('orderid', 0),
         'origin': origin,
     })
     confirmation = ConfirmationForm(query_dict)
     if confirmation.is_valid():
         confirmation.save()
     else:
         raise ValidationError('Confirmation sent by PSP did not validate: %s' % confirmation.errors)
     shaoutsign = self._get_sha_sign(query_dict, self.SHA_OUT_PARAMETERS,
                     settings.VIVEUM_PAYMENT.get('SHA1_OUT_SIGNATURE'))
     if shaoutsign != confirmation.cleaned_data['shasign']:
         raise SuspiciousOperation('Confirm redirection by PSP has a divergent SHA1 signature')
     self.logger.info('PSP redirected client with status %s for order %s',
         confirmation.cleaned_data['status'], confirmation.cleaned_data['orderid'])
     return confirmation
Пример #4
0
 def payment_was_successful(self, request):
     '''
     This listens to a confirmation sent by one of the IPayment servers.
     Valid payments are commited as confirmed payments into their model.
     The intention of this view is not to display any useful information,
     since the HTTP-client is a server located at IPayment.
     '''
     if request.method != 'POST':
         return HttpResponseBadRequest()
     try:
         if settings.IPAYMENT['checkOriginatingIP']:
             self._check_originating_ipaddr(request)
         post = request.POST.copy()
         if 'trx_amount' in post:
             post['trx_amount'] = (Decimal(post['trx_amount']) / Decimal('100')) \
                                                 .quantize(Decimal('0.00'))
         if 'ret_transdate' and 'ret_transtime' in post:
             post['ret_transdatetime'] = datetime.strptime(
                 post['ret_transdate'] + ' ' + post['ret_transtime'],
                 '%d.%m.%y %H:%M:%S')
         confirmation = ConfirmationForm(post)
         if not confirmation.is_valid():
             raise SuspiciousOperation(
                 'Confirmation by IPayment rejected: '
                 'POST data does not contain all expected fields.')
         if not settings.IPAYMENT['useSessionId']:
             self._check_ret_param_hash(request.POST)
         confirmation.save()
         order = self.shop.get_order_for_id(
             confirmation.cleaned_data['shopper_id'])
         self.logger.info('IPayment for %s confirmed %s', order,
                          confirmation.cleaned_data['ret_status'])
         if confirmation.cleaned_data['ret_status'] == 'SUCCESS':
             self.shop.confirm_payment(
                 order, confirmation.cleaned_data['trx_amount'],
                 confirmation.cleaned_data['ret_trx_number'],
                 self.backend_name)
         return HttpResponse('OK')
     except Exception as exception:
         # since this response is sent to IPayment, catch errors locally
         logging.error('POST data: ' + request.POST.__str__())
         logging.error(exception.__str__())
         traceback.print_exc()
         return HttpResponseServerError('Internal error in ' + __name__)
Пример #5
0
 def payment_was_successful(self, request):
     '''
     This listens to a confirmation sent by one of the IPayment servers.
     Valid payments are commited as confirmed payments into their model.
     The intention of this view is not to display any useful information,
     since the HTTP-client is a server located at IPayment.
     '''
     if request.method != 'POST':
         return HttpResponseBadRequest()
     try:
         if settings.IPAYMENT['checkOriginatingIP']:
             self._check_originating_ipaddr(request)
         post = request.POST.copy()
         if 'trx_amount' in post:
             post['trx_amount'] = (Decimal(post['trx_amount']) / Decimal('100')) \
                                                 .quantize(Decimal('0.00'))
         if 'ret_transdate' and 'ret_transtime' in post:
             post['ret_transdatetime'] = datetime.strptime(
                 post['ret_transdate'] + ' ' + post['ret_transtime'],
                 '%d.%m.%y %H:%M:%S')
         confirmation = ConfirmationForm(post)
         if not confirmation.is_valid():
             raise SuspiciousOperation('Confirmation by IPayment rejected: '
                         'POST data does not contain all expected fields.')
         if not settings.IPAYMENT['useSessionId']:
             self._check_ret_param_hash(request.POST)
         confirmation.save()
         order = self.shop.get_order_for_id(confirmation.cleaned_data['shopper_id'])
         self.logger.info('IPayment for %s confirmed %s', order,
                          confirmation.cleaned_data['ret_status'])
         if confirmation.cleaned_data['ret_status'] == 'SUCCESS':
             self.shop.confirm_payment(order, confirmation.cleaned_data['trx_amount'],
                 confirmation.cleaned_data['ret_trx_number'], self.backend_name)
         return HttpResponse('OK')
     except Exception as exception:
         # since this response is sent to IPayment, catch errors locally
         logging.error('POST data: ' + request.POST.__str__())
         logging.error(exception.__str__())
         traceback.print_exc()
         return HttpResponseServerError('Internal error in ' + __name__)
Пример #6
0
def patient_new_with_visit(request, orgStr):
  """Add a new patient and a new visit to the new patient in one screen.

  Note: You can add patients and visits without being logged in, but you will
  only be able to see the last one.
  """
  #logging.info("request.LANGUAGE_CODE: %s" % request.LANGUAGE_CODE)
  #logging.info("request: %s" % request)
  patient_exists = False

  if not models.organization_exists(orgStr):
    raise Http404

  # NOTE(dan): patient doesn't change, so it need not be a param
  def render_this(patient_exists, confirmationForm, patientForm, visitForm):
    return respond(request, 'patient_new_with_visit.html',
                   {'patient_exists': patient_exists,
                    'confirmationform': confirmationForm,
                    'patientform': patientForm,
                    'visitform': visitForm,
                    'orgStr' : orgStr})

  if request.method != 'POST':
    confirmationForm = ConfirmationForm()
    default_country = getattr(request.user, 'default_country', '')
    if default_country:
      patientForm = PatientForm(initial={'organization':orgStr, 'country': default_country})
    else:
      patientForm = PatientForm(initial={'organization':orgStr})
        
    visitForm = VisitForm(initial={'organization':orgStr})
  else:
    confirmationForm = ConfirmationForm(request.POST)
    patientForm = PatientForm(request.POST)
    visitForm = VisitForm(request.POST)

    if patientForm.is_valid() and visitForm.is_valid():
      # First check if patient exists based on name and date of birth
      name = patientForm.cleaned_data['name']
      birth_date = patientForm.cleaned_data['birth_date']
      patient = models.Patient.get_patient_by_name_birthdate(name, birth_date)
      if patient:
        patient_exists = True
        request.session['patient'] = patient
      
      # If patient is new
      if not patient_exists:
        # Need to store both
        if not _store_new_patient_and_new_visit(request, orgStr, patientForm, visitForm):
          return render_this(patient_exists, confirmationForm, patientForm, visitForm)
      # We already went through this once and there is another patient with same name and birthdate
      else:         
        if confirmationForm.is_valid():  
          confirmation_option = confirmationForm.cleaned_data['confirmation_option']
          if confirmation_option == 'addpatientvisit':
            # Need to store both
            if not _store_new_patient_and_new_visit(request, orgStr, patientForm, visitForm):
              return render_this(patient_exists, confirmationForm, patientForm, visitForm)
          else:              
            # Patient is still the same 
            patient = request.session['patient']                       
            # Just add the visit
            newVisit = models.Visit(parent = patient)
            visitForm = VisitForm(request.POST, instance = newVisit)
            visit = _store_new_visit(patient, visitForm, request.user)        
            if not visit:
              return render_this(patient_exists, confirmationForm, patientForm, visitForm)      
        else:
          return render_this(patient_exists, confirmationForm, patientForm, visitForm)        
            
      patient = request.session['patient']
      # Redirect to viewing
      return HttpResponseRedirect(patient.get_view_url())
                
  return render_this(patient_exists, confirmationForm, patientForm, visitForm)