-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.py
86 lines (83 loc) · 3.07 KB
/
admin.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
from Books.Read_Info import *
from Books.Modify_Info import *
from Books.book import Book
from lib.issue_return import *
from pathlib import WindowsPath
from User_Management.user_management import *
values={1:"Add a book",
2:"Issue a book",
3:"Return a book",
4:"Search a book",
5:"List all books",
6:"Get book details",
7:"Delete all books",
8:"Remove a book",
9:"Create new user",
10:"List all users",
11:"Search User",
12:"See list of current issued",
13:"get_overdue_list",
14:"Exit",
}
def admin(database):
ch=1
while(True):
for i in sorted(values.keys()):
print("{i} - {val}".format(i=i,val=values[i]))
ch=int(input())
if values[ch]=="Add a book":
print("Press 1 for manual adding and 2 for excel file")
ch1=int(input())
if ch1==1:
print("Enter number of books")
num_of_books=int(input())
books=[]
for i in range(num_of_books):
title=input("Enter the title of the book: ")
author=input("Enter the author of the book: ")
quantity=input("Enter the quantity of the book: ")
books.append(Book(title,author,quantity))
add_book(database,books)
if ch1==2:
print("Enter the path of the excel file")
path=WindowsPath(input())
add_book_from_excel(database,path)
elif values[ch]=="Issue a book":
userid=input("Enter id")
id=int(input("Enter the id of the book: "))
issue_book(database,userid,id)
elif values[ch]=="Return a book":
userid=input("Enter id")
id=int(input("Enter the id of the book: "))
return_book(database,userid,id)
elif values[ch]=="Search a book":
search_book(database)
elif values[ch]=="List all books":
list_all_book(database,"admin")
elif values[ch]=="Get book details":
id=int(input("Enter book id"))
get_book_details(database,id)
elif values[ch]=="Remove a book":
remove_book(database)
elif values[ch]=="Create new user":
print("Enter user name for new user")
username=input()
print("Enter password for new user")
password=input()
print("Enter role for new user")
role=input()
from User_Management.User import USER
user=USER(username,password,role)
create_new_user(database,[user])
elif values[ch]=="List all users":
list_users(database)
elif values[ch]=="Search User":
search_user(database)
elif values[ch]=="See list of current issued":
get_list_issued(database)
elif values[ch]=="Exit":
break
elif values[ch]=="get_overdue_list":
get_overdue_list(database)
print("press key to continue")
input()