Esempio n. 1
0
 def get(self):
     self.decorateHeaders()
     self.user = users.get_current_user()
     if self.user:  #logged in
         query = Employee.get_by_id(self.user.nickname())
         if query:  #account has been created
             self.response.headers['Content-Type'] = 'application/json'
             json_dict = Employee.toJson(query)
             json_dict["logout_link"] = users.create_logout_url(
                 self.request.uri)
             self.response.out.write(json.dumps(json_dict))
         else:  #no account, create account
             if self.request.get('isManager') == "true":  #is manager
                 new_employee = Employee(
                     id=self.user.nickname(),
                     isManager=True,
                 )
             else:  #employee
                 new_employee = Employee(
                     id=self.user.nickname(),
                     isManager=False,
                 )
             new_employee.put()
             self.redirect('/')
     else:
         self.redirect('/')  #go back to landing to login
Esempio n. 2
0
 def get(self):
     self.user = users.get_current_user()
     if self.user:  #if logged in
         query = Employee.get_by_id(self.user.nickname())
         if query:  #account created
             self.render_template('index.html', {})
         else:
             self.redirect('/getcurrentuser')
     else:
         self.render_template('landing.html', {})
Esempio n. 3
0
 def post(self):
     try:
         name = self.request.get('name')
         mobile = self.request.get('mobile')
         email = self.request.get('email')
         _id = self.request.get('id')
         if _id !='':
             employee = Employee.get_by_id(int(_id))
             employee.name = name
             employee.mobile_number = mobile
             employee.email = email
             employee.save()
         else:                            
             employee = Employee(name=name, mobile_number = mobile, email = email)
             employee.put()
         result_dict = {'success':True}
     except:
         result_dict = {'success':False}        
     self.response.headers['Content-Type'] = 'application/json'
     self.response.out.write(json.dumps(result_dict))