Browse Source

Fixed conversation not always showing first message

sh4nks 9 years ago
parent
commit
cc06048ab4
2 changed files with 7 additions and 2 deletions
  1. 2 0
      flaskbb/message/models.py
  2. 5 2
      flaskbb/templates/message/conversation_list.html

+ 2 - 0
flaskbb/message/models.py

@@ -15,6 +15,7 @@ from sqlalchemy_utils import UUIDType
 from flaskbb.extensions import db
 from flaskbb.utils.database import CRUDMixin
 
+
 class Conversation(db.Model, CRUDMixin):
     __tablename__ = "conversations"
 
@@ -32,6 +33,7 @@ class Conversation(db.Model, CRUDMixin):
     messages = db.relationship(
         "Message", lazy="joined", backref="conversation",
         primaryjoin="Message.conversation_id == Conversation.id",
+        order_by="asc(Message.id)",
         cascade="all, delete-orphan"
     )
 

+ 5 - 2
flaskbb/templates/message/conversation_list.html

@@ -1,4 +1,4 @@
-<div class="panel panel-default conversation">
+<div class="panel panel-primary conversation">
     <div class="panel-heading">
         <span class="glyphicon glyphicon-comment"></span>
         <h3 class="panel-title">{% trans %}Conversations{% endtrans %}</h3>
@@ -26,7 +26,10 @@
                                 {% endif %}
                             </a>
                             <div class="mic-info">
-                                By: <a href="#">{{ conversation.from_user.username }}</a> on {{ conversation.date_created|format_date("%d %B %Y - %H:%M") }}
+                                From <a href="{{ conversation.from_user.url }}">{{ conversation.from_user.username }}</a>
+                                to <a href="{{ conversation.to_user.url }}">{{ conversation.to_user.username }}</a>
+                                on {{ conversation.date_created|format_date("%d %B %Y - %H:%M") }}
+
                             </div>
                         </div>
                         <div class="comment-text">