Exemplo n.º 1
0
 def get(self):
   email = get_user_email()
   if email and is_user_admin():
     page_params = {
       'user_email': email,
       'deliverers': Deliverer.get_all_deliverers(),
       'login_url': users.create_login_url('/home'),
       'logout_url': users.create_logout_url('/home')
     }
     render_template(self, 'adminmanagedeliverers_table.html', page_params)
Exemplo n.º 2
0
 def get(self):
     email = get_user_email()
     if email and is_user_admin():
         page_params = {
             'user_email': email,
             'deliverers': Deliverer.get_all_deliverers(),
             'login_url': users.create_login_url('/home'),
             'logout_url': users.create_logout_url('/home')
         }
         render_template(self, 'adminmanagedeliverers_table.html',
                         page_params)
Exemplo n.º 3
0
 def post(self):
     email = get_user_email()
     if email and is_user_admin():
         # get params from post request
         data = json.loads(self.request.body)
         name = data["name"]
         personToFire = Deliverer.get_by_name(name)
         if personToFire:
             personToFire.key.delete()
             # email the deliverer
             emailsender.send_fire_email(personToFire.email, personToFire)
     else:
         self.redirect('/home')
Exemplo n.º 4
0
 def post(self):
   email = get_user_email()
   if email and is_user_admin():
     # get params from post request
     data = json.loads(self.request.body)
     name = data["name"]
     personToFire = Deliverer.get_by_name(name)
     if personToFire:
       personToFire.key.delete()
       # email the deliverer
       emailsender.send_fire_email(personToFire.email, personToFire)
   else:
     self.redirect('/home')
Exemplo n.º 5
0
 def post(self):
     email = get_user_email()
     if email and is_user_admin():
         # get params from post request
         data = json.loads(self.request.body)
         name = data["name"]
         orderId = int(data["orderId"])
         deliverer = Deliverer.get_by_name(name)
         if deliverer:
             order = ndb.Key("BeerOrder", orderId).get()
             if order:
                 # check if order already has a deliverer
                 oldD = order.get_deliverer()
                 if oldD:
                     oldD.unassign_job()
                 deliverer.assign_job(order)
     else:
         self.redirect('/home')
Exemplo n.º 6
0
 def post(self):
   email = get_user_email()
   if email and is_user_admin():
     # get params from post request
     data = json.loads(self.request.body)
     name = data["name"]
     orderId = int(data["orderId"])
     deliverer = Deliverer.get_by_name(name)
     if deliverer:
       order = ndb.Key("BeerOrder", orderId).get()
       if order:
         # check if order already has a deliverer
         oldD = order.get_deliverer()
         if oldD:
           oldD.unassign_job()
         deliverer.assign_job(order)
   else:
     self.redirect('/home')
Exemplo n.º 7
0
 def post(self):
     email = get_user_email()
     if email and is_user_admin():
         # get params from post request
         data = json.loads(self.request.body)
         name = data["name"]
         email = data["email"]
         salary = float(data["salary"])
         # do not hire a person with same name
         if Deliverer.get_by_name(name):
             return
         else:
             boy = Deliverer()
             boy.name = name
             boy.email = email
             boy.salary = salary
             boy.put()
             # email the deliverer
             emailsender.send_hire_email(boy.email, boy)
     else:
         self.redirect('/home')
Exemplo n.º 8
0
 def post(self):
   email = get_user_email()
   if email and is_user_admin():
     # get params from post request
     data = json.loads(self.request.body)
     name = data["name"]
     email = data["email"]
     salary = float(data["salary"])
     # do not hire a person with same name
     if Deliverer.get_by_name(name):
       return
     else:
       boy = Deliverer()
       boy.name = name
       boy.email = email
       boy.salary = salary
       boy.put()
       # email the deliverer
       emailsender.send_hire_email(boy.email, boy)
   else:
     self.redirect('/home')