Axolotle 1 year ago
parent
commit
8c9c2325db
4 changed files with 27 additions and 24 deletions
  1. 1
    0
      .gitignore
  2. 26
    20
      app/main/views.py
  3. 0
    0
      app/models/playlist.py
  4. 0
    4
      app/templates/main_pages/agendas.html

+ 1
- 0
.gitignore View File

@@ -2,6 +2,7 @@ __pycache__
2 2
 *.pyc
3 3
 .DS_Store
4 4
 app/uploads/*
5
+app/static/podcasts/*
5 6
 venv/*
6 7
 doc/_build/
7 8
 .sass-cache

+ 26
- 20
app/main/views.py View File

@@ -1,26 +1,21 @@
1 1
 # "Standard libs" imports
2
-import os
3
-import json
4
-from glob import glob
5
-from config import config, LIQUIDSOAP_TOKEN
6
-from uuid import uuid4                 # FIXME no longer needed i think
2
+import os                              # FIXME no longer needed i think
3
+import json                            # same
4
+from glob import glob                  # same
5
+from config import config, LIQUIDSOAP_TOKEN # same
6
+from uuid import uuid4                 # same
7 7
 from datetime import date              # same
8 8
 
9 9
 # Flask stuff
10
-from flask import (Flask,
11
-                   render_template,
12
-                   url_for,
13
-                   jsonify,
14
-                   request,
15
-                   redirect,
16
-                   flash)
10
+from flask import (Flask, render_template, request,
11
+                   url_for, jsonify, redirect, flash) # same
17 12
 
18 13
 # Specific app stuff
19 14
 from . import main
20
-from .forms import SubscribeForm
15
+from .forms import SubscribeForm       # same
21 16
 from .partial_content import *
22 17
 from .jinja_custom_filters import *
23
-from .. import db                      # FIXME no longer needed i think
18
+from .. import db                      # same
24 19
 from app.models.admin import *
25 20
 from app.models.event import Event
26 21
 from app.models.podcast import Podcast
@@ -51,8 +46,9 @@ def index():
51 46
             'template': render_template(
52 47
                 "index.html",
53 48
                 podcasts=Podcast.list(number=3),
54
-                blog_posts=BlogPost.list(number=3),
55
-                events=Event.list(number=3)
49
+                blog_posts = BlogPost.list(number=3),
50
+                events = Event.query.order_by(Event.begin.asc())\
51
+                  .limit(5).all()
56 52
             )
57 53
         }
58 54
     }
@@ -240,19 +236,24 @@ def channel(id):
240 236
 @main.route('/blogs')
241 237
 @partial_content
242 238
 def blogs():
239
+    page = request.args.get('page', 1, type=int)
240
+    pagination = BlogPost.query                         \
241
+        .order_by(BlogPost.timestamp.desc())            \
242
+        .paginate(page, per_page=10, error_out=False)
243
+    blog_posts = pagination.items
243 244
     return {
244 245
         'function': 'displayMain',
245 246
         'content': {
246 247
             'template': render_template(
247 248
                 "main_pages/blogs.html",
248
-                blog_posts=BlogPost.list(number=10)
249
+                blog_posts=BlogPost.list(number=10),
250
+                pagination = pagination
249 251
             ),
250 252
             'title': "Blogs",
251 253
             'description': "Les articles de blog de Radio Rhino"
252 254
         }
253 255
     }
254 256
 
255
-
256 257
 @main.route('/blogs/<id>')
257 258
 @partial_content
258 259
 def blog(id):
@@ -276,13 +277,18 @@ def blog(id):
276 277
 @main.route('/agendas')
277 278
 @partial_content
278 279
 def agendas():
280
+    page = request.args.get('page', 1, type=int)
281
+    pagination = Event.query                         \
282
+        .order_by(Event.begin.asc())            \
283
+        .paginate(page, per_page=10, error_out=False)
284
+    events = pagination.items
279 285
     return {
280 286
         'function': 'displayMain',
281 287
         'content': {
282 288
             'template': render_template(
283 289
                 "main_pages/agendas.html",
284
-                events=Event.list(number=10)
285
-            ),
290
+                events = events,
291
+                pagination = pagination),
286 292
             'title': "Agendas"
287 293
         }
288 294
     }

+ 0
- 0
app/models/playlist.py View File


+ 0
- 4
app/templates/main_pages/agendas.html View File

@@ -3,7 +3,6 @@
3 3
         <div class="title marg2">
4 4
             {% include 'svg/title_agenda.svg' %}
5 5
         </div>
6
-        <div>
7 6
             {% for elem in events %}
8 7
             <article class="widgetBis">
9 8
                 <h3><a class="content-link"
@@ -21,8 +20,5 @@
21 20
                 </div>
22 21
             </article>
23 22
             {% endfor %}
24
-        </div>
25
-
26
-
27 23
     {% endif %}
28 24
 </section>

Loading…
Cancel
Save