Example #1
0
 def get_context_data(self, **kwargs):
     context = super(HomeView, self).get_context_data(**kwargs)
     context['is_admin'] = is_admin(self.request.user)
     articles = wordpress.fetch_articles()
     context['articles'] = articles
     context['photos'] = Photo.objects.filter(display_in_gallery=True).order_by('-date')[0:8].select_related()
     return context
Example #2
0
def delete_article_comment(request, *args, **kwargs):

    if request.is_ajax() and request.method == 'POST':
        if (not request.user.is_authenticated()):
            data = {
                'success': False,
                'message': 'Please login to delete comment'
            }

        comment_id = kwargs.get('pk')
        comment = ArticleComment.objects.get(id=comment_id)

        if (request.user == comment.author or is_admin(request.user)):
            comment.delete()
            data = {'success': True}
        else:
            data = {
                'success': False,
                'message': 'You are not the author of the comment'
            }

        return HttpResponse(simplejson.dumps(data),
                            mimetype='application/json')
    else:
        return HttpResponseNotAllowed()
Example #3
0
 def get_context_data(self, **kwargs):
     context = super(HomeView, self).get_context_data(**kwargs)
     context['is_admin'] = is_admin(self.request.user)
     articles = wordpress.fetch_articles()
     context['articles'] = articles
     context['photos'] = Photo.objects.filter(
         display_in_gallery=True).order_by('-date')[0:8].select_related()
     return context
Example #4
0
def delete_article_comment(request, *args, **kwargs):
    
    if request.is_ajax() and request.method == 'POST':
        if (not request.user.is_authenticated()):
            data = {'success': False, 'message': 'Please login to delete comment'}
        
        comment_id = kwargs.get('pk')
        comment = ArticleComment.objects.get(id=comment_id)
        
        if (request.user == comment.author or is_admin(request.user)):
            comment.delete()
            data = {'success': True}
        else:
            data = {'success': False, 'message': 'You are not the author of the comment'}
        
        return HttpResponse(simplejson.dumps(data), mimetype='application/json')
    else:
        return HttpResponseNotAllowed()