Browse Source

Started working on the topic tracker

I couldn't finish it because I'm a bit busy.. but feel free to work on it :)
sh4nks 11 years ago
parent
commit
2225f8a94b

+ 11 - 1
README.md

@@ -11,7 +11,17 @@ using the micro framework Flask.
 * Admin Interface
 * Group based permissions
 * BBCode support
-* **TODO:** Themes
+
+
+## TODO
+
+* Topic Tracker (in progress)
+* Track the unread posts and mark them as new
+* A own theme and make FlaskBB themable with Flask-Themes2
+* Localization (Babel)
+* Searching for members, posts,...
+* Subforums
+* Figure out how to integrate it in another app where you can use the models from flaskbb and so on..
 
 
 ## DEPENDENCIES

+ 0 - 1
flaskbb/admin/forms.py

@@ -108,7 +108,6 @@ class UserForm(Form):
         if user:
             raise ValidationError("This email is taken")
 
-
     def save(self):
         user = User(**self.data)
         return user.save()

+ 2 - 1
flaskbb/admin/views.py

@@ -9,7 +9,8 @@ from flaskbb.decorators import admin_required
 from flaskbb.extensions import db
 from flaskbb.user.models import User, Group
 from flaskbb.forum.models import Post, Topic, Forum, Category
-from flaskbb.admin.forms import AddUserForm, EditUserForm, AddGroupForm, EditGroupForm, ForumForm, CategoryForm
+from flaskbb.admin.forms import (AddUserForm, EditUserForm, AddGroupForm,
+                                 EditGroupForm, ForumForm, CategoryForm)
 
 
 admin = Blueprint("admin", __name__)

+ 1 - 0
flaskbb/configs/default.py

@@ -52,6 +52,7 @@ class DefaultConfig(object):
     # Auth
     LOGIN_VIEW = "auth.login"
     REAUTH_VIEW = "auth.reauth"
+    LOGIN_MESSAGE_CATEGORY = "error"
 
     # Caching
     CACHE_TYPE = "simple"

+ 33 - 0
flaskbb/forum/models.py

@@ -250,3 +250,36 @@ class Category(db.Model):
         db.session.delete(self)
         db.session.commit()
         return self
+
+
+"""
+A topic can be tracked by many users
+and a user can track many topics.. so it's a many-to-many relationship
+"""
+topictracker = db.Table('topictracker',
+    db.Column('user_id', db.Integer(), db.ForeignKey('users.id')),
+    db.Column('topic_id', db.Integer(), db.ForeignKey('topics.id')))
+
+
+class Tracking(db.Model):
+    """
+    This model tracks the unread/read posts
+    Note: This functionality isn't implemented yet, but this will be the next
+    feature after the TopicTracker
+    """
+    __tablename__ = "tracking"
+
+    id = db.Column(db.Integer, primary_key=True)
+    user_id = db.Column(db.Integer, db.ForeignKey("users.id"))
+    topic_id = db.Column(db.Integer, db.ForeignKey("topics.id"))
+    last_read = db.Column(db.DateTime, default=datetime.utcnow())
+
+    def save(self):
+        db.session.add(self)
+        db.session.commit()
+        return self
+
+    def delete(self):
+        db.session.delete(self)
+        db.session.commit()
+        return self

+ 18 - 3
flaskbb/forum/views.py

@@ -46,7 +46,6 @@ def index():
                            online_guests=len(get_online_users(guest=True)))
 
 
-
 @forum.route("/category/<int:category_id>")
 def view_category(category_id):
     category = Category.query.filter_by(id=category_id).first()
@@ -208,8 +207,8 @@ def delete_post(post_id):
 
 @forum.route("/who_is_online")
 def who_is_online():
-    online_users=get_online_users()
-    return render_template("forum/online_users.html", online_users=online_users)
+    return render_template("forum/online_users.html",
+                           online_users=get_online_users())
 
 
 @forum.route("/memberlist")
@@ -222,3 +221,19 @@ def memberlist():
     return render_template("forum/memberlist.html",
                            users=users,
                            per_page=current_app.config['USERS_PER_PAGE'])
+
+
+@forum.route("/topictracker")
+def topic_tracker():
+    #return render_template("forum/topictracker.html", topics=topics)
+    pass
+
+
+@forum.route("/topictracker/<topic_id>/add")
+def add_to_topictrack(topic_id):
+    pass
+
+
+@forum.route("/topictracker/<topic_id>/delete")
+def remove_from_topictrack(topic_id):
+    pass

