mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-05 16:58:59 +00:00
38 lines
1.6 KiB
Python
38 lines
1.6 KiB
Python
![]() |
import zlib
|
||
|
import mongoengine as mongo
|
||
|
|
||
|
|
||
|
class MSharedStory(mongo.Document):
|
||
|
user_id = mongo.IntField()
|
||
|
shared_date = mongo.DateTimeField()
|
||
|
comments = mongo.StringField()
|
||
|
story_feed_id = mongo.IntField()
|
||
|
story_date = mongo.DateTimeField()
|
||
|
story_title = mongo.StringField(max_length=1024)
|
||
|
story_content = mongo.StringField()
|
||
|
story_content_z = mongo.BinaryField()
|
||
|
story_original_content = mongo.StringField()
|
||
|
story_original_content_z = mongo.BinaryField()
|
||
|
story_content_type = mongo.StringField(max_length=255)
|
||
|
story_author_name = mongo.StringField()
|
||
|
story_permalink = mongo.StringField()
|
||
|
story_guid = mongo.StringField(unique_with=('user_id',))
|
||
|
story_tags = mongo.ListField(mongo.StringField(max_length=250))
|
||
|
|
||
|
meta = {
|
||
|
'collection': 'shared_stories',
|
||
|
'indexes': [('user_id', '-shared_date'), ('user_id', 'story_feed_id'), 'story_feed_id'],
|
||
|
'index_drop_dups': True,
|
||
|
'ordering': ['-shared_date'],
|
||
|
'allow_inheritance': False,
|
||
|
}
|
||
|
|
||
|
def save(self, *args, **kwargs):
|
||
|
if self.story_content:
|
||
|
self.story_content_z = zlib.compress(self.story_content)
|
||
|
self.story_content = None
|
||
|
if self.story_original_content:
|
||
|
self.story_original_content_z = zlib.compress(self.story_original_content)
|
||
|
self.story_original_content = None
|
||
|
super(MSharedStory, self).save(*args, **kwargs)
|