mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Adding social model for shared stories. Needs another component to act as a feed.
This commit is contained in:
parent
e6a20e41fc
commit
2e501f617e
4 changed files with 54 additions and 0 deletions
0
social/__init__.py
Normal file
0
social/__init__.py
Normal file
37
social/models.py
Normal file
37
social/models.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
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)
|
16
social/tests.py
Normal file
16
social/tests.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
"""
|
||||
This file demonstrates writing tests using the unittest module. These will pass
|
||||
when you run "manage.py test".
|
||||
|
||||
Replace this with more appropriate tests for your application.
|
||||
"""
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
class SimpleTest(TestCase):
|
||||
def test_basic_addition(self):
|
||||
"""
|
||||
Tests that 1 + 1 always equals 2.
|
||||
"""
|
||||
self.assertEqual(1 + 1, 2)
|
1
social/views.py
Normal file
1
social/views.py
Normal file
|
@ -0,0 +1 @@
|
|||
# Create your views here.
|
Loading…
Add table
Reference in a new issue