+ 0 - 1
flaskbb/helpers.py

@@ -8,7 +8,6 @@
     :copyright: (c) 2013 by the FlaskBB Team.
     :license: BSD, see LICENSE for more details.
 """
-import random
 import time
 from datetime import datetime, timedelta
 

+ 3 - 6
flaskbb/templates/layout.html

@@ -48,10 +48,11 @@
                                 <span class="caret"></span>
                             </button>
                             <ul class="dropdown-menu" role="menu">
-                                <li><a href="{{ url_for('user.settings') }}"><span class="glyphicon glyphicon-cog"></span> Settings</a></li>
+                                <li><a href="{{ url_for('forum.topic_tracker') }}"><span class="glyphicon glyphicon-book"></span> Topic Tracker</a></li>
+                                <li class="divider"></li>
 
+                                <li><a href="{{ url_for('user.settings') }}"><span class="glyphicon glyphicon-cog"></span> Settings</a></li>
                                 {% if current_user.permissions['admin'] %}
-                                <li class="divider"></li>
                                 <li><a href="{{ url_for('admin.overview') }}"><span class="glyphicon glyphicon-cog"></span> Admin Panel</a></li>
                                 <li class="divider"></li>
                                 {% endif %}
@@ -67,10 +68,6 @@
                             <ul class="dropdown-menu" role="menu">
                                 <li><a href="{{ url_for('pms.inbox') }}"><span class="glyphicon glyphicon-envelope"></span> Inbox</a></li>
                                 <li><a href="{{ url_for('pms.new_message') }}"><span class="glyphicon glyphicon-pencil"></span> New Message</a></li>
-                                <!--
-                                <li class="divider"></li>
-                                <li><a href="{{ url_for('pms.view_message', id=1) }}"><strong>test1</strong> - <span class="muted">This is the message title1</span> </a></li>
-                                -->
                             </ul>
                         </div>
                     {% else %}

+ 0 - 1
manage.py

@@ -59,7 +59,6 @@ def createall():
     # Just for testing purposes
     dbfile = os.path.join(Config._basedir, "flaskbb.sqlite")
     if os.path.exists(dbfile):
-        print "Removing old database file..."
         os.remove(dbfile)
 
     db.create_all()

+ 73 - 0
setup.py

@@ -0,0 +1,73 @@
+"""
+FlaskBB
+=======
+
+FlaskBB is a forum software written in Python using the microframework Flask.
+
+
+And Easy to Setup
+-----------------
+
+.. code:: bash
+    $ python manage.py createall
+
+    $ python manage.py runserver
+     * Running on http://localhost:8080/
+
+
+Resources
+---------
+
+* `website <http://flaskbb.org>`_
+* `source <https://github.com/sh4nks/flaskbb>`_
+* `issues <https://github.com/sh4nks/flaskbb/issues>`_
+
+"""
+from setuptools import setup
+
+setup(
+    name='FlaskBB',
+    version='0.1-dev',
+    url='http://github.com/sh4nks/flaskbb/',
+    license='BSD',
+    author='sh4nks',
+    author_email='sh4nks7@gmail.com',
+    description='A forum software written with flask',
+    long_description=__doc__,
+    packages=['flaskbb'],
+    include_package_data=True,
+    zip_safe=False,
+    platforms='any',
+    install_requires=[
+        'Flask==0.10.1',
+        'Flask-Cache==0.12',
+        'Flask-DebugToolbar==0.8.0',
+        'Flask-Login==0.2.7',
+        'Flask-Mail==0.9.0',
+        'Flask-SQLAlchemy==1.0',
+        'Flask-Script==0.6.2',
+        'Flask-Themes2==0.1.2',
+        'Flask-WTF==0.9.3',
+        'Jinja2==2.7.1',
+        'Pygments==1.6',
+        'MarkupSafe==0.18',
+        'SQLAlchemy==0.8.2',
+        'WTForms==1.0.5',
+        'Werkzeug==0.9.4',
+        'blinker==1.3',
+        'itsdangerous==0.23',
+        'postmarkup==1.2.0',
+        'wsgiref==0.1.2',
+    ],
+    classifiers=[
+        'Development Status :: 4 - Beta',
+        'Environment :: Web Environment',
+        'Intended Audience :: Developers, Users',
+        'License :: OSI Approved :: BSD License',
+        'Operating System :: OS Independent',
+        'Programming Language :: Python',
+        'Programming Language :: Python :: 3',
+        'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
+        'Topic :: Software Development :: Libraries :: Python Modules'
+    ]
+)