def get(self, request, pk): article = get_articles(pk=pk)[0] if article: if request.user != article.author and not request.user.is_staff: context = {'message': 'You don\'t have permission for that'} return render(request, self.template_name, context) form = ArticleForm(instance=article) context = {'form': form, 'message': 'Edit you article'} else: context = get_context_from_articles(article) return render(request, self.template_name, context)
def get(self, request, pk): article = get_articles(pk=pk)[0] if article: if request.user != article.author and not request.user.is_staff: context = { 'success': False, 'message': 'You don\'t have permission for that' } return render(request, self.template_name, context) context = { 'success': True, 'message': f'Are you sure you want to delete {article.title}' } else: context = get_context_from_articles(article) return render(request, self.template_name, context)
def get(self, request, slug_username): articles = get_articles(author__username=slug_username) context = get_context_from_articles(articles) context.update({'articles_owner': slug_username}) return render(request, self.template_name, context)
def get(self, request, pk): article = get_articles(pk=pk) form = CommentForm context = get_context_from_articles(article) context.update({'form': form}) return render(request, self.template_name, context)
def get(self, request): articles = get_articles() return render(request, self.template_name, get_context_from_articles(articles))