Ejemplo n.º 1
0
    def get(self, args=None):
        employee_id = self.request.get('employee_id')
        firstName = self.request.get('firstName')
        lastName = self.request.get('lastName')
        appointment = self.request.get('appointment')
        username = self.request.get('username')
        password = self.request.get('password')
        shiftHeadable = self.request.get('shiftHeadable')

        if not employee_id or not firstName or not lastName or not appointment or not username or not password:
            self.response.write("one or more fields are empty!")
            return

        employee = Employee.query(Employee.userName == username).get()

        if employee:
            self.response.write('This username already exist!')
            return

        employee = Employee()
        employee.workerID = employee_id
        employee.firstName = firstName
        employee.lastName = lastName
        employee.userName = username
        employee.setPassword(password)
        employee.percentJob = int(appointment)
        if shiftHeadable == 'true':
            employee.shiftHead = True
        elif shiftHeadable == 'false':
            employee.shiftHead = False

        employee.isManager = False
        employee.put()

        self.response.write(json.dumps({'status': 'OK'}))
Ejemplo n.º 2
0
	def get(self):
		userName = self.request.get('userName')
		password = self.request.get('password')
		employee = Employee.query(Employee.userName == userName).get()
		if not employee or not employee.checkPassword(password) or employee.isManager:
			self.response.write("Wrong username or password or you are manager")
			return
		
		self.response.set_cookie('our_token', str(employee.key.id()))
		self.response.write(json.dumps({'status':'OK'}))
Ejemplo n.º 3
0
    def get(self):
        userName = self.request.get('userName')
        password = self.request.get('password')
        employee = Employee.query(Employee.userName == userName).get()
        if not employee or not employee.checkPassword(
                password) or employee.isManager:
            self.response.write(
                "Wrong username or password or you are manager")
            return

        self.response.set_cookie('our_token', str(employee.key.id()))
        self.response.write(json.dumps({'status': 'OK'}))
	def get(self, args=None):
		employee_id = self.request.get('employee_id')
		if not employee_id:
			self.response.write("the id field is empty!")
			return
		
		employee = Employee.query(Employee.workerID == employee_id).get()
		
		if not employee:
			self.response.write("there is no employee with this id number!")
			return
			
		employee.key.delete()
		
		self.response.write(json.dumps({'status':'OK'}))
Ejemplo n.º 5
0
    def get(self, args=None):
        employee_id = self.request.get('employee_id')
        if not employee_id:
            self.response.write("the id field is empty!")
            return

        employee = Employee.query(Employee.workerID == employee_id).get()

        if not employee:
            self.response.write("there is no employee with this id number!")
            return

        employee.key.delete()

        self.response.write(json.dumps({'status': 'OK'}))
Ejemplo n.º 6
0
    def get(self):

        self.response.headers['Content-Type'] = 'application/json'
        employee_query = Employee.query().order(Employee.name)
        employees = employee_query.fetch()
        employee_list = []

        for employee in employees:
            date = employee.creation_date
            date_string = date.strftime('%m/%d/%Y')
            employee_list.append({
                'id': employee.key.id(),
                'name': employee.name,
                'phone': employee.phone,
                'carrier': employee.carrier,
                'bartending': employee.bartending,
                'creation_date': date_string
            })

        self.response.out.write(json.dumps(employee_list))
	def get(self, args=None):
		employee_id = self.request.get('employee_id')
		firstName = self.request.get('firstName')
		lastName = self.request.get('lastName')
		appointment = self.request.get('appointment')
		username = self.request.get('username')
		password = self.request.get('password')
		shiftHeadable = self.request.get('shiftHeadable')
		
		
		if not employee_id or not firstName or not lastName or not appointment or not username or not password:
			self.response.write("one or more fields are empty!")
			return
		
		employee = Employee.query(Employee.userName == username).get()
		
		if employee:
			self.response.write('This username already exist!')
			return
			
		employee = Employee()
		employee.workerID = employee_id
		employee.firstName = firstName
		employee.lastName = lastName
		employee.userName = username
		employee.setPassword(password)
		employee.percentJob = int(appointment)
		if shiftHeadable == 'true':
			employee.shiftHead = True
		elif shiftHeadable == 'false':		
			employee.shiftHead = False
	
			
		employee.isManager = False
		employee.put()
		
		self.response.write(json.dumps({'status':'OK'}))
    def post(self):

        json_string = self.request.body
        dict_object = json.loads(json_string)

        employee_name = dict_object['employeeName']
        employee_phone = dict_object['employeePhone']
        employee_carrier = dict_object['employeeCarrier']
        employee_bartending = bool(dict_object['employeeBartending'])

        same_name = Employee.query(Employee.name == employee_name).fetch()

        if not same_name:

            #NDB storing
            employee = Employee(name=employee_name,
                                phone=employee_phone,
                                carrier=employee_carrier,
                                bartending=employee_bartending)
            employee_key = employee.put()
            employee_id = str(employee_key.id())

            res = {
                "msg": "Employee successfully added",
                "success": True,
                "employee_id": employee_id
            }
            self.response.out.write(json.dumps(res))

        else:
            res = {
                "msg":
                "That employee already exists in the inventory or something went wrong. Please try again.",
                "success": False
            }
            self.response.out.write(json.dumps(res))
Ejemplo n.º 9
0
	def text_order(self, order_beers, user_id):
		account_sid = ""
		auth_token = ""
		client = Client(account_sid, auth_token)
		
		customers = User.query(User.fb_user_id == user_id).fetch()
		for customer in customers:
			customer_name = customer.name
		beer_list = ""

		for beer in order_beers:
			beer_name = Beer.get_by_id(int(beer['id'])).name
			beer_quantity = beer['quantity']
			beer = '\n{} x{}'.format(beer_name, beer_quantity)
			beer_list += beer;

		msg_body = 'Beer Order for {}! {}'.format(customer_name, beer_list)		

		bartending_employees = Employee.query(Employee.bartending == True).fetch()

		for employee in bartending_employees:
			msg_to = "+1"+employee.phone
			
			rv = client.messages.create(to=msg_to, from_="+15126400776 ",body=msg_body)