|
63 | 63 | @app.route("/") |
64 | 64 | @auth.oidc_auth('default') |
65 | 65 | @audiophiler_auth |
66 | | -def home(auth_dict=None): |
| 66 | +def home_def(auth_dict=None): |
| 67 | + return redirect("/1") |
| 68 | + |
| 69 | +@app.route("/<int:page>") |
| 70 | +@auth.oidc_auth('default') |
| 71 | +@audiophiler_auth |
| 72 | +def home(page, auth_dict=None): |
67 | 73 | # Retrieve list of files for templating |
68 | | - db_files = File.query.all() |
| 74 | + rows = File.query.count() |
| 75 | + rows = int(rows // 10 + bool(rows % 10)) |
| 76 | + db_files = File.query.offset((page-1) * 10).limit(10).all() |
69 | 77 | harolds = get_harold_list(auth_dict["uid"]) |
70 | 78 | tour_harolds = get_harold_list("root") |
71 | 79 | is_rtp = ldap_is_rtp(auth_dict["uid"]) |
72 | 80 | is_eboard = ldap_is_eboard(auth_dict["uid"]) |
73 | 81 | return render_template("main.html", db_files=db_files, |
74 | 82 | get_date_modified=get_date_modified, s3_bucket=s3_bucket, |
75 | 83 | auth_dict=auth_dict, harolds=harolds, tour_harolds=tour_harolds, |
76 | | - is_rtp=is_rtp, is_eboard=is_eboard, is_tour_page=False) |
| 84 | + is_rtp=is_rtp, is_eboard=is_eboard, is_tour_page=False, |
| 85 | + current="", page=page, rows=rows) |
77 | 86 |
|
78 | | -@app.route("/mine") |
| 87 | +@app.route("/mine/<int:page>") |
79 | 88 | @auth.oidc_auth('default') |
80 | 89 | @audiophiler_auth |
81 | | -def mine(auth_dict=None): |
| 90 | +def mine(page, auth_dict=None): |
| 91 | + rows = File.query.count() |
| 92 | + rows = int(rows // 10 + bool(rows % 10)) |
82 | 93 | is_rtp = ldap_is_rtp(auth_dict["uid"]) |
83 | 94 | is_eboard = ldap_is_eboard(auth_dict["uid"]) |
84 | 95 | # Retrieve list of files for templating |
85 | | - db_files = File.query.filter_by(author=auth_dict["uid"]).all() |
| 96 | + db_files = File.query.filter_by(author=auth_dict["uid"]).offset((page-1) * 10).limit(10).all() |
86 | 97 | harolds = get_harold_list(auth_dict["uid"]) |
87 | 98 | tour_harolds = get_harold_list("root") |
88 | 99 | return render_template("main.html", db_files=db_files, |
89 | 100 | get_file_s3=get_file_s3, get_date_modified=get_date_modified, |
90 | 101 | s3_bucket=s3_bucket, auth_dict=auth_dict, harolds=harolds, |
91 | | - tour_harolds=tour_harolds, is_rtp=is_rtp, is_eboard=is_eboard, is_tour_page=False) |
| 102 | + tour_harolds=tour_harolds, is_rtp=is_rtp, is_eboard=is_eboard, is_tour_page=False, |
| 103 | + current="/mine",page=page, rows=rows) |
92 | 104 |
|
93 | | -@app.route("/selected") |
| 105 | +@app.route("/selected/<int:page>") |
94 | 106 | @auth.oidc_auth('default') |
95 | 107 | @audiophiler_auth |
96 | | -def selected(auth_dict=None): |
| 108 | +def selected(page, auth_dict=None): |
| 109 | + rows = File.query.count() |
| 110 | + rows = int(rows // 10 + bool(rows % 10)) |
97 | 111 | is_rtp = ldap_is_rtp(auth_dict["uid"]) |
98 | 112 | is_eboard = ldap_is_eboard(auth_dict["uid"]) |
99 | 113 | #Retrieve list of files for templating |
100 | 114 | harolds = get_harold_list(auth_dict["uid"]) |
101 | 115 | tour_harolds = get_harold_list("root") |
102 | | - db_files = File.query.filter(File.file_hash.in_(harolds)).all() |
| 116 | + db_files = File.query.filter(File.file_hash.in_(harolds)).offset((page-1) * 10).limit(10).all() |
103 | 117 | return render_template("main.html", db_files=db_files, |
104 | 118 | get_date_modified=get_date_modified, s3_bucket=s3_bucket, |
105 | 119 | auth_dict=auth_dict, harolds=harolds, tour_harolds=tour_harolds, |
106 | | - is_rtp=is_rtp, is_eboard=is_eboard, is_tour_page=False) |
| 120 | + is_rtp=is_rtp, is_eboard=is_eboard, is_tour_page=False, |
| 121 | + current="/selected",page=page, rows=rows) |
107 | 122 |
|
108 | | -@app.route("/tour_page") |
| 123 | +@app.route("/tour_page/<int:page>") |
109 | 124 | @auth.oidc_auth('default') |
110 | 125 | @audiophiler_auth |
111 | | -def admin(auth_dict=None): |
| 126 | +def admin(page, auth_dict=None): |
| 127 | + rows = File.query.count() |
| 128 | + rows = int(rows // 10 + bool(rows % 10)) |
112 | 129 | is_rtp = ldap_is_rtp(auth_dict["uid"]) |
113 | 130 | is_eboard = ldap_is_eboard(auth_dict["uid"]) |
114 | 131 | if is_eboard or is_rtp: |
115 | 132 | harolds = get_harold_list(auth_dict["uid"]) |
116 | 133 | tour_harolds = get_harold_list("root") |
117 | | - db_files = File.query.filter(File.file_hash.in_(tour_harolds)).all() |
| 134 | + db_files = File.query.filter(File.file_hash.in_(tour_harolds)).offset((page-1) * 10).limit(10).all() |
118 | 135 | return render_template("main.html", db_files=db_files, |
119 | 136 | get_date_modified=get_date_modified, s3_bucket=s3_bucket, |
120 | 137 | auth_dict=auth_dict, harolds=harolds, tour_harolds=tour_harolds, |
121 | | - is_rtp=is_rtp, is_eboard=is_eboard, is_tour_page=True, is_tour_mode=get_tour_lock_status()) |
| 138 | + is_rtp=is_rtp, is_eboard=is_eboard, is_tour_page=True, is_tour_mode=get_tour_lock_status(), |
| 139 | + current="/tour_page",page=page, rows=rows) |
122 | 140 |
|
123 | 141 | return "Permission Denied", 403 |
124 | 142 |
|
|
0 commit comments