Exemple #1
0
def create_product(name, stock, warning, price):
    api.create('product', {
        'name': name,
        'stock': stock,
        'warning': warning,
        'price': price
    })
Exemple #2
0
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
    })
Exemple #3
0
 def badges(self, badges):
     for badgenumber in badges:
         if not badgenumber in self.badges:
             api.create('badge', {
                 'badgenumber': badgenumber,
                 'usid': self.usid
             })
Exemple #4
0
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
    })
Exemple #5
0
 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'])
Exemple #6
0
 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
     })
Exemple #7
0
 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']
Exemple #8
0
def root_api_create(table):
    content = core.create(table, request.form)
    return jsonify(content), 200 if content['success'] else 406