@@ -186,13 +186,13 @@ def submit():
186
186
), 200
187
187
188
188
189
- def get_quote_query (speaker : str = "" , submitter : str = "" , include_hidden : bool = False ):
189
+ def get_quote_query (speaker : str = "" , submitter : str = "" , last_id = None , include_hidden : bool = False ):
190
190
"""Return a query based on the args, with vote count attached to the quotes"""
191
191
# Get all the quotes with their votes
192
192
quote_query = db .session .query (Quote ,
193
193
func .sum (Vote .direction ).label ('votes' )).outerjoin (Vote ).group_by (Quote )
194
194
# Put the most recent first
195
- quote_query = quote_query .order_by (Quote .quote_time .desc ())
195
+ quote_query = quote_query .order_by (Quote .id .desc ())
196
196
# Filter hidden quotes
197
197
if not include_hidden :
198
198
quote_query = quote_query .filter (Quote .hidden == False )
@@ -201,53 +201,43 @@ def get_quote_query(speaker: str = "", submitter: str = "", include_hidden: bool
201
201
quote_query = quote_query .filter (Quote .speaker == request .args .get ('speaker' ))
202
202
if request .args .get ('submitter' ):
203
203
quote_query = quote_query .filter (Quote .submitter == request .args .get ('submitter' ))
204
+ if last_id :
205
+ quote_query = quote_query .filter (Quote .id < last_id )
204
206
return quote_query
205
207
206
208
# display first 20 stored quotes
207
209
@app .route ('/storage' , methods = ['GET' ])
208
210
@auth .oidc_auth
209
- def get ():
211
+ def default_get ():
212
+ return redirect ("/storage/1" )
213
+
214
+ # display first 20 stored quotes
215
+ @app .route ('/storage/<page>' , methods = ['GET' ])
216
+ @auth .oidc_auth
217
+ def get (page ):
210
218
"""
211
219
Show submitted quotes, only showing first 20 initially
212
220
"""
213
221
metadata = get_metadata ()
214
222
223
+ page = int (page )
224
+
215
225
# Get the most recent 20 quotes
216
226
quotes = get_quote_query (speaker = request .args .get ('speaker' ),
217
- submitter = request .args .get ('submitter' )).limit (20 ).all ()
227
+ submitter = request .args .get ('submitter' )).offset ((page - 1 )* 20 ).limit (20 ).all ()
228
+
229
+ last_id = list (quotes )[- 1 ][0 ].id
230
+
231
+ last_id = list (quotes )[- 1 ][0 ].id
218
232
219
233
#tie any votes the user has made to their uid
220
234
user_votes = Vote .query .filter (Vote .voter == metadata ['uid' ]).all ()
221
235
return render_template (
222
236
'bootstrap/storage.html' ,
223
237
quotes = quotes ,
224
238
metadata = metadata ,
225
- user_votes = user_votes
226
- )
227
-
228
-
229
- # display ALL stored quotes
230
- @app .route ('/additional' , methods = ['GET' ])
231
- @auth .oidc_auth
232
- def additional_quotes ():
233
- """
234
- Show beyond the first 20 quotes
235
- """
236
-
237
- metadata = get_metadata ()
238
-
239
- # Get all the quotes
240
- quotes = get_quote_query (speaker = request .args .get ('speaker' ),
241
- submitter = request .args .get ('submitter' )).all ()
242
-
243
- #tie any votes the user has made to their uid
244
- user_votes = db .session .query (Vote ).filter (Vote .voter == metadata ['uid' ]).all ()
245
-
246
- return render_template (
247
- 'bootstrap/additional_quotes.html' ,
248
- quotes = quotes [20 :],
249
- metadata = metadata ,
250
- user_votes = user_votes
239
+ user_votes = user_votes ,
240
+ page = page
251
241
)
252
242
253
243
@app .route ('/report/<quote_id>' , methods = ['POST' ])
0 commit comments