Browse Source

reflecting changes of partial_content to all routes

Axolotle 1 year ago
parent
commit
8560bd5953
1 changed files with 123 additions and 57 deletions
  1. 123
    57
      app/main/views.py

+ 123
- 57
app/main/views.py View File

@@ -61,8 +61,7 @@ def index():
61 61
                 podcasts=Podcast.list(number=3),
62 62
                 blog_posts = BlogPost.list(number=3),
63 63
                 events = Event.list(number=3)
64
-            ),
65
-            'title': 'home page'
64
+            )
66 65
         }
67 66
     }
68 67
 
@@ -89,12 +88,17 @@ def about():
89 88
 @main.route('/contrib')
90 89
 @partial_content
91 90
 def contribute():
92
-    # create a real "contribute" page
93 91
     page = Page.query.get_or_404(2)
94
-    return [ 'displayMain',
95
-             { "content": render_template("main_pages/contribute.html",
96
-                                          page=page),
97
-               "title": "Contribuer"} ]
92
+    return {
93
+        'function': 'displayMain',
94
+        'content': {
95
+            'template': render_template(
96
+                "main_pages/contribute.html",
97
+                page=page
98
+            ),
99
+            'title': "Contribuer"
100
+        }
101
+    }
98 102
 
99 103
 #########################
100 104
 #  Podcasts             #
@@ -108,31 +112,46 @@ def podcasts():
108 112
         .order_by(Podcast.timestamp.desc())            \
109 113
         .paginate(page, per_page=10, error_out=False)
110 114
     podcasts = pagination.items
111
-
112
-    return [ 'displayMain',
113
-             { "content": render_template("main_pages/podcasts.html",
114
-                                          podcasts=podcasts,
115
-                                          pagination=pagination),
116
-               "title": "Podcasts" } ]
115
+    return {
116
+        'function': 'displayMain',
117
+        'content': {
118
+            'template': render_template(
119
+                "main_pages/podcasts.html",
120
+                podcasts=podcasts,
121
+                pagination=pagination
122
+            ),
123
+            'title': "Podcasts"
124
+        }
125
+    }
117 126
 
118 127
 @main.route('/podcasts/<id>')
119 128
 @partial_content
120 129
 def podcast(id):
121 130
     podcast = Podcast.query.get_or_404(id)
122
-    return [ 'displayMain',
123
-             { "content": render_template("elem_pages/podcast.html",
124
-                                          elem=podcast),
125
-               "title": podcast.name,
126
-               "description" : podcast.description } ]
131
+    return {
132
+        'function': 'displayMain',
133
+        'content': {
134
+            'template': render_template(
135
+                "elem_pages/podcast.html",
136
+                elem=podcast
137
+            ),
138
+            'title': podcast.name,
139
+            'description': podcast.description
140
+        }
141
+    }
127 142
 
128 143
 @main.route('/podcasts/<id>/play')
129 144
 @partial_content_no_history
130 145
 def play(id):
131 146
     podcast = Podcast.query.get_or_404(id)
132
-    return [ "player.load.bind(player)",
133
-             { "link" : podcast.link,
134
-               "title" : podcast.name,
135
-               "channel": podcast.channel_id } ]
147
+    return {
148
+        'function': 'player.load.bind(player)',
149
+        'content': {
150
+            "link" : podcast.link,
151
+            "title" : podcast.name,
152
+            "channel": podcast.channel_id
153
+        }
154
+    }
136 155
 
137 156
 ##############################
138 157
 #  Contributors/Collectives  #
@@ -142,32 +161,50 @@ def play(id):
142 161
 @main.route('/collectives')
143 162
 @partial_content
144 163
 def contributors():
145
-    return [ 'displayMain',
146
-             { "content": render_template("main_pages/contributors.html",
147
-                                          contributors=Contributor.list(),
148
-                                          collectives=Collective.list()),
149
-               "title": "Contributeurs",
150
-               "description" : "Liste des contributeurs de Radio Rhino." }]
164
+    return {
165
+        'function': 'displayMain',
166
+        'content': {
167
+            'template': render_template(
168
+                "main_pages/contributors.html",
169
+                contributors=Contributor.list(),
170
+                collectives=Collective.list()
171
+            ),
172
+            'title': "Contributeurs",
173
+            'description': "Liste des contributeurs de Radio Rhino."
174
+        }
175
+    }
151 176
 
152 177
 @main.route('/contributors/<id>')
153 178
 @partial_content
154 179
 def contributor(id):
155 180
     contributor = Contributor.query.get_or_404(id)
