aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin
diff options
context:
space:
mode:
authorJoar Wandborg <git@wandborg.com>2011-06-27 23:39:40 +0200
committerJoar Wandborg <git@wandborg.com>2011-06-27 23:39:40 +0200
commitc11f21ab3c64c6ef9d9cde8bfdcddf12f6663932 (patch)
treeaee2af62c16f4f31fefa281941655a8c34a48956 /mediagoblin
parentda0683b48c9ed6fc4ada1aff758e493bd2311d48 (diff)
downloadmediagoblin-c11f21ab3c64c6ef9d9cde8bfdcddf12f6663932.tar.lz
mediagoblin-c11f21ab3c64c6ef9d9cde8bfdcddf12f6663932.tar.xz
mediagoblin-c11f21ab3c64c6ef9d9cde8bfdcddf12f6663932.zip
Issue 362 - Add simple comments
* Added MediaComment database model Holds `media_entry` (`ObjectId`), `author` (`ObjectId`), `created`, `content` and `content_html`.
Diffstat (limited to 'mediagoblin')
-rw-r--r--mediagoblin/db/models.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py
index 600b79ff..5d00aa34 100644
--- a/mediagoblin/db/models.py
+++ b/mediagoblin/db/models.py
@@ -147,8 +147,32 @@ class MediaEntry(Document):
def uploader(self):
return self.db.User.find_one({'_id': self['uploader']})
+class MediaComment(Document):
+ __collection__ = 'media_comments'
-REGISTER_MODELS = [MediaEntry, User]
+ structure = {
+ 'media_entry': ObjectId,
+ 'author': ObjectId,
+ 'created': datetime.datetime,
+ 'content': unicode,
+ 'content_html': unicode}
+
+ required_fields = [
+ 'author', 'created', 'content']
+
+ default_values = {
+ 'created': datetime.datetime.utcnow}
+
+ def media_entry(self):
+ pass
+
+ def author(self):
+ return self.db.User.find_one({'_id': self['author']})
+
+REGISTER_MODELS = [
+ MediaEntry,
+ User,
+ MediaComment]
def register_models(connection):