Commit 4380a034a050434c4a6cba596447b66dd1d5a689
1 parent
47bb038f
Exists in
master
and in
5 other branches
Fixing template/view [Issue #190]
Showing
3 changed files
with
164 additions
and
176 deletions
Show diff stats
core/templates/guest.html
1 | -{% extends 'base.html' %} | |
1 | +<!DOCTYPE html> | |
2 | 2 | |
3 | +{% load static i18n %} | |
3 | 4 | {% load i18n custom_filters %} |
4 | 5 | |
5 | -{% block breadcrumbs %} | |
6 | - <div class="col-md-12"> | |
7 | - <form id="searchform" action="{% url 'course:manage' %}" method="get" accept-charset="utf-8"> | |
8 | - <div class="input-group"> | |
9 | - <div class="form-group is-empty"> | |
10 | - <input type="search" class="form-control" placeholder="Search Courses" name="q" id="searchbox"></div> | |
11 | - <span class="input-group-btn input-group-sm"> | |
12 | - <button type="button" class="btn btn-fab btn-fab-mini"> | |
13 | - <i class="material-icons">search</i> | |
14 | - </button> | |
15 | - </span> | |
16 | - </div> | |
17 | - </form> | |
18 | - </div> | |
19 | - | |
20 | - <div class="col-md-12"> | |
21 | - <div class="btn-group btn-group-justified btn-group-raised"> | |
22 | - <a href="?category=all" class="btn btn-raised btn-info">Todos</a> | |
23 | - {% for category_course in categorys_courses %} | |
24 | - <a href="?category={{category_course.name}}" class="btn btn-raised btn-primary">{{category_course.name}}</a> | |
25 | - {% endfor %} | |
26 | - </div> | |
27 | - </div> | |
28 | - | |
29 | -{% endblock %} | |
30 | - | |
31 | - | |
32 | -{% block content %} | |
33 | - | |
34 | - {% for course in courses %} | |
35 | - <div class="panel panel-info"> | |
36 | - <div class="panel-heading"> | |
37 | - <h3 class="panel-title"> | |
38 | - {{course.name}} | |
39 | - {% if user|show_course_subscribe:course %} | |
40 | - <div class="pull-right" style="margin-top:-15px"> | |
41 | - <a onclick="subscribe($(this), '{% url 'course:subscribe' course.slug %}' , '{% trans 'Are you sure you want to subscribe to this subject?' %}')" class="btn btn-sm btn-primary btn-raised">{% trans 'Subscribe' %}</a> | |
42 | - </div> | |
43 | - {% endif %} | |
44 | - </h3> | |
45 | - </div> | |
46 | - | |
47 | - <div class="panel-body"> | |
48 | - <p><b>Course Name: </b>{{course.name}}</p> | |
49 | - <p><b>Begining: </b>{{course.init_date}}</p> | |
50 | - <p><b>End: </b>{{course.end_date}}</p> | |
51 | - <p><b>Professor: </b>{{course.professors.name}}</p> | |
52 | - <p> | |
53 | - <b>Description:</b> | |
54 | - <i> | |
55 | - {{course.content}} | |
56 | - </i> | |
57 | - </p> | |
58 | - </div> | |
59 | - </div> | |
60 | - {% endfor %} | |
61 | -{% endblock %} | |
62 | - | |
63 | - | |
64 | - | |
65 | -{% comment %} | |
66 | - | |
67 | - | |
68 | - | |
6 | +<html> | |
7 | +<head> | |
8 | + <title>{{ title }}</title> | |
9 | + | |
10 | + <meta http-equiv="Cache-Control" content="no-cache, no-store" /> | |
11 | + <link href="{% static 'img/favicon.ico' %}" rel="shortcut icon" /> | |
12 | + <!-- Roboto font --> | |
13 | + <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:300,400,500,700" type="text/css"> | |
14 | + <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> | |
15 | + | |
16 | + <!-- jQuery & jQuery UI --> | |
17 | + <script type="text/javascript" src="{% static 'js/vendor/jquery-3.1.0.min.js' %}"></script> | |
18 | + <script type="text/javascript" src="{% static 'js/vendor/jquery-ui.js' %}"></script> | |
19 | + | |
20 | + <!-- Bootstrap and themes (material) --> | |
21 | + <link rel="stylesheet" type="text/css" href="{% static 'bootstrap-3.3.7/css/bootstrap.css' %}"> | |
22 | + <link rel="stylesheet" type="text/css" href="{% static 'css/vendor/material.min.css' %}"> | |
23 | + <link rel="stylesheet" type="text/css" href="{% static 'css/vendor/ripples.min.css' %}"> | |
24 | + <link rel="stylesheet" type="text/css" href="{% static 'css/vendor/datepicker.css' %}"> | |
25 | + <link rel="stylesheet" type="text/css" href="{% static 'css/vendor/alertifyjs/alertify.min.css' %}"> | |
26 | + <link rel="stylesheet" type="text/css" href="{% static 'css/vendor/alertifyjs/themes/bootstrap.css' %}"> | |
27 | + <script type="text/javascript" src="{% static 'bootstrap-3.3.7/js/bootstrap.js' %}"></script> | |
28 | + <script type="text/javascript" src="{% static 'js/vendor/bootstrap-acessibility.min.js' %}"></script> | |
29 | + <script type="text/javascript" src="{% static 'js/vendor/material.min.js' %}"></script> | |
30 | + <script type="text/javascript" src="{% static 'js/vendor/ripples.min.js' %}"></script> | |
31 | + <script type="text/javascript" src="{% static 'js/vendor/bootstrap-datepicker.js' %}"></script> | |
32 | + <script type="text/javascript" src="{% static 'js/vendor/alertify.min.js' %}"></script> | |
33 | + | |
34 | + <!-- Font awesome --> | |
35 | + <link rel="stylesheet" type="text/css" href="{% static 'font-awesome-4.6.3/css/font-awesome.min.css' %}"> | |
36 | + | |
37 | + <!-- Custom styles --> | |
38 | + <link rel="stylesheet" type="text/css" href="{% static 'css/base/amadeus.css' %}"> | |
39 | + | |
40 | + <!-- Init material Bootstrap --> | |
41 | + <script type="text/javascript">$.material.init()</script> | |
42 | + | |
43 | + <!--Javascript block for specific-app ones --> | |
44 | + <script src="{% static 'js/base/amadeus.js' %}"></script> | |
45 | + {% block style %} | |
46 | + {% endblock %} | |
47 | + {% block javascript %} | |
48 | + {% endblock %} | |
49 | +</head> | |
50 | +<body> | |
51 | + {% block nav %} | |
52 | + <div class="navbar navbar-default"> | |
53 | + <div class="navbar-header"> | |
54 | + <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse"> | |
55 | + <span class="icon-bar"></span> | |
56 | + <span class="icon-bar"></span> | |
57 | + <span class="icon-bar"></span> | |
58 | + </button> | |
59 | + <a class="navbar-brand" href="{% url 'app:index' %}"><img class="logo" src="{% static 'img/topo-amadeus-white.png' %}" alt="Logo"/></a> | |
60 | + </div> | |
61 | + <div class="navbar-collapse collapse navbar-responsive-collapse"> | |
62 | + <ul class="nav navbar-nav navbar-right notifications"> | |
63 | + <li class="" data-toggle="tooltip" data-placement="bottom" title data-original-title="notifications"> | |
64 | + <a class="dropdown-toggle" data-toggle="dropdown"> <span id="notification-count" class="badge notification-count">{{notifications.count}}</span><i class="fa fa-bell" aria-hidden="true"></i></a> | |
65 | + <ul id="notification-dropdown" class="dropdown-menu"> | |
66 | + <li class="dropdown-header">Notifications</li> | |
67 | + {% include "notifications.html" %} | |
68 | + | |
69 | + <li> | |
70 | + <a onclick="getNotifications(5)"> | |
71 | + <div id="notification-see-more" class="list-group-item"> | |
72 | + <div class="row-content"> | |
73 | + <p class="list-group-item-text">See More</p> | |
74 | + </div> | |
75 | + </a> | |
76 | + </li> | |
77 | + </ul> | |
78 | + </li> | |
79 | + | |
80 | + <li data-toggle="tooltip" data-placement="bottom" title data-original-title="{% trans 'messages' %}"> <a href="#"><i class="fa fa-comments" aria-hidden="true"></i></a> </li> | |
81 | + <li > <a class="link" href="{% url 'app:index' %}">{{ user }}</a></li> | |
82 | + | |
83 | + </ul> | |
84 | + </div> | |
85 | + </div> | |
86 | + {% endblock %} | |
87 | + <div class="container-fluid"> | |
88 | + <div class="row"> | |
89 | + | |
90 | + <div class="col-xs-2 col-sm-2 col-md-2 col-lg-2 col-xl-2"> | |
91 | + {% block sidebar %} | |
92 | + <div class="panel panel-primary navigation"> | |
93 | + <div class="panel-heading"> | |
94 | + <h4>Menu</h4> | |
95 | + </div> | |
96 | + <div class="panel-body"> | |
97 | + <ul class="nav nav-pills nav-stacked"> | |
98 | + <li><a href="{% url 'core:register' %}">{% trans 'Register' %}</a></li> | |
99 | + </ul> | |
100 | + </div> | |
101 | + </div> | |
102 | + {% endblock %} | |
103 | + | |
104 | + </div> | |
105 | + <div class="col-xs-10 col-sm-10 col-md-10 col-lg-10 col-xl-10"> | |
106 | + {% block breadcrumbs %} | |
107 | + <div class="col-md-12"> | |
108 | + <form id="searchform" action="{% url 'course:manage' %}" method="get" accept-charset="utf-8"> | |
109 | + <div class="input-group"> | |
110 | + <div class="form-group is-empty"> | |
111 | + <input type="search" class="form-control" placeholder="Search Courses" name="q" id="searchbox"></div> | |
112 | + <span class="input-group-btn input-group-sm"> | |
113 | + <button type="button" class="btn btn-fab btn-fab-mini"> | |
114 | + <i class="material-icons">search</i> | |
115 | + </button> | |
116 | + </span> | |
117 | + </div> | |
118 | + </form> | |
119 | + </div> | |
69 | 120 | |
70 | -</fieldset> | |
71 | - <div class="col-md-12"> | |
72 | - {% if courses|length > 0 %} | |
73 | - {% if request.GET.category == 'all' or none or request.GET.category == '' %} | |
74 | - {% for course in list_courses %} | |
75 | - <div class="panel-group ui-accordion ui-widget ui-helper-reset ui-sortable" id="accordion" role="tablist" aria-multiselectable="false"> | |
76 | - <div class="group"> | |
77 | - <div class="panel panel-info"> | |
78 | - <div class="panel-heading" role="tab"> | |
79 | - <div class="row"> | |
80 | - <div class="col-xs-9 col-md-9 titleTopic"> | |
81 | - <a role="button" data-toggle="collapse" data-parent="#accordion" href=".collapseOne" aria-expanded="false" aria-controls="collapseOne" class="collapsed"> | |
82 | - <h4 style="color:white">{{course.name}}</h4> | |
83 | - </a> | |
84 | - </div> | |
85 | - </div> | |
86 | - </div> | |
87 | - <div class="panel-collapse collapseOne collapse in" role="tabpanel" aria-labelledby="headingOne" aria-expanded="true" aria-hidden="false" tabindex="0"> | |
88 | - <div class="panel-body"> | |
89 | - <p><b>Course Name: </b>{{course.name}}</p> | |
90 | - <p><b>Duration (in semesters): </b>09</p> | |
91 | - <p><b>Coordinator: </b>{{course.professors}}</p> | |
92 | - <p> | |
93 | - <b>Description:</b> | |
94 | - <i> | |
95 | - {{course.description}} | |
96 | - </i> | |
97 | - </p> | |
98 | - <a href="{% url 'course:view' course.slug %}" class="btn btn-raised btn-default center-block">'View Course<div class="ripple-container"></div></a> | |
99 | - </div> | |
100 | - </div> | |
101 | - </div> | |
121 | + <div class="col-md-12"> | |
122 | + <div class="btn-group btn-group-justified btn-group-raised"> | |
123 | + <a href="?category=all" class="btn btn-raised btn-info">Todos</a> | |
124 | + {% for category in categories %} | |
125 | + <a href="?category={{category.name}}" class="btn btn-raised btn-primary">{{category.name}}</a> | |
126 | + {% endfor %} | |
102 | 127 | </div> |
103 | 128 | </div> |
104 | - {% endfor %} | |
105 | - {% else %} | |
106 | - {% for course in courses_category %} | |
107 | - {% if course.category.name == request.GET.category %} | |
108 | - <!-- Put your content here! --> | |
109 | - <div class="panel-group ui-accordion ui-widget ui-helper-reset ui-sortable" id="accordion" role="tablist" aria-multiselectable="false"> | |
110 | - <div class="group"> | |
129 | + | |
130 | + {% endblock %} | |
131 | + {% block render_breadcrumbs %}{% endblock %} | |
132 | + <div> | |
133 | + </div> | |
134 | + <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12"> | |
135 | + {% block content %} | |
136 | + {% for course in courses %} | |
111 | 137 | <div class="panel panel-info"> |
112 | - <div class="panel-heading" role="tab"> | |
113 | - <div class="row"> | |
114 | - <div class="col-xs-9 col-md-9 titleTopic"> | |
115 | - <a role="button" data-toggle="collapse" data-parent="#accordion" href=".collapseOne" aria-expanded="false" aria-controls="collapseOne" class="collapsed"> | |
116 | - <h4 style="color:white">{{course.name}}</h4> | |
117 | - </a> | |
118 | - </div> | |
119 | - </div> | |
120 | - </div> | |
121 | - <div class="panel-collapse collapseOne collapse in" role="tabpanel" aria-labelledby="headingOne" aria-expanded="true" aria-hidden="false" tabindex="0"> | |
122 | - <div class="panel-body"> | |
123 | - <p><b>Course Name: </b>{{course.name}}</p> | |
124 | - <p><b>Duration (in semesters): </b>09</p> | |
125 | - <p><b>Coordinator: </b>{{course.professors}}</p> | |
126 | - <p> | |
127 | - <b>Description:</b> | |
128 | - <i> | |
129 | - {{course.description}} | |
130 | - </i> | |
131 | - </p> | |
132 | - <a href="{% url 'course:view' course.slug %}" class="btn btn-raised btn-default center-block">View Course<div class="ripple-container"></div></a> | |
133 | - </div> | |
134 | - </div> | |
138 | + <div class="panel-heading"> | |
139 | + <a href="{{ course.get_absolute_url }}" class="panel-title">{{course.name}}</a> | |
140 | + </div> | |
141 | + | |
142 | + <div class="panel-body"> | |
143 | + <p><b>Course Name: </b>{{course.name}}</p> | |
144 | + <p><b>Begining: </b>{{course.init_date}}</p> | |
145 | + <p><b>End: </b>{{course.end_date}}</p> | |
146 | + <p><b>Professor: </b>{{course.professors.name}}</p> | |
147 | + <p> | |
148 | + <b>Description:</b> | |
149 | + <i> | |
150 | + {{course.content}} | |
151 | + </i> | |
152 | + </p> | |
153 | + </div> | |
135 | 154 | </div> |
136 | - </div> | |
137 | - </div> | |
138 | - {% endif %} | |
139 | - {% endfor %} | |
140 | - {% endif %} | |
141 | - {% else %} | |
142 | - No courses found | |
143 | - {% endif %} | |
144 | - <div class="group"> | |
145 | - <div class="modal" id="removeCourse"> | |
146 | - <div class="modal-dialog"> | |
147 | - <div class="modal-content"> | |
148 | - <div class="modal-header"> | |
149 | - <button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button> | |
150 | - <h4 class="modal-title"></h4> | |
151 | - </div> | |
152 | - <div class="modal-body"> | |
153 | - <p>Delete your course?</p> | |
154 | - </div> | |
155 | - <div class="modal-footer"> | |
156 | - | |
157 | - <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> | |
158 | - | |
159 | - </div> | |
160 | - </div> | |
161 | - </div> | |
155 | + {% endfor %} | |
156 | + | |
157 | + {% endblock %} | |
162 | 158 | </div> |
163 | 159 | </div> |
164 | 160 | </div> |
165 | - <div class="col-md-12"> | |
166 | - <nav aria-label="Page navigation"> | |
167 | - <ul class="pagination"> | |
168 | - {% if page_obj.has_previous %} | |
169 | - <li> | |
170 | - <a href="?page={{ page_obj.previous_page_number }}"><span><<</span></a> | |
171 | - </li> | |
172 | - {% endif %} | |
173 | - {% for page_number in paginator.page_range %} | |
174 | - <li{% if page_obj.number == page_number %} class="active"{% endif %}> | |
175 | - <a href="?page={{ page_number }}">{{ page_number }}</a> | |
176 | - </li> | |
177 | - {% endfor %} | |
178 | - {% if page_obj.has_next %} | |
179 | - <li> | |
180 | - <a href="?page={{ page_obj.next_page_number }}"><span>>></span></a> | |
181 | - </li> | |
182 | - {% endif %} | |
183 | - </ul> | |
184 | - </nav> | |
185 | - </div> | |
186 | -{% endcomment %} | |
161 | + <script src="{% static 'js/main.js' %}"></script> | |
162 | + <script type="text/javascript" src="{% static 'js/topic_editation_presentation.js' %}"></script> | |
163 | + {% block script_file %} | |
164 | + | |
165 | + {% endblock script_file %} | |
166 | +</body> | |
167 | + | |
168 | +</html> | |
187 | 169 | \ No newline at end of file | ... | ... |
core/views.py
... | ... | @@ -116,6 +116,7 @@ def getNotifications(request): |
116 | 116 | |
117 | 117 | def guest (request): |
118 | 118 | context = { |
119 | - 'courses': Course.objects.filter(public=True) | |
119 | + 'courses': Course.objects.filter(public=True), | |
120 | + 'categories': CourseCategory.objects.all(), | |
120 | 121 | } |
121 | 122 | return render(request, 'guest.html', context) |
122 | 123 | \ No newline at end of file | ... | ... |
courses/models.py
... | ... | @@ -6,6 +6,8 @@ from users.models import User |
6 | 6 | from core.models import Resource, MimeType |
7 | 7 | from s3direct.fields import S3DirectField |
8 | 8 | |
9 | +from django.core.urlresolvers import reverse | |
10 | + | |
9 | 11 | class CourseCategory(models.Model): |
10 | 12 | |
11 | 13 | name = models.CharField(_('Name'), max_length = 100, unique = True) |
... | ... | @@ -57,6 +59,9 @@ class Course(models.Model): |
57 | 59 | def __str__(self): |
58 | 60 | return self.name |
59 | 61 | |
62 | + def get_absolute_url (self): | |
63 | + return reverse('course:view', kwargs={'slug': self.slug}) | |
64 | + | |
60 | 65 | def show_subscribe(self): |
61 | 66 | today = datetime.date.today() |
62 | 67 | ... | ... |