def create_product(name, stock, warning, price): api.create('product', { 'name': name, 'stock': stock, 'warning': warning, 'price': price })
def create_mail(prid, stock): date = datetime.datetime.now().strftime("%d-%m-%Y_%H:%M:%S") api.create('mail', { 'datetime': date, 'prid': prid, 'stock': stock })
def badges(self, badges): for badgenumber in badges: if not badgenumber in self.badges: api.create('badge', { 'badgenumber': badgenumber, 'usid': self.usid })
def create_transaction(usid, amount, reason): date = datetime.datetime.now().strftime("%d-%m-%Y_%H:%M:%S") api.create('transaction', { 'datetime': date, 'usid': usid, 'amount': amount, 'reason': reason })
def buy(self, prid): product = get_product(prid)[prid] price = product['price'] date = datetime.datetime.now().strftime("%d-%m-%Y_%H:%M:%S") api.create('purchase', { 'datetime': date, 'prid': prid, 'usid': self.usid, 'amount': price }) update_product(prid, product['name'], product['stock']-1, product['warning'], product['price'])
def register(self, firstname, lastname, email, badgenumber): users = get_users() for user in users.items(): if user[1]['firstname'] == firstname and user[1]['lastname'] == lastname and user[1]['email'] == email: self.usid = user[0] break else: self.usid = api.create('user', { 'firstname': firstname, 'lastname': lastname, 'email': email, 'avatar': default_avatar })['usid'] api.create('badge', { 'badgenumber': badgenumber, 'usid': self.usid })
def otp(self): date = datetime.datetime.now().strftime("%d-%m-%Y_%H:%M:%S") otid = api.create('otp', { 'datetime': date, 'otp': random.randint(100000, 999999), 'usid': self.usid })['otid'] otp = api.get('otp', { 'otid': otid }) return dict(filter(lambda x: x[0] != 'success', otp.items()))[otid]['otp']
def root_api_create(table): content = core.create(table, request.form) return jsonify(content), 200 if content['success'] else 406