Beispiel #1
0
 def post(self):
     patient_signup_form = forms.user.PatientSignupForm().get_form(self.request.POST)
     
     if patient_signup_form.validate():
         
         # init the patient
         patient = Patient()
         patient_signup_form.populate_obj(patient)
         patient.put()
         
         msg = _('Thanks for your interest. We will be in touch soon!')
         self.render_template('user/signup_patient.html', success_message=msg, patient_signup_form=patient_signup_form)
     else:
         self.render_template('user/signup_patient.html', patient_signup_form=patient_signup_form)
    def post(self, vanity_url=None):
        provider = db.get_provider_from_vanity_url(vanity_url)

        patient_form = RegistrationDetailsForNewPatient().get_form(self.request.POST)
        
        if patient_form.validate():
            booking_key_urlsafe = patient_form['booking_key'].data
            booking = db.get_from_urlsafe_key(booking_key_urlsafe)

            # create a new patient
            patient = Patient()
                    
            patient_form.populate_obj(patient)
            self.set_gae_geography_from_headers(patient)
            patient.put()

            # create a new user
            user = self.create_empty_user_for_patient(patient)
            user.language = self.get_language()

            # set the password            
            password = patient_form['password'].data
            password_hash = security.generate_password_hash(password, length=12)    
            user.password = password_hash
            user.put()
            
            # login with new password
            self.login_user(user.get_email(), password)

            # store booking
            user = patient.user.get()
            booking.patient = patient.key
            booking.confirmed = user.confirmed = False
            booking.put()

            # send a confirmation/activation email
            url_obj = urlparse.urlparse(self.request.url)
            activation_url = urlparse.urlunparse((url_obj.scheme, url_obj.netloc, '/login/booking/' + booking.key.urlsafe(), '', '', ''))
            logging.info('(NewPatientHandler.post) generated activation url for user %s : %s ' %  (patient.email, activation_url))
            mail.email_booking_to_patient(self, booking, activation_url)
            
            PatientBaseHandler.render_confirmation_email_sent(self, booking)
        else:
            self.render_template('provider/public/booking_new_patient.html', provider=provider, patient_form=patient_form)

                
 def link_user_to_new_patient(self, appointment_details_form, user, booking):
     # user but no patient
     # create a patient and link it to existing user
     patient = Patient() 
     
     # set the properties (just email)
     appointment_details_form.populate_obj(patient)
     self.set_gae_geography_from_headers(patient)
     
     # link to logged in user
     patient.user = user.key
     patient.email = user.get_email()
     
     # if it's a provider, copy over details like name, etc.
     provider = db.get_provider_from_user(user)
     if provider:
         patient.first_name = provider.first_name
         patient.last_name = provider.last_name        
     
     patient.put()
     
     booking.patient = patient.key
     booking.put()
     
     # add patient role to user
     user.roles.append(auth.PATIENT_ROLE)
     user.put()
Beispiel #4
0
    def check_activation_email_patient(self):
        '''             
            1) receive confirmation email
            2) clicks profile activation link
            3) sets a password
        '''
        # check email
        messages = self.mail_stub.get_sent_messages(to=self._TEST_PATIENT_EMAIL)
        self.assertEqual(1, len(messages))
        m = messages[0]

        patient = Patient.query(Patient.email == self._TEST_PATIENT_EMAIL).get()
        booking = Booking.query(Booking.patient == patient.key).get()
        
        self.assertEqual(m.subject, 'Rendez-vous Veosan - %s' % 'Ostéopathe')
        
        # assert that activation link is in the email body
        user = User.query(User.key == patient.user).get()
        self.assertTrue('http://localhost/user/activation/%s' % user.signup_token in m.body.payload)
 
        # click link in email
        activation_response = self.testapp.get('/user/activation/%s' % str(user.signup_token))
        
        # choose a password
        activation_response.mustcontain('Votre rendez-vous est confirmé')
        activation_response.mustcontain("Fantastic Fox")
        booking = Booking.query(Booking.patient == patient.key).get()
        activation_response_form = activation_response.forms[0]
        activation_response_form['password'] = self._TEST_PATIENT_PASSWORD
        activation_response_form['password_confirm'] = self._TEST_PATIENT_PASSWORD
        booking_confirm_page = activation_response_form.submit()
        
        # patient email in navbar
        booking_confirm_page.mustcontain(self._TEST_PATIENT_EMAIL)
        # Title check
        booking_confirm_page.mustcontain('You new appointment is confirmed!')
Beispiel #5
0
def fetch_patients():
    return Patient.query().order(Patient.last_name)
Beispiel #6
0
def get_patient_from_user(user):
    '''returns the first patient profile liked to user. Returns None if user is not a patient'''
    if user:
        return Patient.query(Patient.user == user.key).get()
    else:
        return None
Beispiel #7
0
def get_patient_from_email(email):
    return Patient.query(Patient.email == email).get()
Beispiel #8
0
def fetch_patients():
    return Patient.query().order(Patient.last_name)
Beispiel #9
0
def get_patient_from_user(user):
    '''returns the first patient profile liked to user. Returns None if user is not a patient'''
    if user:
        return Patient.query(Patient.user == user.key).get()
    else:
        return None
Beispiel #10
0
def get_patient_from_email(email):
    return Patient.query(Patient.email == email).get()
Beispiel #11
0
 def create_test_patient(self):
     '''
         Create a test patient (and linked user) in the datastore
     '''
     user_created, new_user = User.create_user(self._TEST_PATIENT_EMAIL, password_raw=self._TEST_PATIENT_PASSWORD, roles=[auth.PATIENT_ROLE])
     self.assertTrue(user_created)
     tp = Patient()
     tp.created_on = datetime.now()
     tp.user = new_user.key
     tp.first_name = 'Pat'
     tp.last_name = 'Patient'
     tp.email = "*****@*****.**"
     tp.telephone = '514-123-1234'
     tp.terms_agreement = True
     tp.put() 
     
     new_user.language = 'fr'
     new_user.put()