Пример #1
0
 def obj_create(self, bundle, **kwargs):
     ''' Modifies the content before submission '''
     
     # Add in the user
     bundle.data['user'] = bundle.request.user.username
     
     # Sanitize tags before they get submitted
     try: bundle.data['tags'] = cleanup_tags(bundle.data['tags'])
     except: pass
     
     # These ensure that counts are present if projects are created with tags and backs and comments
     bundle = count_builder(bundle, 'comments',  'comment_count')
     bundle = count_builder(bundle, 'backs',     'back_count')
     bundle = count_builder(bundle, 'tags',      'tag_count')
      
     return super(ProjectResource, self).obj_create(bundle)
Пример #2
0
    def obj_create(self, bundle, **kwargs):
        ''' Modifies the content before submission '''

        # Add in the user
        bundle.data['user'] = bundle.request.user.username

        # Sanitize tags before they get submitted
        try:
            bundle.data['tags'] = cleanup_tags(bundle.data['tags'])
        except:
            pass

        # These ensure that counts are present if projects are created with tags and backs and comments
        bundle = count_builder(bundle, 'comments', 'comment_count')
        bundle = count_builder(bundle, 'backs', 'back_count')
        bundle = count_builder(bundle, 'tags', 'tag_count')

        return super(ProjectResource, self).obj_create(bundle)
Пример #3
0
    def obj_create(self, bundle, **kwargs):
        """ Modifies the content before submission """

        # Add in the user
        bundle.data["user"] = bundle.request.user.username
        # These ensure that counts are present if ideas are created with tags/likes/dislikes and comments
        bundle = count_builder(bundle, "comments", "comment_count")
        bundle = count_builder(bundle, "likes", "like_count")
        bundle = count_builder(bundle, "dislikes", "dislike_count")
        bundle = count_builder(bundle, "tags", "tag_count")

        # Sanitize tags before they get submitted
        try:
            bundle.data["tags"] = cleanup_tags(bundle.data["tags"])
        except:
            pass

        # Finally build the score
        bundle.data["vote_score"] = vote_score(bundle.data["like_count"], bundle.data["dislike_count"])

        return super(IdeaResource, self).obj_create(bundle)
Пример #4
0
    def obj_create(self, bundle, **kwargs):
        """ Modifies the content before submission """

        # Add in the user
        bundle.data['user'] = bundle.request.user.username
        # These ensure that counts are present if ideas are created with tags/likes/dislikes and comments
        bundle = count_builder(bundle, 'comments', 'comment_count')
        bundle = count_builder(bundle, 'likes', 'like_count')
        bundle = count_builder(bundle, 'dislikes', 'dislike_count')
        bundle = count_builder(bundle, 'tags', 'tag_count')

        # Sanitize tags before they get submitted
        try:
            bundle.data['tags'] = cleanup_tags(bundle.data['tags'])
        except:
            pass

        # Finally build the score
        bundle.data['vote_score'] = vote_score(bundle.data['like_count'],
                                               bundle.data['dislike_count'])

        return super(IdeaResource, self).obj_create(bundle)