Ejemplo n.º 1
0
    def post(self):
        logging.info('ProfilePage posted')
        #Look for existing profile based on Users' email
        doctor_key = ndb.Key('Doctor', self.user.email())
        doctor = doctor_key.get()
        if not doctor:
            #Profile doesn't yet exist, create a new Doctor with default values
            doctor = models.Doctor(key=ndb.Key("Doctor", self.user.email()))

        #Update the user controll
        doctor.username = self.user.email()
        doctor.notifyEmail = self.request.get('notifyEmail')
        doctor.bio = self.request.get('bio')
        doctor.designation = self.request.get('designation')
        doctor.organization = self.request.get('organization')
        doctor.field = self.request.get('field')
        doctor.specialization = self.request.get('specialization')
        doctor.idNumber = int(self.request.get('idNumber'))
        doctor.province = self.request.get('province')
        doctor.city = self.request.get('city')
        doctor.gender = self.request.get('gender')
        doctor.contactNumber = self.request.get('contactNumber')
        doctor.mobileNumber = self.request.get('mobileNumber')
        #Commit our updates to the datastore
        doctor.put()
        self.redirect('/profile')
Ejemplo n.º 2
0
    def get(self):
        logging.info('RegisterPage class requested')
        #-------------------------------------------------------------------
        #Look for existing profile based on User's email
        doctor_key = ndb.Key('Doctor', self.user.email())
        doctor = doctor_key.get()

        self.template_values['svg'] = {'facebook': 'public/svg/facebook.svg'}
        self.template_values['svg1'] = {'google': 'public/svg/google.svg'}
        self.template_values['svg2'] = {'twitter': 'twitter.svg'}

        if doctor:
            template = jinja_environment.get_template(
                'views/registered.template')
            self.response.out.write(template.render(self.template_values))

        else:
            #Profile doesn't yet exist, create a new Doctor with default values
            newKey = ndb.Key("Doctor", self.user.email())
            doctor = models.Doctor(key=newKey)
            #Add the doctor model to our template values for rendering
            self.template_values['doctor'] = doctor
            #--------------------------------------------------------------------
            template = jinja_environment.get_template(
                'views/register.template')
            self.response.out.write(template.render(self.template_values))