Commit a5a2274e3909e2152704685954bb48121c1fae9b
Exists in
master
and in
5 other branches
Merge branch 'dev' of https://github.com/amadeusproject/amadeuslms into dev
Showing
2 changed files
with
36 additions
and
20 deletions
Show diff stats
core/templates/guest.html
@@ -90,21 +90,6 @@ | @@ -90,21 +90,6 @@ | ||
90 | </div> | 90 | </div> |
91 | <div class="col-xs-10 col-sm-10 col-md-10 col-lg-10 col-xl-10"> | 91 | <div class="col-xs-10 col-sm-10 col-md-10 col-lg-10 col-xl-10"> |
92 | {% block breadcrumbs %} | 92 | {% block breadcrumbs %} |
93 | - | ||
94 | - <div class="col-md-12"> | ||
95 | - <form id="searchform" action="{% url 'course:manage' %}" method="get" accept-charset="utf-8"> | ||
96 | - <div class="input-group"> | ||
97 | - <div class="form-group is-empty"> | ||
98 | - <input type="search" class="form-control" placeholder="{% trans 'Search Courses' %}" name="q" id="searchbox"></div> | ||
99 | - <span class="input-group-btn input-group-sm"> | ||
100 | - <button type="button" class="btn btn-fab btn-fab-mini"> | ||
101 | - <i class="material-icons">search</i> | ||
102 | - </button> | ||
103 | - </span> | ||
104 | - </div> | ||
105 | - </form> | ||
106 | - </div> | ||
107 | - | ||
108 | {% endblock %} | 93 | {% endblock %} |
109 | {% block render_breadcrumbs %}{% endblock %} | 94 | {% block render_breadcrumbs %}{% endblock %} |
110 | <div> | 95 | <div> |
@@ -133,6 +118,27 @@ | @@ -133,6 +118,27 @@ | ||
133 | </div> | 118 | </div> |
134 | {% endfor %} | 119 | {% endfor %} |
135 | </div> | 120 | </div> |
121 | + <div class="col-md-12"> | ||
122 | + <nav aria-label="Page navigation"> | ||
123 | + <ul class="pagination"> | ||
124 | + {% if page_obj.has_previous %} | ||
125 | + <li> | ||
126 | + <a href="?page={{ page_obj.previous_page_number }}"><span><<</span></a> | ||
127 | + </li> | ||
128 | + {% endif %} | ||
129 | + {% for page_number in paginator.page_range %} | ||
130 | + <li{% if page_obj.number == page_number %} class="active"{% endif %}> | ||
131 | + <a href="?page={{ page_number }}">{{ page_number }}</a> | ||
132 | + </li> | ||
133 | + {% endfor %} | ||
134 | + {% if page_obj.has_next %} | ||
135 | + <li> | ||
136 | + <a href="?page={{ page_obj.next_page_number }}"><span>>></span></a> | ||
137 | + </li> | ||
138 | + {% endif %} | ||
139 | + </ul> | ||
140 | + </nav> | ||
141 | + </div> | ||
136 | {% endblock %} | 142 | {% endblock %} |
137 | </div> | 143 | </div> |
138 | </div> | 144 | </div> |
core/views.py
@@ -14,6 +14,8 @@ from core.mixins import NotificationMixin | @@ -14,6 +14,8 @@ from core.mixins import NotificationMixin | ||
14 | from .models import Notification, Log | 14 | from .models import Notification, Log |
15 | from rolepermissions.shortcuts import assign_role | 15 | from rolepermissions.shortcuts import assign_role |
16 | from django.contrib.auth.decorators import login_required | 16 | from django.contrib.auth.decorators import login_required |
17 | +from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger | ||
18 | + | ||
17 | #API REST IMPORTS | 19 | #API REST IMPORTS |
18 | from .serializers import LogSerializer | 20 | from .serializers import LogSerializer |
19 | from rest_framework import status, serializers, permissions, viewsets | 21 | from rest_framework import status, serializers, permissions, viewsets |
@@ -103,16 +105,24 @@ class GuestView (ListView): | @@ -103,16 +105,24 @@ class GuestView (ListView): | ||
103 | 105 | ||
104 | template_name = 'guest.html' | 106 | template_name = 'guest.html' |
105 | context_object_name = 'courses' | 107 | context_object_name = 'courses' |
108 | + queryset = CourseCategory.objects.all() | ||
106 | paginate_by = 10 | 109 | paginate_by = 10 |
107 | 110 | ||
108 | - def get_queryset(self): | ||
109 | - return Course.objects.filter(public=True) | ||
110 | - | ||
111 | - | ||
112 | def get_context_data (self, **kwargs): | 111 | def get_context_data (self, **kwargs): |
113 | context = super(GuestView, self).get_context_data(**kwargs) | 112 | context = super(GuestView, self).get_context_data(**kwargs) |
114 | - context['categorys_courses'] = CourseCategory.objects.all() | ||
115 | context['title'] = _("Guest") | 113 | context['title'] = _("Guest") |
114 | + queryset_list = CourseCategory.objects.all() | ||
115 | + | ||
116 | + paginator = Paginator(queryset_list, 10) | ||
117 | + page = self.request.GET.get('page') | ||
118 | + try: | ||
119 | + queryset_list = paginator.page(page) | ||
120 | + except PageNotAnInteger: | ||
121 | + queryset_list = paginator.page(1) | ||
122 | + except EmptyPage: | ||
123 | + queryset_list = paginator.page(paginator.num_pages) | ||
124 | + | ||
125 | + context['categorys_courses'] = queryset_list | ||
116 | return context | 126 | return context |
117 | 127 | ||
118 | 128 |