all_events

This commit is contained in:
Mikhail Ronchyk 2021-12-20 04:19:35 +03:00
parent 5f10a6f405
commit 95fc21166c
8 changed files with 84 additions and 29 deletions

View File

@ -8,7 +8,7 @@ import Login from './Pages/Login';
import SearchEvent from './Pages/SearchEvent';
import Calendar from './Pages/Calendar';
import FBfanpage from './Pages/FBfanpage';
import views from '../../views.py'
function App() {
return (

View File

@ -76,6 +76,9 @@ function Home() {
<h1>Witamy na stronie HighNeed </h1>
<p>HighNeed.pl jest portalem do planowania aktywności dla rodzin z dziećmi w Poznaniu.</p>
</div>
</div>
<div class='line'></div>

View File

@ -0,0 +1,52 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Events</title>
</head>
<body>
{% block content %}
<nav>
<h1 class="cat">Events:</h1>
{% for i in latest_news_list %}
<p>Nazwa: {{ i.title }}</p><b></b>
<p>Data: {{ i.data }}</p><b></b>
<p>Miasto: {{ i.place }}</p><b></b>
<p>Opublikowane: {{ i.pub_date }}</p><br>
{% endfor %}
</nav>
{% endblock %}
<nav aria-label="Page navigation">
{% if users.has_other_pages %}
<ul class="pagination">
{% if users.has_previous %}
<li><a href="?page={{ users.previous_page_number }}">&laquo;</a></li>
{% else %}
<li class="disabled"><span>&laquo;</span></li>
{% endif %}
{% for i in users.paginator.page_range %}
{% if users.number == i %}
<li class="active"><span>{{ i }} <span class="sr-only">(current)</span></span></li>
{% else %}
<li><a href="?page={{ i }}">{{ i }}</a></li>
{% endif %}
{% endfor %}
{% if users.has_next %}
<li><a href="?page={{ users.next_page_number }}">&raquo;</a></li>
{% else %}
<li class="disabled"><span>&raquo;</span></li>
{% endif %}
</ul>
{% endif %}
</nav>
<br>
<br>
<br>
</body>
</html>

View File

@ -24,14 +24,15 @@
{% endif %}
{% endblock %}
<p><a href="{% url 'events' %}">Zobacz Wydarzenia</a></p>
<p><a href="add_event/">Stwórz Wydarzenie</a></p>
<br>
<p>All {{ numofnews }} news</p>
<br>
<nav>
<h1 class="cat">Events:</h1>
{% for i in latest_news_list %}
<p>Nazwa: {{ i.title }}</p><b></b>
<p>Data: {{ i.data }}</p><b></b>
@ -39,32 +40,6 @@
<p>Opublikowane: {{ i.pub_date }}</p><br>
{% endfor %}
</nav>
<br>
<br>
<nav aria-label="Page navigation">
{% if users.has_other_pages %}
<ul class="pagination">
{% if users.has_previous %}
<li><a href="?page={{ users.previous_page_number }}">&laquo;</a></li>
{% else %}
<li class="disabled"><span>&laquo;</span></li>
{% endif %}
{% for i in users.paginator.page_range %}
{% if users.number == i %}
<li class="active"><span>{{ i }} <span class="sr-only">(current)</span></span></li>
{% else %}
<li><a href="?page={{ i }}">{{ i }}</a></li>
{% endif %}
{% endfor %}
{% if users.has_next %}
<li><a href="?page={{ users.next_page_number }}">&raquo;</a></li>
{% else %}
<li class="disabled"><span>&raquo;</span></li>
{% endif %}
</ul>
{% endif %}
</nav>
<br>
<div id="disqus_thread"></div>
<script>

View File

@ -30,6 +30,30 @@ def index(request):
return render(request, 'profil.html', context)
def events(request):
latest_news_list = Event.objects.order_by('-pub_date')
page = request.GET.get('page', 1)
paginator = Paginator(latest_news_list, 10)
numofnews = len(Event.objects.all())
try:
users = paginator.page(page)
except PageNotAnInteger:
users = paginator.page(1)
except EmptyPage:
users = paginator.page(paginator.num_pages)
context = {
'latest_news_list': latest_news_list,
'Title': Event.title,
'Data': Event.data,
'Place': Event.place,
'numofnews': numofnews,
}
return render(request, 'events/all_events.html', context)
def create(request):
if request.method == "POST":

View File

@ -26,5 +26,6 @@ urlpatterns = [
path('accounts/', include('allauth.urls')),
path('profil/', views.index, name='profil'),
path('profil/add_event/', views.create),
path('all_events/', views.events, name='events'),
#path('profil/add_event/', TemplateView.as_view(template_name='add_event.html')),
]