6
6
render_template_string ,
7
7
jsonify ,
8
8
render_template ,
9
+ make_response ,
9
10
)
11
+
10
12
import pymysql .cursors
11
13
import json
12
14
import html as html_lib
@@ -139,6 +141,7 @@ def fileset():
139
141
<a href="{{{{ url_for('ready_for_review') }}}}">Ready for review</a>
140
142
<a href="{{{{ url_for('fileset_search') }}}}">Fileset Search</a>
141
143
<a href="{{{{ url_for('logs') }}}}">Logs</a>
144
+ <a href="{{{{ url_for('config') }}}}">Config</a>
142
145
</div>
143
146
</nav>
144
147
<h2 style="margin-top: 80px;"><u>Fileset: { id } </u></h2>
@@ -502,6 +505,7 @@ def merge_fileset(id):
502
505
<a href="{{{{ url_for('ready_for_review') }}}}">Ready for review</a>
503
506
<a href="{{{{ url_for('fileset_search') }}}}">Fileset Search</a>
504
507
<a href="{{{{ url_for('logs') }}}}">Logs</a>
508
+ <a href="{{{{ url_for('config') }}}}">Config</a>
505
509
</div>
506
510
</nav>
507
511
<h2 style="margin-top: 80px;">Search Results for '{ search_query } '</h2>
@@ -549,6 +553,7 @@ def merge_fileset(id):
549
553
<a href="{{ url_for('ready_for_review') }}">Ready for review</a>
550
554
<a href="{{ url_for('fileset_search') }}">Fileset Search</a>
551
555
<a href="{{ url_for('logs') }}">Logs</a>
556
+ <a href="{{ url_for('config') }}">Config</a>
552
557
</div>
553
558
</nav>
554
559
<h2 style="margin-top: 80px;">Search Fileset to Merge</h2>
@@ -616,6 +621,7 @@ def possible_merge_filesets(id):
616
621
<a href="{{{{ url_for('ready_for_review') }}}}">Ready for review</a>
617
622
<a href="{{{{ url_for('fileset_search') }}}}">Fileset Search</a>
618
623
<a href="{{{{ url_for('logs') }}}}">Logs</a>
624
+ <a href="{{{{ url_for('config') }}}}">Config</a>
619
625
</div>
620
626
</nav>
621
627
<h2 style="margin-top: 80px;">Possible Merges for fileset-'{ id } '</h2>
@@ -818,6 +824,7 @@ def highlight_differences(source, target):
818
824
<a href="{{ url_for('ready_for_review') }}">Ready for review</a>
819
825
<a href="{{ url_for('fileset_search') }}">Fileset Search</a>
820
826
<a href="{{ url_for('logs') }}">Logs</a>
827
+ <a href="{{ url_for('config') }}">Config</a>
821
828
</div>
822
829
</nav>
823
830
<h2 style="margin-top: 80px;">Confirm Merge</h2>
@@ -1368,6 +1375,34 @@ def mark_as_full(id):
1368
1375
return redirect (f"/fileset?id={ id } " )
1369
1376
1370
1377
1378
+ @app .route ("/config" , methods = ["GET" , "POST" ])
1379
+ def config ():
1380
+ """
1381
+ Stores the user configurations in the cookies
1382
+ """
1383
+ if request .method == "POST" :
1384
+ items_per_page = request .form .get ("items_per_page" , "25" )
1385
+
1386
+ try :
1387
+ items_per_page_int = int (items_per_page )
1388
+ if items_per_page_int < 1 :
1389
+ items_per_page = "1"
1390
+ except ValueError :
1391
+ items_per_page = "25"
1392
+
1393
+ resp = make_response (redirect (url_for ("config" )))
1394
+ resp .set_cookie ("items_per_page" , items_per_page , max_age = 365 * 24 * 60 * 60 )
1395
+ return resp
1396
+
1397
+ items_per_page = int (request .cookies .get ("items_per_page" , "25" ))
1398
+
1399
+ return render_template ("config.html" , items_per_page = items_per_page )
1400
+
1401
+
1402
+ def get_items_per_page ():
1403
+ return int (request .cookies .get ("items_per_page" , "25" ))
1404
+
1405
+
1371
1406
@app .route ("/validate" , methods = ["POST" ])
1372
1407
def validate ():
1373
1408
error_codes = {
@@ -1506,8 +1541,19 @@ def games_list():
1506
1541
"engine.id" : "game.engine" ,
1507
1542
"game.id" : "fileset.game" ,
1508
1543
}
1544
+
1545
+ items_per_page = get_items_per_page ()
1546
+
1509
1547
return render_template_string (
1510
- create_page (filename , 25 , records_table , select_query , order , filters , mapping )
1548
+ create_page (
1549
+ filename ,
1550
+ items_per_page ,
1551
+ records_table ,
1552
+ select_query ,
1553
+ order ,
1554
+ filters ,
1555
+ mapping ,
1556
+ )
1511
1557
)
1512
1558
1513
1559
@@ -1524,8 +1570,11 @@ def logs():
1524
1570
"user" : "log" ,
1525
1571
"text" : "log" ,
1526
1572
}
1573
+ items_per_page = get_items_per_page ()
1527
1574
return render_template_string (
1528
- create_page (filename , 25 , records_table , select_query , order , filters )
1575
+ create_page (
1576
+ filename , items_per_page , records_table , select_query , order , filters
1577
+ )
1529
1578
)
1530
1579
1531
1580
@@ -1558,8 +1607,17 @@ def fileset_search():
1558
1607
"engine.id" : "game.engine" ,
1559
1608
"fileset.id" : "transactions.fileset" ,
1560
1609
}
1610
+ items_per_page = get_items_per_page ()
1561
1611
return render_template_string (
1562
- create_page (filename , 25 , records_table , select_query , order , filters , mapping )
1612
+ create_page (
1613
+ filename ,
1614
+ items_per_page ,
1615
+ records_table ,
1616
+ select_query ,
1617
+ order ,
1618
+ filters ,
1619
+ mapping ,
1620
+ )
1563
1621
)
1564
1622
1565
1623
0 commit comments