@@ -45,6 +45,27 @@ def shutdown():
45
45
return render ('layouts/shutdown.html' )
46
46
47
47
48
+ @app .route ('/create' , methods = ['POST' ])
49
+ def create ():
50
+ with open (sys .argv [1 ], 'w+' ) as csvfile :
51
+ fieldnames = [
52
+ 'ids' , 'student_name' , 'academics' , 'sports' , 'social'
53
+ ]
54
+ writer = csv .DictWriter (
55
+ csvfile , fieldnames = fieldnames
56
+ )
57
+
58
+ writer .writeheader ()
59
+ s ['swipe' ] = 1
60
+ print s ['swipe' ]
61
+ hriks (
62
+ 'Notification : New file created with name "%s" ' % (
63
+ sys .argv [1 ]
64
+ )
65
+ )
66
+ return redirect (url_for ('home' ))
67
+
68
+
48
69
# Controllers.
49
70
def write ():
50
71
try :
@@ -153,7 +174,19 @@ def cache_records():
153
174
154
175
@app .route ('/' , methods = ['GET' , 'POST' ])
155
176
def home ():
156
- return render ('pages/placeholder.home.html' )
177
+ try :
178
+ input_file = csv .DictReader (open (sys .argv [1 ]))
179
+ except Exception :
180
+ input_file = None
181
+ file = sys .argv [1 ]
182
+ print input_file
183
+ if input_file :
184
+ swipe = 1
185
+ s ['swipe' ] = swipe
186
+ else :
187
+ swipe = 0
188
+ s ['swipe' ] = swipe
189
+ return render ('pages/placeholder.home.html' , filename = file , swipe = swipe )
157
190
158
191
159
192
@app .route ('/delete' , methods = ['GET' , 'POST' ])
@@ -279,27 +312,21 @@ def addinfo():
279
312
student_name , academics , sports , social
280
313
)
281
314
s ['data' ] = data
282
- if 'delete_id' in s :
283
- hriks (
284
- 'Notification : %s successfully added to records \
285
- with ID %s and deleted ID %s due to minimum access' % (
286
- student_name , ids , s ['delete_id' ]
287
- )
288
- )
289
- else :
290
- hriks (
291
- 'Notification : %s successfully added to records \
292
- with ID %s' % (
293
- student_name , ids
294
- )
315
+ hriks (
316
+ 'Notification : %s successfully added to records \
317
+ with ID %s' % (
318
+ student_name , ids
295
319
)
320
+ )
296
321
s .pop ('delete_id' , None )
297
322
return redirect (url_for ('home' ))
298
323
return render ('forms/register.html' , form = form , ids = ids )
299
324
300
325
301
326
@app .route ('/search' , methods = ['GET' , 'POST' ])
302
327
def search ():
328
+ if 'swipe' in s :
329
+ swipe = s ['swipe' ]
303
330
if 'p' not in s :
304
331
s ['count' ] = count_dict
305
332
print s ['count' ]
@@ -333,7 +360,8 @@ def search():
333
360
hriks ('Notification : Invalid ID provided, Please provide ID' )
334
361
return redirect (url_for ('home' ))
335
362
return render (
336
- 'pages/placeholder.search.html' , match = match , search = search
363
+ 'pages/placeholder.search.html' , match = match , search = search ,
364
+ swipe = swipe
337
365
)
338
366
return render ('pages/placeholder.search.html' , search = search )
339
367
0 commit comments