home » zplus/freepost.git
Author zPlus <zplus@peers.community> 2018-07-18 23:17:29
Committer zPlus <zplus@peers.community> 2018-07-18 23:17:29
Commit 03779d5 (patch)
Tree 2f30169
Parent(s)

Add "topic" route. modified: freepost/__init__.py modified: freepost/templates/homepage.html


commits diff: f67dca1..03779d5
2 files changed, 26 insertions, 1 deletiondownload


Diffstat
-rwxr-xr-x freepost/__init__.py 25
-rwxr-xr-x freepost/templates/homepage.html 2

Diff options
View
Side
Whitespace
Context lines
Inter-hunk lines
+25/-0 M   freepost/__init__.py
index 783bd10..08510dd
old size: 24K - new size: 25K
@@ -143,6 +143,30 @@ def new ():
143 143 posts=posts,
144 144 sorting='new')
145 145
146 + # TODO implement this
147 + @get ('/topic/<name>', name='topic')
148 + def topic (name):
149 + """
150 + Display posts by topic.
151 + """
152 +
153 + return ""
154 +
155 + # Page number
156 + page = int (request.query.page or 0)
157 +
158 + if page < 0:
159 + redirect (application.get_url ('topic', name=name))
160 +
161 + user = session.user ()
162 + posts = database.get_topic_posts (page, user['id'] if user else None)
163 +
164 + return template (
165 + 'homepage.html',
166 + page_number=page,
167 + posts=posts,
168 + sorting='hot')
169 +
146 170 @get ('/about', name='about')
147 171 def about ():
148 172 """
@@ -394,6 +418,7 @@ def update_user ():
394 418 if about is None or email is None:
395 419 redirect (application.get_url ('user'))
396 420
421 + # TODO check unique value of emails
397 422 database.update_user (user['id'], about, email, False)
398 423
399 424 redirect (application.get_url ('user'))

+1/-1 M   freepost/templates/homepage.html
index 5d2a3c6..521cc57
old size: 3K - new size: 4K
@@ -45,7 +45,7 @@
45 45
46 46 <div class="topics">
47 47 {% for topic in topics %}
48 - <a href="" class="topic">{{ topic }}</a>
48 + <a href="{{ url ('topic', name=topic) }}" class="topic">{{ topic }}</a>
49 49 {% endfor %}
50 50 </div>
51 51