Commits

Anonymous committed 51d62fd

photo subclass

Comments (0)

Files changed (6)

newsmeme/__init__.py

     app.register_module(views.comment, url_prefix="/comment")
     app.register_module(views.account, url_prefix="/acct")
     app.register_module(views.feeds, url_prefix="/feeds")
+    app.register_module(views.photos, url_prefix="/photos/")
     app.register_module(views.openid, url_prefix="/openid")
     app.register_module(views.api, url_prefix="/api")
 

newsmeme/extensions.py

 from flaskext.openid import OpenID
 from flaskext.sqlalchemy import SQLAlchemy
 from flaskext.cache import Cache
+from flaskext.uploads import UploadSet
 
 __all__ = ['oid', 'mail', 'db']
 
 mail = Mail()
 db = SQLAlchemy()
 cache = Cache()
+uploads = UploadSet()
 

newsmeme/models/__init__.py

 from newsmeme.models.users import User
 from newsmeme.models.posts import Post, Tag, post_tags
 from newsmeme.models.comments import Comment
+from newsmeme.models.photos import Photo
 
 

newsmeme/models/posts.py

     access = db.Column(db.Integer, default=PUBLIC)
 
     _tags = db.Column("tags", db.UnicodeText)
+    _type = db.Column("type", db.String(50))
 
     author = db.relation(User, innerjoin=True, lazy="joined")
     
-    __mapper_args__ = {'order_by' : id.desc()}
+    __mapper_args__ = {'order_by' : id.desc(),
+                       'polymorphic_on' : _type, }
 
     class Permissions(object):
 

newsmeme/views/__init__.py

 from .user import user
 from .openid import openid
 from .api import api
+from .photos import photos
         'Flask-OpenID',
         'Flask-Babel',
         'Flask-Themes',
+        'Flask-Uploads',
+        'PIL',
         'sqlalchemy',
         'markdown',
         'feedparser',