156
-    return [ 'displayMain',
157
-             { "content": render_template("elem_pages/contributor.html",
158
-                                          elem=contributor),
159
-               "title": contributor.name,
160
-               "description" : contributor.description }]
181
+    return {
182
+        'function': 'displayMain',
183
+        'content': {
184
+            'template': render_template(
185
+                "elem_pages/contributor.html",
186
+                elem=contributor
187
+            ),
188
+            'title': contributor.name,
189
+            'description': contributor.description
190
+        }
191
+    }
161 192
 
162 193
 @main.route('/collectives/<id>')
163 194
 @partial_content
164 195
 def collective(id):
165 196
     collective = Collective.query.get_or_404(id)
166
-    return [ 'displayMain',
167
-             { "content": render_template("elem_pages/contributor.html",
168
-                                          elem=collective),
169
-               "title": collective.name,
170
-               "description" : collective.description } ]
197
+    return {
198
+        'function': 'displayMain',
199
+        'content': {
200
+            'template': render_template(
201
+                "elem_pages/contributor.html",
202
+                elem=collective
203
+            ),
204
+            'title': collective.name,
205
+            'description': collective.description
206
+        }
207
+    }
171 208
 
172 209
 #########################
173 210
 #  Blogs                #
@@ -176,20 +213,33 @@ def collective(id):
176 213
 @main.route('/blogs')
177 214
 @partial_content
178 215
 def blogs():
179
-    return [ 'displayMain',
180
-             { "content": render_template("main_pages/blogs.html",
181
-                                          blog_posts = BlogPost.list(number=10)),
182
-               "title": "Blogs",
183
-               "description": "Les articles de blog de Radio Rhino" } ]
216
+    return {
217
+        'function': 'displayMain',
218
+        'content': {
219
+            'template': render_template(
220
+                "main_pages/blogs.html",
221
+                blog_posts=BlogPost.list(number=10)
222
+            ),
223
+            'title': "Blogs",
224
+            'description': "Les articles de blog de Radio Rhino"
225
+        }
226
+    }
227
+
184 228
 
185 229
 @main.route('/blogs/<id>')
186 230
 @partial_content
187 231
 def blog(id):
232
+    blog_post = BlogPost.query.get_or_404(id)
233
+    return {
234
+        'function': 'displayMain',
235
+        'content': {
236
+            'template': render_template(
237
+                "notimplemented.html"
238
+            ),
239
+            'title': blog_post.name
240
+        }
241
+    }
188 242
 
189
-    return [ 'displayMain',
190
-             { "content": render_template("main_page/blogs.html",
191
-                                          blog_post = BlogPost.query.list()),
192
-               "title": blog_post.name } ]
193 243
 
194 244
 #########################
195 245
 #  Agendas              #
@@ -198,18 +248,30 @@ def blog(id):
198 248
 @main.route('/agendas')
199 249
 @partial_content
200 250
 def agendas():
201
-    return [ 'displayMain',
202
-             { "content": render_template("main_pages/agendas.html",
203
-                                          events = Event.list(number=10)),
204
-               "title": "Agendas" } ]
251
+    return {
252
+        'function': 'displayMain',
253
+        'content': {
254
+            'template': render_template(
255
+                "main_pages/agendas.html",
256
+                events=Event.list(number=10)
257
+            ),
258
+            'title': "Agendas"
259
+        }
260
+    }
205 261
 
206 262
 @main.route('/agendas/<id>')
207 263
 @partial_content
208 264
 def agenda(id):
209 265
     event = Event.query.get_or_404(id)
210
-    return [ 'displayMain',
211
-             { "content": render_template("notimplemented.html"),
212
-               "title": event.name} ]
266
+    return {
267
+        'function': 'displayMain',
268
+        'content': {
269
+            'template': render_template(
270
+                "notimplemented.html"
271
+            ),
272
+            'title': event.name
273
+        }
274
+    }
213 275
 
214 276
 #########################
215 277
 #  Static stuff         #
@@ -223,6 +285,10 @@ def get_live():
223 285
 
224 286
     stream_url_play = url_for('main.podcast', id=live.podcast().id)
225 287
 
226
-    return [ "updateLive",
227
-             { "next_live_in" : next_live_in,
228
-               "stream_url_play" : stream_url } ]
288
+    return {
289
+        'function': 'updateLive',
290
+        'content': {
291
+            "next_live_in" : next_live_in,
292
+            "stream_url_play" : stream_url
293
+        }
294
+    }

Loading…
Cancel
Save