diff --git a/freepost/__init__.py b/freepost/__init__.py index fd88c53..27ab976 100755 --- a/freepost/__init__.py +++ b/freepost/__init__.py @@ -207,8 +207,11 @@ def login_check (): # Start new session session.start (user['id'], remember) - # Go to user homepage - redirect (application.get_url ('homepage')) + # Redirect logged in user to preferred feed + if user['preferred_feed'] == 'new': + redirect (application.get_url ('homepage') + '?sort=new') + else: + redirect (application.get_url ('homepage')) @get ('/register', name='register') @requires_logout @@ -406,12 +409,16 @@ def update_user_settings (): about = request.forms.getunicode ('about') email = request.forms.getunicode ('email') + preferred_feed = request.forms.getunicode ('preferred_feed') if about is None or email is None: redirect (application.get_url ('user_settings')) + if preferred_feed not in [ 'hot', 'new' ]: + preferred_feed = 'hot' + # Update user info in the database - database.update_user (user['id'], about, email, False) + database.update_user (user['id'], about, email, False, preferred_feed) redirect (application.get_url ('user_settings')) diff --git a/freepost/database.py b/freepost/database.py index b5ecd1a..74b5759 100644 --- a/freepost/database.py +++ b/freepost/database.py @@ -266,7 +266,7 @@ def get_user_replies (user_id): return cursor.fetchall () # Update user information -def update_user (user_id, about, email, email_notifications): +def update_user (user_id, about, email, email_notifications, preferred_feed): cursor = db.cursor (MySQLdb.cursors.DictCursor) # Update user info, but not email address @@ -274,13 +274,15 @@ def update_user (user_id, about, email, email_notifications): """ UPDATE user SET about = %(about)s, - email_notifications = %(notifications)s + email_notifications = %(notifications)s, + preferred_feed = %(preferred_feed)s WHERE id = %(user)s """, { 'about': about, 'notifications': email_notifications, - 'user': user_id + 'user': user_id, + 'preferred_feed': preferred_feed } ) diff --git a/freepost/templates/banner.html b/freepost/templates/banner.html index 5dad22e..1008ce4 100644 --- a/freepost/templates/banner.html +++ b/freepost/templates/banner.html @@ -2,15 +2,18 @@ # on special occasions. #} +{#
FOSDEM 2018
+#} {# Welcome New Year. # To maintain alignment, keep al lines below of the same length # and with no padding. #} +{#
                       .''.    
     .        *''*    :_\/_:   
@@ -20,10 +23,10 @@
    *_\/_*     -= o =-  /)\    
    * /\ *     .'/.\'.   '     
     *..*         :            
-     ___   ___  __  ___       
-    |__ \ / _ \/_ |/ _ \      
-       ) | | | || | (_) |     
-      / /| | | || |> _ <      
-     / /_| |_| || | (_) |     
-    |____|\___/ |_|\___/      
+     ____   ___  _  ___       
+    |___ \ / _ \/ |/ _ \      
+      __) | | | | | (_) |     
+     / __/| |_| | |\__, |     
+    |_____|\___/|_|  /_/      
 
+#} diff --git a/freepost/templates/homepage.html b/freepost/templates/homepage.html index 494610e..c25d2eb 100755 --- a/freepost/templates/homepage.html +++ b/freepost/templates/homepage.html @@ -6,7 +6,7 @@ {% block content %} - {# include 'banner.html' #} + {% include 'banner.html' %} {% include 'posts.html' %} diff --git a/freepost/templates/layout.html b/freepost/templates/layout.html index 9a8e455..ee15dee 100644 --- a/freepost/templates/layout.html +++ b/freepost/templates/layout.html @@ -29,7 +29,7 @@ topic / {{ topic }} {% else %} - {% else %} - {% endif %} - diff --git a/freepost/templates/user_settings.html b/freepost/templates/user_settings.html index e4a56d1..386018e 100755 --- a/freepost/templates/user_settings.html +++ b/freepost/templates/user_settings.html @@ -50,6 +50,24 @@
+ Preferred feed +
+
+

+ +

+

+ +

+
+ +