Commit f26def9409a6a1d221b5c5cfaeeb35d98f28272c
1 parent
715f05d8
Exists in
master
and in
5 other branches
Adding template/view public courses [Issue #190]
Showing
6 changed files
with
208 additions
and
2 deletions
Show diff stats
@@ -0,0 +1,177 @@ | @@ -0,0 +1,177 @@ | ||
1 | +{% extends 'base.html' %} | ||
2 | + | ||
3 | +{% block breadcrumbs %} | ||
4 | + <div class="col-md-12"> | ||
5 | + <form id="searchform" action="{% url 'course:manage' %}" method="get" accept-charset="utf-8"> | ||
6 | + <div class="input-group"> | ||
7 | + <div class="form-group is-empty"> | ||
8 | + <input type="search" class="form-control" placeholder="Search Courses" name="q" id="searchbox"></div> | ||
9 | + <span class="input-group-btn input-group-sm"> | ||
10 | + <button type="button" class="btn btn-fab btn-fab-mini"> | ||
11 | + <i class="material-icons">search</i> | ||
12 | + </button> | ||
13 | + </span> | ||
14 | + </div> | ||
15 | + </form> | ||
16 | + </div> | ||
17 | + | ||
18 | + <div class="col-md-12"> | ||
19 | + <div class="btn-group btn-group-justified btn-group-raised"> | ||
20 | + <a href="?category=all" class="btn btn-raised btn-info">Todos</a> | ||
21 | + {% for category_course in categorys_courses %} | ||
22 | + <a href="?category={{category_course.name}}" class="btn btn-raised btn-primary">{{category_course.name}}</a> | ||
23 | + {% endfor %} | ||
24 | + </div> | ||
25 | + </div> | ||
26 | + | ||
27 | +{% endblock %} | ||
28 | + | ||
29 | + | ||
30 | +{% block content %} | ||
31 | + | ||
32 | + {% for course in courses %} | ||
33 | + <div class="panel panel-info"> | ||
34 | + <div class="panel-heading"> | ||
35 | + <h3 class="panel-title">{{course.name}}</h3> | ||
36 | + </div> | ||
37 | + | ||
38 | + <div class="panel-body"> | ||
39 | + <p><b>Course Name: </b>{{course.name}}</p> | ||
40 | + <p><b>Begining: </b>{{course.init_date}}</p> | ||
41 | + <p><b>End: </b>{{course.end_date}}</p> | ||
42 | + <p><b>Professor: </b>{{course.professors.name}}</p> | ||
43 | + <p> | ||
44 | + <b>Description:</b> | ||
45 | + <i> | ||
46 | + {{course.content}} | ||
47 | + </i> | ||
48 | + </p> | ||
49 | + </div> | ||
50 | + </div> | ||
51 | + {% endfor %} | ||
52 | +{% endblock %} | ||
53 | + | ||
54 | + | ||
55 | + | ||
56 | +{% comment %} | ||
57 | + | ||
58 | + | ||
59 | + | ||
60 | + | ||
61 | +</fieldset> | ||
62 | + <div class="col-md-12"> | ||
63 | + {% if courses|length > 0 %} | ||
64 | + {% if request.GET.category == 'all' or none or request.GET.category == '' %} | ||
65 | + {% for course in list_courses %} | ||
66 | + <div class="panel-group ui-accordion ui-widget ui-helper-reset ui-sortable" id="accordion" role="tablist" aria-multiselectable="false"> | ||
67 | + <div class="group"> | ||
68 | + <div class="panel panel-info"> | ||
69 | + <div class="panel-heading" role="tab"> | ||
70 | + <div class="row"> | ||
71 | + <div class="col-xs-9 col-md-9 titleTopic"> | ||
72 | + <a role="button" data-toggle="collapse" data-parent="#accordion" href=".collapseOne" aria-expanded="false" aria-controls="collapseOne" class="collapsed"> | ||
73 | + <h4 style="color:white">{{course.name}}</h4> | ||
74 | + </a> | ||
75 | + </div> | ||
76 | + </div> | ||
77 | + </div> | ||
78 | + <div class="panel-collapse collapseOne collapse in" role="tabpanel" aria-labelledby="headingOne" aria-expanded="true" aria-hidden="false" tabindex="0"> | ||
79 | + <div class="panel-body"> | ||
80 | + <p><b>Course Name: </b>{{course.name}}</p> | ||
81 | + <p><b>Duration (in semesters): </b>09</p> | ||
82 | + <p><b>Coordinator: </b>{{course.professors}}</p> | ||
83 | + <p> | ||
84 | + <b>Description:</b> | ||
85 | + <i> | ||
86 | + {{course.description}} | ||
87 | + </i> | ||
88 | + </p> | ||
89 | + <a href="{% url 'course:view' course.slug %}" class="btn btn-raised btn-default center-block">'View Course<div class="ripple-container"></div></a> | ||
90 | + </div> | ||
91 | + </div> | ||
92 | + </div> | ||
93 | + </div> | ||
94 | + </div> | ||
95 | + {% endfor %} | ||
96 | + {% else %} | ||
97 | + {% for course in courses_category %} | ||
98 | + {% if course.category.name == request.GET.category %} | ||
99 | + <!-- Put your content here! --> | ||
100 | + <div class="panel-group ui-accordion ui-widget ui-helper-reset ui-sortable" id="accordion" role="tablist" aria-multiselectable="false"> | ||
101 | + <div class="group"> | ||
102 | + <div class="panel panel-info"> | ||
103 | + <div class="panel-heading" role="tab"> | ||
104 | + <div class="row"> | ||
105 | + <div class="col-xs-9 col-md-9 titleTopic"> | ||
106 | + <a role="button" data-toggle="collapse" data-parent="#accordion" href=".collapseOne" aria-expanded="false" aria-controls="collapseOne" class="collapsed"> | ||
107 | + <h4 style="color:white">{{course.name}}</h4> | ||
108 | + </a> | ||
109 | + </div> | ||
110 | + </div> | ||
111 | + </div> | ||
112 | + <div class="panel-collapse collapseOne collapse in" role="tabpanel" aria-labelledby="headingOne" aria-expanded="true" aria-hidden="false" tabindex="0"> | ||
113 | + <div class="panel-body"> | ||
114 | + <p><b>Course Name: </b>{{course.name}}</p> | ||
115 | + <p><b>Duration (in semesters): </b>09</p> | ||
116 | + <p><b>Coordinator: </b>{{course.professors}}</p> | ||
117 | + <p> | ||
118 | + <b>Description:</b> | ||
119 | + <i> | ||
120 | + {{course.description}} | ||
121 | + </i> | ||
122 | + </p> | ||
123 | + <a href="{% url 'course:view' course.slug %}" class="btn btn-raised btn-default center-block">View Course<div class="ripple-container"></div></a> | ||
124 | + </div> | ||
125 | + </div> | ||
126 | + </div> | ||
127 | + </div> | ||
128 | + </div> | ||
129 | + {% endif %} | ||
130 | + {% endfor %} | ||
131 | + {% endif %} | ||
132 | + {% else %} | ||
133 | + No courses found | ||
134 | + {% endif %} | ||
135 | + <div class="group"> | ||
136 | + <div class="modal" id="removeCourse"> | ||
137 | + <div class="modal-dialog"> | ||
138 | + <div class="modal-content"> | ||
139 | + <div class="modal-header"> | ||
140 | + <button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button> | ||
141 | + <h4 class="modal-title"></h4> | ||
142 | + </div> | ||
143 | + <div class="modal-body"> | ||
144 | + <p>Delete your course?</p> | ||
145 | + </div> | ||
146 | + <div class="modal-footer"> | ||
147 | + | ||
148 | + <a href="http://127.0.0.1:8080/html/screens/users/profile_user.html" target="_self"><button type="button" class="btn btn-primary">Confirm</button></a> | ||
149 | + | ||
150 | + </div> | ||
151 | + </div> | ||
152 | + </div> | ||
153 | + </div> | ||
154 | + </div> | ||
155 | + </div> | ||
156 | + <div class="col-md-12"> | ||
157 | + <nav aria-label="Page navigation"> | ||
158 | + <ul class="pagination"> | ||
159 | + {% if page_obj.has_previous %} | ||
160 | + <li> | ||
161 | + <a href="?page={{ page_obj.previous_page_number }}"><span><<</span></a> | ||
162 | + </li> | ||
163 | + {% endif %} | ||
164 | + {% for page_number in paginator.page_range %} | ||
165 | + <li{% if page_obj.number == page_number %} class="active"{% endif %}> | ||
166 | + <a href="?page={{ page_number }}">{{ page_number }}</a> | ||
167 | + </li> | ||
168 | + {% endfor %} | ||
169 | + {% if page_obj.has_next %} | ||
170 | + <li> | ||
171 | + <a href="?page={{ page_obj.next_page_number }}"><span>>></span></a> | ||
172 | + </li> | ||
173 | + {% endif %} | ||
174 | + </ul> | ||
175 | + </nav> | ||
176 | + </div> | ||
177 | +{% endcomment %} |
core/templates/index.html
@@ -64,7 +64,7 @@ | @@ -64,7 +64,7 @@ | ||
64 | {# </div> #} | 64 | {# </div> #} |
65 | {# <div class="row"> #} | 65 | {# <div class="row"> #} |
66 | <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6 text-center"> | 66 | <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6 text-center"> |
67 | - <button type="button" class="btn btn-flat" formaction="#" style="position: initial;">{% trans 'Guest' %}</button> | 67 | + <a class="btn btn-flat" href="{% url 'core:guest' %}" formaction="#" style="position: initial;">{% trans 'Guest' %}</a> |
68 | </div> | 68 | </div> |
69 | <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6 text-center"> | 69 | <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6 text-center"> |
70 | <button type="submite" class="btn btn-flat btn-success" form="form-login" style="position: initial;">{% trans 'Login' %}</button> | 70 | <button type="submite" class="btn btn-flat btn-success" form="form-login" style="position: initial;">{% trans 'Login' %}</button> |
core/urls.py
@@ -11,6 +11,7 @@ urlpatterns = [ | @@ -11,6 +11,7 @@ urlpatterns = [ | ||
11 | url(r'^logout/$', auth_views.logout, {'next_page': 'core:home'}, name='logout'), | 11 | url(r'^logout/$', auth_views.logout, {'next_page': 'core:home'}, name='logout'), |
12 | url(r'^notification/([0-9]+)/$', views.processNotification, name='notification_read'), | 12 | url(r'^notification/([0-9]+)/$', views.processNotification, name='notification_read'), |
13 | url(r'^getNotifications/$', views.getNotifications, name='getNotifications'), | 13 | url(r'^getNotifications/$', views.getNotifications, name='getNotifications'), |
14 | + url(r'^guest/$', views.guest, name='guest'), | ||
14 | 15 | ||
15 | #Reset Password | 16 | #Reset Password |
16 | 17 |
core/views.py
@@ -18,7 +18,7 @@ from .forms import RegisterUserForm | @@ -18,7 +18,7 @@ from .forms import RegisterUserForm | ||
18 | from .decorators import log_decorator, notification_decorator | 18 | from .decorators import log_decorator, notification_decorator |
19 | 19 | ||
20 | from users.models import User | 20 | from users.models import User |
21 | - | 21 | +from courses.models import Course, CourseCategory |
22 | 22 | ||
23 | def index(request): | 23 | def index(request): |
24 | context = { | 24 | context = { |
@@ -113,3 +113,9 @@ def getNotifications(request): | @@ -113,3 +113,9 @@ def getNotifications(request): | ||
113 | 113 | ||
114 | html = render_to_string("notifications.html", context) | 114 | html = render_to_string("notifications.html", context) |
115 | return HttpResponse(html) | 115 | return HttpResponse(html) |
116 | + | ||
117 | +def guest (request): | ||
118 | + context = { | ||
119 | + 'courses': Course.objects.filter(public=True) | ||
120 | + } | ||
121 | + return render(request, 'guest.html', context) | ||
116 | \ No newline at end of file | 122 | \ No newline at end of file |
@@ -0,0 +1,21 @@ | @@ -0,0 +1,21 @@ | ||
1 | +# -*- coding: utf-8 -*- | ||
2 | +# Generated by Django 1.10 on 2016-10-19 13:19 | ||
3 | +from __future__ import unicode_literals | ||
4 | + | ||
5 | +from django.db import migrations, models | ||
6 | + | ||
7 | + | ||
8 | +class Migration(migrations.Migration): | ||
9 | + | ||
10 | + dependencies = [ | ||
11 | + ('courses', '0002_auto_20161018_1842'), | ||
12 | + ] | ||
13 | + | ||
14 | + operations = [ | ||
15 | + migrations.AddField( | ||
16 | + model_name='course', | ||
17 | + name='public', | ||
18 | + field=models.BooleanField(default=False, verbose_name='Public'), | ||
19 | + preserve_default=False, | ||
20 | + ), | ||
21 | + ] |
courses/models.py
@@ -46,6 +46,7 @@ class Course(models.Model): | @@ -46,6 +46,7 @@ class Course(models.Model): | ||
46 | category = models.ForeignKey(CourseCategory, verbose_name = _('Category'), related_name='course_category') | 46 | category = models.ForeignKey(CourseCategory, verbose_name = _('Category'), related_name='course_category') |
47 | professors = models.ManyToManyField(User,verbose_name=_('Professors'), related_name='courses_professors') | 47 | professors = models.ManyToManyField(User,verbose_name=_('Professors'), related_name='courses_professors') |
48 | students = models.ManyToManyField(User,verbose_name=_('Students'), related_name='courses_student') | 48 | students = models.ManyToManyField(User,verbose_name=_('Students'), related_name='courses_student') |
49 | + public = models.BooleanField(_('Public')) | ||
49 | 50 | ||
50 | class Meta: | 51 | class Meta: |
51 | ordering = ('create_date','name') | 52 | ordering = ('create_date','name') |