-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathissuer_ui.py
More file actions
77 lines (68 loc) · 2.77 KB
/
Copy pathissuer_ui.py
File metadata and controls
77 lines (68 loc) · 2.77 KB
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
import requests
import os
import time as t
from rich import print
from rich.panel import Panel
from rich.tree import Tree
from rich.prompt import Prompt
if os.name == 'nt':
cls = lambda : os.system("cls")
else:
cls = lambda : os.system("clear")
menu = Tree("MENU")
menu.add("Issue a Certy")
menu.add("Quit")
data = {
"inWhat":'',
"achievement":'',
"who":'',
"fromWhere":'',
"heldAt":'',
"issuer":'Certy'
}
def renderCertPanel():
panel = Panel(f"Event: {data['inWhat']}\nAchievement: {data['achievement']}\nIndividual: {data['who']}\nHeld At: {data['heldAt']}\nFrom Where: {data['fromWhere']}", title="Certificate of Achievement", subtitle=f"Issued by {data['issuer']}", subtitle_align="right")
print(panel)
def main():
while True:
cls()
print(Panel(menu,title="Certy :tulip:"))
ch = Prompt.ask("Action", choices=["issue","x"])
if ch == "issue":
while True:
cls()
renderCertPanel()
opt = Prompt.ask("Edit - [red]e[/red]vent • [red]a[/red]chievement • [red]p[/red]erson • [red]h[/red]eld at • [red]i[/red]ssuer • [red]f[/red]romWhere | [red]s[/red]ubmit • [red]q[/red]uit",choices=['e','a','p','h','i','f', 's','q'])
if opt == 'e':
data['inWhat'] = Prompt.ask("Event Name",default="Deep Sleepers Award")
if opt == 'a':
data['achievement'] = Prompt.ask("Achievement",default="Rank 1")
if opt == 'p':
data['who'] = Prompt.ask("Name of holder",default="Keanu Reeves")
if opt == 'h':
data['heldAt'] = Prompt.ask("Event Venue",default="Their Bed")
if opt == 'i':
data['issuer'] = Prompt.ask("Issued By",default="Certy")
if opt == 'f':
data['fromWhere'] = Prompt.ask("From where", default="Bangalore")
if opt == 's':
cls()
res = requests.post("http://localhost:6969/issue", json=data)
if res.status_code == 200:
# res contains a pdf
# save it to a file
# and open it.
with open("certy.pdf", "wb") as f:
f.write(res.content)
os.system("open certy.pdf") # only works in macos
print(Panel(":tulip: Certy has been Issued :tulip:", style="green"))
print("Press [green]ENTER[/green] to continue")
input()
pass
if opt == 'q':
break
if ch == 'x':
cls()
break
if __name__ == "__main__":
main()