Exemple #1
0
 def to_form_data(self):
     return to_json(self, (
         ('blog', 'blog__form'),
         'title',
         'text',
         'type',
         'addition',
         'raw_tags',
     ))
Exemple #2
0
 def change_action(request, post_id):
     post = get_object_or_404(Post, id=post_id)
     try:
         obj = model.objects.get(
             user=request.user, post=post,
         )
         obj.delete()
     except model.DoesNotExist:
         model.objects.create(
             user=request.user, post=post,
         )
     return to_json(post)
Exemple #3
0
 def rate_fnc(request, id, value):
     """Rate function"""
     value = +1 if value else -1
     obj = get_object_or_404(cls, id=id)
     if request.get_profile.check_access(permission):
         if action(obj, request.user, value):
             return to_json(obj)
         else:
             return {
                 'error': _(u'Rating allowed once a time')
             }
     else:
         return {
             'error': _(u'Permission denied'),
         }
Exemple #4
0
def post_options(request, post_id, disable_rate, disable_reply, pinch):
    """Change post options"""
    post = get_object_or_404(Post, id=post_id)
    form = PostOptions({
        'disable_rate': disable_rate,
        'disable_reply': disable_reply,
        'pinch': pinch,
    }, instance=post)
    if form.is_valid():
        post = form.save()
        return to_json(post)
    else:
        return {
            'error': form.errors,
        }
Exemple #5
0
 def user__json(self):
     return to_json(self.user)
Exemple #6
0
 def author__json(self):
     return to_json(self.authr)
Exemple #7
0
 def post__json(self):
     return to_json(self.post)
Exemple #8
0
 def blog__json(self):
     return to_json(self.blog)
 def post__json(self):
     return to_json(self.post)
 def user__json(self):
     return to_json(self.user)
 def author__json(self):
     return to_json(self.authr)
 def to_form_data(self):
     return to_json(self, (
         ('blog', 'blog__form'),
         'title', 'text', 'type',
         'addition', 'raw_tags',
     ))
 def blog__json(self):
     return to_json(self.blog)