Browse Source

A few fixes when using postgresql.

sh4nks 11 years ago
parent
commit
e6e0871469
3 changed files with 9 additions and 7 deletions
  1. 1 0
      flaskbb/configs/development.py.example
  2. 5 4
      flaskbb/forum/models.py
  3. 3 3
      flaskbb/user/models.py

+ 1 - 0
flaskbb/configs/development.py.example

@@ -18,6 +18,7 @@ class DevelopmentConfig(DefaultConfig):
     # SQLAlchemy connection options
     # This will create in the applications folder (where manage.py is)
     # a database named flaskbb.sqlite.
+    #SQLALCHEMY_DATABASE_URI = "postgresql://flaskbb@localhost:5432/flaskbb"
     SQLALCHEMY_DATABASE_URI = 'sqlite:///' + DefaultConfig._basedir + '/' + \
                               'flaskbb.sqlite'
 

+ 5 - 4
flaskbb/forum/models.py

@@ -70,7 +70,7 @@ class ForumsRead(db.Model):
     user_id = db.Column(db.Integer, db.ForeignKey("users.id"),
                         primary_key=True)
     forum_id = db.Column(db.Integer,
-                         db.ForeignKey("topics.id", use_alter=True,
+                         db.ForeignKey("forums.id", use_alter=True,
                                        name="fk_fr_forum_id"),
                          primary_key=True)
     last_read = db.Column(db.DateTime, default=datetime.utcnow())
@@ -438,6 +438,8 @@ class Topic(db.Model):
         # These things needs to be stored in a variable before they are deleted
         forum = self.forum
 
+        TopicsRead.query.filter_by(topic_id=self.id).delete()
+
         # Delete the topic
         db.session.delete(self)
         db.session.commit()
@@ -457,8 +459,6 @@ class Topic(db.Model):
                    Topic.forum_id == self.forum_id).\
             count()
 
-        TopicsRead.query.filter_by(topic_id=self.id).delete()
-
         db.session.commit()
         return self
 
@@ -712,7 +712,8 @@ class Forum(db.Model):
         db.session.delete(self)
         db.session.commit()
 
-        # Delete all entries from the ForumsRead and TopicsRead relation
+        # Delete the entries for the forum in the ForumsRead and TopicsRead
+        # relation
         ForumsRead.query.filter_by(forum_id=self.id).delete()
         TopicsRead.query.filter_by(forum_id=self.id).delete()
 

+ 3 - 3
flaskbb/user/models.py

@@ -86,7 +86,7 @@ class User(db.Model, UserMixin):
     location = db.Column(db.String(63))
     signature = db.Column(db.String(255))
     avatar = db.Column(db.String(63))
-    notes = db.Column(db.Text(5000))
+    notes = db.Column(db.Text)
 
     theme = db.Column(db.String(15))
 
@@ -191,7 +191,7 @@ class User(db.Model, UserMixin):
         return expired, invalid, data
 
     def make_reset_token(self, expiration=3600):
-        """Creates a token. The duration can be configured through the
+        """Creates a reset token. The duration can be configured through the
         expiration parameter.
 
         :param expiration: The time in seconds how long the token is valid.
@@ -200,7 +200,7 @@ class User(db.Model, UserMixin):
 
     def verify_reset_token(self, token):
         """Verifies a reset token. It returns three boolean values based on
-        state of the token (expired, invalid, data)
+        the state of the token (expired, invalid, data)
 
         :param token: The reset token that should be checked.
         """