-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
895 lines (681 loc) · 24.9 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
__author__ = 'dsantos'
import re
from mysql.connector import Connect, errors
from datetime import datetime
from flask.ext.bcrypt import Bcrypt
from flask import make_response, redirect, url_for, request, flash
HOST = 'us-cdbr-iron-east-02.cleardb.net'
USER = 'b40c9dc05ad587'
PASSWORD = 'cc61f936'
DATABASE = 'heroku_a7fad87285a8099'
class Database:
"""Database model with init method to set the database."""
def __init__(self):
pass
@staticmethod
def create_database():
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD)
except:
raise ConnectionError
cur = conn.cursor()
query = 'CREATE DATABASE IF NOT EXISTS `pytry`'
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
conn.close()
@staticmethod
def create_business_table():
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except:
raise ConnectionError
cur = conn.cursor()
query = ("CREATE TABLE IF NOT EXISTS `business` (`id` INT(11) NOT NULL AUTO_INCREMENT, "
"`name` VARCHAR(255) NOT NULL, `street` VARCHAR(255) NOT NULL,"
"`city` VARCHAR(255) NOT NULL, `state` VARCHAR(255) NOT NULL,"
"`zipcode` VARCHAR(255) NOT NULL, `phone` VARCHAR(255) NOT NULL,"
"`email` VARCHAR(255) NOT NULL, `manager` VARCHAR(255) NOT NULL, PRIMARY KEY(`id`));")
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
conn.close()
@staticmethod
def create_item_table():
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except:
raise ConnectionError
cur = conn.cursor()
query = ("CREATE TABLE IF NOT EXISTS `items` (`id` INT(11) NOT NULL AUTO_INCREMENT, "
"`description` VARCHAR(255), `market_price` DECIMAL(6,2) NOT NULL, "
"`costumer_price` DECIMAL(6,2) NOT NULL, `distributor_price` DECIMAL(6,2) NOT NULL, "
"`quantity` INT(11) NOT NULL, PRIMARY KEY(`id`));")
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
conn.close()
@staticmethod
def create_costumer_table():
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except:
raise ConnectionError
cur = conn.cursor()
query = ("CREATE TABLE IF NOT EXISTS `costumers` (`id` INT(11) NOT NULL AUTO_INCREMENT, "
"`name` VARCHAR(255) NOT NULL, `street` VARCHAR(255) NOT NULL, `city` VARCHAR(255) NOT NULL,"
"`state` VARCHAR(255) NOT NULL, `zipcode` VARCHAR(255) NOT NULL, `phone` VARCHAR(255) NOT NULL,"
"`email` VARCHAR(255) NOT NULL, PRIMARY KEY(`id`));")
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
conn.close()
@staticmethod
def create_employees_table():
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except:
raise ConnectionError
cur = conn.cursor()
query = ("CREATE TABLE IF NOT EXISTS `employees`(`id` INT(11) NOT NULL AUTO_INCREMENT,"
"`name` VARCHAR(255) NOT NULL, `street` VARCHAR(255) NOT NULL, `city` VARCHAR(255) NOT NULL,"
"`state` VARCHAR(255) NOT NULL, `zipcode` VARCHAR(255) NOT NULL, `phone` VARCHAR(255) NOT NULL,"
"`email` VARCHAR(255) NOT NULL, `join_date` DATE NOT NULL, PRIMARY KEY(`id`));")
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
conn.close()
@staticmethod
def create_invoice_table():
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except:
raise ConnectionError
cur = conn.cursor()
query = ("CREATE TABLE IF NOT EXISTS `invoices`(`id` INT(11) NOT NULL AUTO_INCREMENT,"
"`invoice_id` VARCHAR(255),`costumer` VARCHAR(255) NOT NULL, `date` DATE NOT NULL,"
"seller VARCHAR(255) NOT NULL, `items` TEXT NOT NULL, `total` DECIMAL(6,2),"
"is_pending BOOLEAN NOT NULL, PRIMARY KEY(`id`));")
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
conn.close()
@staticmethod
def create_admin_table():
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except:
raise ConnectionError
cur = conn.cursor()
query = ("CREATE TABLE IF NOT EXISTS `administrator`(`id` INT(11) NOT NULL AUTO_INCREMENT,"
"`name` VARCHAR(255) NOT NULL, `user_name` VARCHAR(255) NOT NULL, `password` VARCHAR(255) NOT NULL,"
"`street` VARCHAR(255) NOT NULL, `city` VARCHAR(255) NOT NULL,"
"`state` VARCHAR(255) NOT NULL, `zipcode` VARCHAR(255) NOT NULL, `phone` VARCHAR(255) NOT NULL,"
"`email` VARCHAR(255) NOT NULL, `join_date` DATE NOT NULL, PRIMARY KEY(`id`));")
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
conn.close()
def init(self):
self.create_database()
self.create_costumer_table()
self.create_item_table()
self.create_business_table()
self.create_invoice_table()
self.create_employees_table()
self.create_admin_table()
class Business:
"""This is the business class"""
def __init__(self, name='', phone='', manager='', email='', address={}):
self.name = name
self.phone = phone
self.manager = manager
self.email = email
self.address = address
def create_business(self):
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except ConnectionError as e:
print(e)
return False
cur = conn.cursor()
query = ("INSERT INTO `business`(name, street, city, state, zipcode, phone, email, manager)"
"VALUES ('{}', '{}', '{}', '{}', '{}', '{}', '{}', '{}')"
"".format(self.name, self.address['street'], self.address['city'], self.address['state'],
self.address['zipcode'], self.phone, self.email, self.manager))
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
return False
conn.commit()
conn.close()
return True
@staticmethod
def erase_business(id):
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except ConnectionError as e:
print(e)
return False
cur = conn.cursor()
query = ("DELETE FROM business WHERE '{}' = id".format(id))
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
return False
conn.commit()
conn.close()
return True
def business_info(self):
full_info = ('Name: ' + self.name + ' Address: ' + self.address['street'] + ' ' + self.address['city'] + ', ' +
self.address['state'] + ' ' + self.address['zipcode'] + ' Phone: ' + self.phone + ' Manager: ' +
self.manager + ' Email: ' + self.email)
return full_info
class Costumer:
"""This is the costumer class"""
def __init__(self, name='', phone='', email='', address={}):
self.name = name
self.phone = phone
self.email = email
self.address = address
def create_costumer(self):
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except ConnectionError as e:
print(e)
return False
cur = conn.cursor()
query = ("INSERT INTO `costumers`(name, street, city, state, zipcode, phone, email)"
"VALUES ('{}', '{}', '{}', '{}', '{}', '{}', '{}')"
"".format(self.name, self.address['street'], self.address['city'], self.address['state'],
self.address['zipcode'], self.phone, self.email))
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
return False
conn.commit()
conn.close()
return True
@staticmethod
def erase_costumer(id):
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except ConnectionError as e:
print(e)
return False
cur = conn.cursor()
query = ("DELETE FROM costumers WHERE '{}' = id".format(id))
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
return False
conn.commit()
conn.close()
return True
class Employee:
""" This is Employee class """
def __init__(self, name='', phone='', email='', address={}):
self.name = name
self.phone = phone
self.email = email
self.address = address
self.join_date = datetime.now().date()
def create_employee(self):
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except ConnectionError as e:
print(e)
return False
cur = conn.cursor()
query = ("INSERT INTO `employees`(name, street, city, state, zipcode, phone, email, join_date)"
"VALUES ('{}', '{}', '{}', '{}', '{}', '{}', '{}', '{}')"
"".format(self.name, self.address['street'], self.address['city'], self.address['state'],
self.address['zipcode'], self.phone, self.email, self.join_date))
if self.name == "" or self.phone == "" or self.email == "" or self.address == "":
raise Exception
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
return False
conn.commit()
conn.close()
return True
@staticmethod
def erase_employee(id):
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except ConnectionError as e:
print(e)
return False
cur = conn.cursor()
query = ("DELETE FROM employees WHERE '{}' = id".format(id))
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
return False
conn.commit()
conn.close()
return True
@staticmethod
def get_employees():
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except ConnectionError as e:
print(e)
return False
cur = conn.cursor()
query = "SELECT * FROM employees"
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
return None
response = cur.fetchall()
conn.close()
return response
def send_email(self, mail, msg, app):
with app.app_context():
msg.subject = "Welcome to NapCorps!"
msg.sender = "PyTry Manager <daniel.santos@napcorps.com>"
msg.recipients = [self.email]
msg.html = """
<html>
<head>
<title></title>
</head>
<body>
<p>This is a confirmation email from PyTry. An administrator added you to the employee list.</p>
</body>
</html>
"""
try:
mail.send(msg)
except Exception as e:
print(e)
raise Exception
return 'Success'
class Item:
"""This is the item class"""
def __init__(self, description='', market_price=0, costumer_price=0, distributor_price=0, quantity=0):
self.description = description
self.market_price = market_price
self.costumer_price = costumer_price
self.distributor_price = distributor_price
self.quantity = quantity
def add_item(self):
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except ConnectionError as e:
print(e)
return False
cur = conn.cursor()
query = ("INSERT INTO `items`(description, market_price, costumer_price, distributor_price, quantity)"
"VALUES('{}', '{}', '{}', '{}', '{}')"
"".format(self.description, self.market_price, self.costumer_price, self.distributor_price,
self.quantity))
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
return False
conn.commit()
conn.close()
return True
@staticmethod
def get_items():
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except ConnectionError as e:
print(e)
return False
cur = conn.cursor()
query = "SELECT * FROM items"
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
return None
response = cur.fetchall()
conn.close()
return response
class Invoice:
def __init__(self, costumer={}, date='', seller='', items='', total=0, is_pending=False, invoice_id=''):
self.info = costumer
self.date = date
self.seller = seller
self.items = items
self.total = total
self.pending = is_pending
self.invoice_id = invoice_id
def create_invoice(self):
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except ConnectionError as e:
print(e)
return False
cur = conn.cursor()
query = ("INSERT INTO `invoices`(invoice_id, costumer, date, seller, items, total, is_pending)"
"VALUES ('{}', '{}', '{}', '{}', '{}', '{}', '{}')"
"".format(self.invoice_id, self.info, self.date, self.seller, self.items, self.total, self.pending))
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
return False
conn.commit()
conn.close()
return True
def delete_invoice(self):
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except ConnectionError as e:
print(e)
return False
cur = conn.cursor()
query = "DELETE FROM `invoices` WHERE `invoice_id` = '{}'".format(self.invoice_id)
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
return False
conn.commit()
conn.close()
return True
@staticmethod
def get_price_category(id, category):
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except ConnectionError as e:
print(e)
return False
cur = conn.cursor()
query = ("SELECT `{}` FROM items WHERE id = '{}'".format(category, id))
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
return None
response = cur.fetchall()
conn.close()
return response[0][0]
@staticmethod
def get_item_description_by_id(id):
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except ConnectionError as e:
print(e)
return False
cur = conn.cursor()
query = ("SELECT `description` FROM items WHERE id = '{}'".format(id))
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
return None
response = cur.fetchall()
conn.close()
return response[0][0]
@staticmethod
def get_ten_invoices():
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except ConnectionError as e:
print(e)
return False
cur = conn.cursor()
query = ("SELECT * FROM invoices ORDER BY `invoice_id` DESC LIMIT 15".format(id))
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
return None
response = cur.fetchall()
conn.close()
return response
def get_invoice_by_id(self):
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except ConnectionError as e:
print(e)
return False
cur = conn.cursor()
query = ("SELECT * FROM invoices WHERE `invoice_id` = {}".format(self.invoice_id))
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
return None
response = cur.fetchall()
conn.close()
return response
@staticmethod
def get_pending_invoices():
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except ConnectionError as e:
print(e)
return False
cur = conn.cursor()
query = "SELECT * FROM invoices WHERE `is_pending` = 1"
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
return None
response = cur.fetchall()
conn.close()
return response
@staticmethod
def change_pending_status(invoce_num):
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except ConnectionError as e:
print(e)
return False
cur = conn.cursor()
query = ("SELECT `is_pending` FROM `invoices` "
"WHERE `invoice_id` = '{}'".format(invoce_num))
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
return None
response = cur.fetchall()
is_pending = response[0][0]
new_status = None
if is_pending == 1:
new_status = 0
elif is_pending == 0:
new_status = 1
query = ("UPDATE `invoices` SET `is_pending` = {} "
"WHERE invoice_id = '{}';".format(new_status, invoce_num))
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
return None
conn.commit()
conn.close()
return response
@staticmethod
def number_of_boxes_sold():
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except ConnectionError as e:
print(e)
return False
cur = conn.cursor()
query = "SELECT `items` FROM `invoices`"
cur.execute(query)
response = cur.fetchall()
num_of_boxes = 0
t = []
for invoice in response:
for items in invoice:
if 'Box' in items:
t.append(items.split(')('))
for x in t:
for i in x:
num_of_boxes += int(i.replace('(', '')[0])
return num_of_boxes
class Admin:
def __init__(self, name='', email='', user_name='', password='', phone='', join_date='', address={}):
self.name = name
self.email = email
self.user_name = user_name
self.password = password
self.phone = phone
self.address = address
self.join_date = join_date
def create_admin(self):
if not self.check_duplicate():
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except ConnectionError as e:
print(e)
return False
cur = conn.cursor()
bcrypt = Bcrypt()
query = ("INSERT INTO "
"`administrator`(name, user_name, password, street, city, state, zipcode, phone, email, join_date)"
"VALUES ('{}', '{}', '{}', '{}', '{}', '{}', '{}', '{}', '{}', '{}')"
"".format(self.name, self.user_name, bcrypt.generate_password_hash(self.password),
self.address['street'], self.address['city'], self.address['state'],
self.address['zipcode'], self.phone, self.email, self.join_date))
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
return False
conn.commit()
conn.close()
return True
return False
def check_duplicate(self):
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except ConnectionError as e:
print(e)
return False
cur = conn.cursor()
# Check if username exist
query = "SELECT * FROM `administrator` WHERE `user_name` = '{}'".format(self.user_name)
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
return False
response = cur.fetchall()
print(response)
# If so, return True
if response:
conn.close()
return True
# If not, check if email exists
query = "SELECT * FROM `administrator` WHERE `email` = '{}'".format(self.email)
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
return False
response = cur.fetchall()
print(response)
if response:
conn.close()
return True
conn.close()
# If not return False
return False
@staticmethod
def check_if_admin_exist():
"""This method is used to verify if at least one administrator has been setup."""
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except ConnectionError as e:
print(e)
return False
cur = conn.cursor()
query = "SELECT * FROM `administrator`"
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
return False
conn.close()
return cur.fetchall()
def auth_admin(self):
"""Authenticate administrator trying to login."""
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except ConnectionError as e:
print(e)
return False
cur = conn.cursor()
query = "SELECT `password` FROM `administrator` WHERE `user_name` = '{}'".format(self.user_name)
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
return False
response = cur.fetchall()
conn.close()
bcrypt = Bcrypt()
try:
return bcrypt.check_password_hash(response[0][0], self.password)
except IndexError:
return False
@staticmethod
def create_session(name, callback, key, time):
response = make_response(redirect(url_for(callback)))
response.set_cookie(name, key, time)
return response
class Security(Admin):
@staticmethod
def is_login(sk):
"""This method is used to verify if at least one administrator has been setup."""
try:
conn = Connect(host=HOST, user=USER, password=PASSWORD, database=DATABASE)
except ConnectionError as e:
print(e)
return False
cur = conn.cursor()
query = "SELECT * FROM `administrator`"
try:
cur.execute(query)
except errors.ProgrammingError as e:
print(e)
return False
conn.close()
response = cur.fetchall()
if response:
b = Bcrypt()
try:
return b.check_password_hash(request.cookies['admin_session'], sk)
except KeyError as e:
return False
else:
return True
if __name__ == '__main__':
# db = Database()
# db.init()
# admin = Admin()
# admin.user_name = 'dsantos'
# admin.password = 'Kila@toadsfla$1432'
# print(admin.auth_admin())
# sec = Security()
# print(sec.is_login('asdfasdfasdfasd'))
inv = Invoice()
inv.number_of_boxes_sold()