-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsert.py
More file actions
116 lines (109 loc) · 3.11 KB
/
insert.py
File metadata and controls
116 lines (109 loc) · 3.11 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
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
import firebase_admin
# from firebase_admin import db
import base64, datetime
# from crypto import magichash
# ref = db.reference('vitask')
def insert_attendance(id, attend, q, sub_entry="attendance"):
status = True
try:
tut_ref = ref.child(sub_entry)
new_ref = tut_ref.child(sub_entry+"-"+id)
new_ref.set({
id: {
'Attendance': attend,
'Track': q
}
})
except:
status = False
finally:
return status
def insert_timetable(id, days, final_dict, sub_entry="timetable"):
status = True
try:
# tut_ref = ref.child(sub_entry)
# new_ref = tut_ref.child(sub_entry+"-"+id)
new_ref.set({
id: {
'Timetable': days,
'Credits': final_dict
}
})
except:
status = False
finally:
return status
def insert_acadhistory(id, acadHistory, curriculumDetails, sub_entry="acadhistory"):
status = True
try:
# tut_ref = ref.child(sub_entry)
new_ref = tut_ref.child(sub_entry+"-"+id)
new_ref.set({
id: {
'AcadHistory': acadHistory,
'CurriculumDetails': curriculumDetails
}
})
except:
status = False
finally:
return status
def insert_profile(id, profile, sub_entry="profile"):
status = True
try:
tut_ref = ref.child(sub_entry)
new_ref = tut_ref.child(sub_entry+"-"+id)
new_ref.set({
id: {
'Name': profile['name'],
'Branch': profile['branch'],
'Program': profile['program'],
'RegNo': profile['regNo'],
'AppNo': profile['appNo'],
'School': profile['school'],
'Email': profile['email'],
'ProctorName': profile['proctorName'],
'ProctorEmail': profile['proctorEmail'],
'API': profile['token']
}
})
except:
status = False
finally:
return status
def insert_account(id, profile, header_value, sub_entry="account"):
status = True
try:
date = datetime.datetime.now()
current_date = date.strftime("%d/%m/%Y, %H:%M:%S")
tut_ref = ref.child(sub_entry)
new_ref = tut_ref.child(sub_entry+"-"+id)
new_ref.set({
id: {
'X-VITASK-API': header_value,
'Name': profile['name'],
'RegNo': profile['regNo'],
'Account-Type': 'Free',
'API-Calls': 0,
'Start-Date': current_date,
'End-Date': 'N/A'
}
})
except:
status = False
finally:
return status
def insert_marks(id, marksDict, sub_entry="marks"):
status = True
try:
# tut_ref = ref.child(sub_entry)
new_ref = tut_ref.child(sub_entry+"-"+id)
new_ref.set({
id: {
'Marks': marksDict
}
})
except:
status = False
finally:
return status