Skip to content

Commit

Permalink
Fixing create_article view
Browse files Browse the repository at this point in the history
Updating the redirect to my_articles
  • Loading branch information
Shalevro2 committed Jan 18, 2023
1 parent 14c6d60 commit b351da2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
7 changes: 1 addition & 6 deletions projboard/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,7 @@ def test_fill_article_post(client, article, django_capture_on_commit_callbacks):
'user_id': 1,
'content': article.content
})

# Page after the post
template_names = set(tmpl.origin.template_name for tmpl in response.templates)
# TODO change board.html to my_article.html
assert 'landing/homepage.html' in template_names
assert response.status_code == 200
assert response.status_code == 302


@pytest.mark.django_db
Expand Down
5 changes: 2 additions & 3 deletions projboard/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .models.article import Article
from django.shortcuts import render
from django.shortcuts import render, redirect
from .models.user import User
from .models.subject import Subject
from .forms import CreateArticleForm
Expand Down Expand Up @@ -60,8 +60,7 @@ def create_article(request):
form = CreateArticleForm(request.POST, initial={'user_id': user})
if form.is_valid():
form.save()
# TODO when we end to create the "my articles" page, change the redirect
return render(request, 'landing/homepage.html', {'articles': Article.search_by_user(user)})
return redirect(f'/my_articles/{user.nickname}')
elif request.method == "DELETE":
raise Http404()
else:
Expand Down

0 comments on commit b351da2

Please sign in to comment.