circuit
circuit social network code-documentation
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
posts.models.Post Class Reference

Inherits Model.

Public Member Functions

def original_or_self (self)
 
def get_number_of_favorites (self)
 
def get_number_of_reposts (self)
 
def set_post_extra (self, request)
 
def save_hashtags (self, hashtags)
 
def check_repost (self, user)
 
def check_reply (self, user)
 
def __str__ (self)
 

Static Public Member Functions

def parse_content (content)
 
def content_is_valid (content)
 
def image_is_valid (image)
 
def visible_posts_for (user)
 

Static Public Attributes

tuple content = models.CharField(max_length=256)
 
tuple author = models.ForeignKey(User)
 
tuple repost_original = models.ForeignKey('self', null=True, blank=True, related_name='repost')
 
tuple reply_original = models.ForeignKey('self', null=True, blank=True, related_name='reply')
 
tuple created_at = models.DateTimeField(auto_now_add=True)
 
tuple updated_at = models.DateTimeField(auto_now=True)
 
tuple favorites = models.ManyToManyField(User, related_name='favorites')
 
tuple circles = models.ForeignKey(Circle, null=True, blank=True, related_name='circles')
 
tuple image
 

Detailed Description

Post model that stores all information of a post

Member Function Documentation

def posts.models.Post.__str__ (   self)
def posts.models.Post.check_reply (   self,
  user 
)
Checks if a post can be replied to

@param user: the user that wants to reply to a post.

@return: 'not_auth' in case the user isn't authenticated, 'ok' otherwise.
def posts.models.Post.check_repost (   self,
  user 
)
Check if a post can be reposted by a user.

@param self: the post to repost
@param user: the user that wants to repost
@return `ok` if the post can be reposted by the user, a different error string otherwise
def posts.models.Post.content_is_valid (   content)
static
def posts.models.Post.get_number_of_favorites (   self)
def posts.models.Post.get_number_of_reposts (   self)
def posts.models.Post.image_is_valid (   image)
static
def posts.models.Post.original_or_self (   self)
Helper method for getting the original post of a repost.

Loops until the original is found to avoid database inconsistencies.

@return `self.repost_original` if set, `self` otherwise
def posts.models.Post.parse_content (   content)
static
def posts.models.Post.save_hashtags (   self,
  hashtags 
)
def posts.models.Post.set_post_extra (   self,
  request 
)
Add an `extra` attribute to a post for easy information access in a template.

@param self: the post to add extra information to
@param request: the request for which information is added
def posts.models.Post.visible_posts_for (   user)
static
Returns a pre-filtered query object containing all posts visible for the specified user.
@param user: instance of the User model

Member Data Documentation

tuple posts.models.Post.author = models.ForeignKey(User)
static
tuple posts.models.Post.circles = models.ForeignKey(Circle, null=True, blank=True, related_name='circles')
static
tuple posts.models.Post.content = models.CharField(max_length=256)
static
tuple posts.models.Post.created_at = models.DateTimeField(auto_now_add=True)
static
tuple posts.models.Post.favorites = models.ManyToManyField(User, related_name='favorites')
static
tuple posts.models.Post.image
static
Initial value:
1 = models.ImageField(upload_to='tmp/', null=True, blank=True, height_field=None,
2  width_field=None)
tuple posts.models.Post.reply_original = models.ForeignKey('self', null=True, blank=True, related_name='reply')
static
tuple posts.models.Post.repost_original = models.ForeignKey('self', null=True, blank=True, related_name='repost')
static
tuple posts.models.Post.updated_at = models.DateTimeField(auto_now=True)
static

The documentation for this class was generated from the following file: