Skip to content

Commit

Permalink
Adding costants for categories.html and read_more.html
Browse files Browse the repository at this point in the history
  • Loading branch information
orIsrael committed Apr 21, 2022
1 parent e4e472c commit 4d7ec56
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions tips/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
TIPS_PAGE_ROUTE = 'tips/index.html'
ADD_TIP_PAGE_ROUTE = 'tips/add_tip.html'
EDIT_TIP_PAGE_ROUTE = 'tips/edit_tip.html'
READ_MORE_PAGE_ROUTE = 'tips/read_more.html'
CATEGORIES_PAGE_ROUT = 'tips/categories.html'
2 changes: 1 addition & 1 deletion tips/templates/tips/read_more.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ <h3 class="md-heading"><a href="#">{{ tip.author }}</a></h3>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
</body>
{% endblock %}
{% endblock %}
6 changes: 3 additions & 3 deletions tips/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.shortcuts import render, redirect, get_object_or_404
from .models import Tip
from .forms import TipForm
from .constants import TIPS_PAGE_ROUTE, ADD_TIP_PAGE_ROUTE, EDIT_TIP_PAGE_ROUTE
from .constants import TIPS_PAGE_ROUTE, ADD_TIP_PAGE_ROUTE, EDIT_TIP_PAGE_ROUTE, READ_MORE_PAGE_ROUTE, CATEGORIES_PAGE_ROUT


def board(request):
Expand All @@ -22,12 +22,12 @@ def add_tip(request):

def categories_filter(request, cats):
category_filtered_tips = Tip.objects.filter(category=cats)
return render(request, 'tips/categories.html', {'cats': cats, 'category_filtered_tips': category_filtered_tips})
return render(request, CATEGORIES_PAGE_ROUT, {'cats': cats, 'category_filtered_tips': category_filtered_tips})


def read_more_view(request, tip_id):
tip = get_object_or_404(Tip, pk=tip_id)
return render(request, 'tips/read_more.html', {'tip': tip})
return render(request, READ_MORE_PAGE_ROUTE, {'tip': tip})


def edit_tip(request, tip_id):
Expand Down

0 comments on commit 4d7ec56

Please sign in to comment.