Commit c1d6fbf8d66cccde31a6d4a2de4d94bcf9a5736f
Exists in
master
and in
5 other branches
Merge
Showing
15 changed files
with
234 additions
and
120 deletions
Show diff stats
... | ... | @@ -0,0 +1,42 @@ |
1 | +// loadOnScroll handler | |
2 | +var loadOnScroll = function() { | |
3 | + // If the current scroll position is past out cutoff point... | |
4 | + if ($(window).scrollTop() >= $(document).height() - $(window).height() - 10) { | |
5 | + // temporarily unhook the scroll event watcher so we don't call a bunch of times in a row | |
6 | + $(window).unbind(); | |
7 | + // execute the load function below that will visit the view and return the content | |
8 | + loadItems(); | |
9 | + } | |
10 | +}; | |
11 | + | |
12 | +var loadItems = function() { | |
13 | + // Check if page is equal to the number of pages | |
14 | + if (pageNum == numberPages) { | |
15 | + return false | |
16 | + } | |
17 | + // Update the page number | |
18 | + pageNum = pageNum + 1; | |
19 | + | |
20 | + $("#loading").show(); | |
21 | + // Configure the url we're about to hit | |
22 | + setTimeout(function (){ | |
23 | + $.ajax({ | |
24 | + url: baseUrl, | |
25 | + data: {'page': pageNum}, | |
26 | + success: function(data) { | |
27 | + $("#loading").hide(); | |
28 | + | |
29 | + $("#timeline").append(data); | |
30 | + }, | |
31 | + complete: function(data, textStatus){ | |
32 | + // Turn the scroll monitor back on | |
33 | + $(window).bind('scroll', loadOnScroll); | |
34 | + } | |
35 | + }); | |
36 | + }, 1000) | |
37 | +}; | |
38 | + | |
39 | +$(document).ready(function(){ | |
40 | + $(window).bind('scroll', loadOnScroll); | |
41 | + $.material.init(); | |
42 | +}); | |
0 | 43 | \ No newline at end of file | ... | ... |
app/templates/home.html
... | ... | @@ -5,59 +5,16 @@ |
5 | 5 | {% block javascript %} |
6 | 6 | {% if page_obj %} |
7 | 7 | <script type="text/javascript"> |
8 | - {% if page_obj and paginator %} | |
9 | - var pageNum = {{ page_obj.number }}; // The latest page loaded | |
10 | - var numberPages = {{ paginator.num_pages }}; // Indicates the number of pages | |
11 | - {% else %} | |
12 | - var pageNum = 0 ; // The latest page loaded | |
13 | - var numberPages = 0 ; // Indicates the number of pages | |
14 | - {% endif %} | |
15 | - | |
16 | - var baseUrl = '{% url "app:index" %}'; | |
17 | - | |
18 | - // loadOnScroll handler | |
19 | - var loadOnScroll = function() { | |
20 | - // If the current scroll position is past out cutoff point... | |
21 | - if ($(window).scrollTop() >= $(document).height() - $(window).height() - 10) { | |
22 | - // temporarily unhook the scroll event watcher so we don't call a bunch of times in a row | |
23 | - $(window).unbind(); | |
24 | - // execute the load function below that will visit the view and return the content | |
25 | - loadItems(); | |
26 | - } | |
27 | - }; | |
28 | - | |
29 | - var loadItems = function() { | |
30 | - // Check if page is equal to the number of pages | |
31 | - if (pageNum == numberPages) { | |
32 | - return false | |
33 | - } | |
34 | - // Update the page number | |
35 | - pageNum = pageNum + 1; | |
36 | - | |
37 | - $("#loading").show(); | |
38 | - // Configure the url we're about to hit | |
39 | - setTimeout(function (){ | |
40 | - $.ajax({ | |
41 | - url: baseUrl, | |
42 | - data: {'page': pageNum}, | |
43 | - success: function(data) { | |
44 | - $("#loading").hide(); | |
45 | - | |
46 | - $("#timeline").append(data); | |
47 | - }, | |
48 | - complete: function(data, textStatus){ | |
49 | - // Turn the scroll monitor back on | |
50 | - $(window).bind('scroll', loadOnScroll); | |
51 | - } | |
52 | - }); | |
53 | - }, 1000) | |
54 | - }; | |
55 | - | |
56 | - $(document).ready(function(){ | |
57 | - $(window).bind('scroll', loadOnScroll); | |
58 | - $.material.init(); | |
59 | - }); | |
8 | + {% if page_obj and paginator %} | |
9 | + var pageNum = {{ page_obj.number }}; // The latest page loaded | |
10 | + var numberPages = {{ paginator.num_pages }}; // Indicates the number of pages | |
11 | + {% else %} | |
12 | + var pageNum = 0 ; // The latest page loaded | |
13 | + var numberPages = 0 ; // Indicates the number of pages | |
14 | + {% endif %} | |
15 | + var baseUrl = '{% url "app:index" %}'; | |
60 | 16 | </script> |
17 | + <script type="text/javascript" src="{% static 'js/home.js' %}"></script> | |
61 | 18 | {% endif %} |
62 | 19 | {% endblock %} |
63 | 20 | |
... | ... | @@ -96,7 +53,7 @@ |
96 | 53 | |
97 | 54 | {% endblock %} |
98 | 55 | {% if user|has_role:'system_admin' %} |
99 | - | |
56 | + | |
100 | 57 | <li> |
101 | 58 | <a href="#menu_users" class="accordion" data-toggle="collapse">{% trans 'Users' %}<span class="pull-right glyphicon glyphicon-chevron-down"></span></a> |
102 | 59 | <div id="menu_users" class="collapse"> |
... | ... | @@ -104,9 +61,9 @@ |
104 | 61 | <li> <a href="{% url 'users:manage' %}">{% trans 'Manage Users' %}</a></li> |
105 | 62 | <li> <a href="{% url 'users:create' %}">{% trans 'Create User' %}</a></li> |
106 | 63 | </ul> |
107 | - </div> | |
64 | + </div> | |
108 | 65 | </li> |
109 | - <li> | |
66 | + <li> | |
110 | 67 | <a href="#menu_settings" class="accordion" data-toggle="collapse">{% trans 'Settings' %}<span class="pull-right glyphicon glyphicon-chevron-down"></span></a> |
111 | 68 | <div id="menu_settings" class="collapse"> |
112 | 69 | <ul class="nav nav-pill nav-stacked accordion_list"> | ... | ... |
core/admin.py
... | ... | @@ -14,7 +14,7 @@ class ActionResourceAdmin(admin.ModelAdmin): |
14 | 14 | search_fields = ['action', 'resource'] |
15 | 15 | |
16 | 16 | class LogAdmin(admin.ModelAdmin): |
17 | - list_display = ['datetime', 'user', 'action_resource'] | |
17 | + list_display = ['datetime', 'user', 'action_resource', 'context'] | |
18 | 18 | search_fields = ['user'] |
19 | 19 | |
20 | 20 | class MimeTypeAdmin(admin.ModelAdmin): | ... | ... |
core/static/css/base/amadeus.css
... | ... | @@ -77,9 +77,6 @@ |
77 | 77 | .end{ |
78 | 78 | text-align: right; |
79 | 79 | } |
80 | -h5{ | |
81 | - text-align: center; | |
82 | -} | |
83 | 80 | #img { |
84 | 81 | |
85 | 82 | display: block; |
... | ... | @@ -406,16 +403,19 @@ ul, li { |
406 | 403 | -webkit-animation-timing-function: ease-in-out; |
407 | 404 | } |
408 | 405 | /* Icon Topic */ |
409 | -.divMoreActions {text-align: right; height: 39px; float: right;} | |
410 | -.divMoreActions div button {padding-left: 10px; padding-right: 10px; padding-bottom: 10px; margin-bottom: 4px; height: 31px;} | |
411 | -.titleTopic {padding-top: 18px; padding-left: 0px;} | |
412 | -.titleTopic-detail {padding-top: 8px; color: white;} | |
413 | -.titleTopic a h4 {margin-top: 0px; color: black; cursor:pointer;} | |
406 | +.divMoreActions {text-align: right; height: 59px; float: right;} | |
407 | +.moreAccordion {height: 59px;} | |
408 | +/*.divMoreActions div button {padding-left: 10px; padding-right: 10px; padding-bottom: 10px; margin-bottom: 4px; height: 31px;}*/ | |
409 | +.divMoreActions , .moreAccordion{padding-top: 5px; padding-bottom: 1%;} | |
410 | +.moreAccordion button{margin-bottom: 0px; margin-top: 8px;} | |
411 | +.titleTopic {padding-top: 10px; padding-bottom: 10px;} | |
412 | +.titleTopic a h4, .titleTopic h4{color: white;} | |
413 | +.titleTopic a:hover{text-decoration: none;} | |
414 | +.Topic-detail a h4{color: black;} | |
415 | +/* .titleTopic a h4 {margin-top: 0px; color: black; cursor:pointer;}*/ | |
414 | 416 | .dropdown-menu .pull-right { |
415 | 417 | right: 0; |
416 | 418 | } |
417 | -.moreAccordion{ padding-left: 0px; padding-right: 0px;} | |
418 | -.moreAccordion div button{ padding-left: 0px; padding-right: 0px;} | |
419 | 419 | .cards-content{ padding-left: 0px; padding-right: 0px; } |
420 | 420 | .cards-detail{margin-left: 4%;} |
421 | 421 | .cards-detail .panel .panel-heading{/*background-color:;*/} | ... | ... |
courses/static/js/topic.js
... | ... | @@ -2,14 +2,14 @@ function openTopic(url, topic, btn) { |
2 | 2 | var icon = btn.find('i'); |
3 | 3 | var action = '', log_id; |
4 | 4 | |
5 | - if (icon.hasClass('fa-caret-square-o-down')) { | |
6 | - icon.removeClass('fa-caret-square-o-down'); | |
7 | - icon.addClass('fa-caret-square-o-up'); | |
5 | + if (icon.hasClass('fa-angle-down')) { | |
6 | + icon.removeClass('fa-angle-down'); | |
7 | + icon.addClass('fa-angle-up'); | |
8 | 8 | action = 'open'; |
9 | 9 | log_id = -1; |
10 | 10 | } else { |
11 | - icon.addClass('fa-caret-square-o-down'); | |
12 | - icon.removeClass('fa-caret-square-o-up'); | |
11 | + icon.addClass('fa-angle-down'); | |
12 | + icon.removeClass('fa-angle-up'); | |
13 | 13 | action = 'close'; |
14 | 14 | log_id = $(".topic_" + topic).find(".log_id").val(); |
15 | 15 | } |
... | ... | @@ -20,7 +20,7 @@ function openTopic(url, topic, btn) { |
20 | 20 | dataType: 'json', |
21 | 21 | success: function (data) { |
22 | 22 | if (action == 'open') { |
23 | - $(".topic_" + topic).find(".log_id").val(data.log_id); | |
23 | + $(".topic_" + topic).find(".log_id").val(data.log_id); | |
24 | 24 | } |
25 | 25 | }, |
26 | 26 | error: function(data) { | ... | ... |
courses/templates/category/create.html
... | ... | @@ -19,7 +19,7 @@ |
19 | 19 | <label for="{{ field.auto_id }}">{{ field.label }}</label> |
20 | 20 | {% render_field field class='form-control input-sm' %} |
21 | 21 | </div> |
22 | - {% if field.errors.length > 0 %} | |
22 | + {% if field.errors%} | |
23 | 23 | <div class="alert alert-danger alert-dismissible" role="alert"> |
24 | 24 | <ul> |
25 | 25 | {% for error in field.errors %} | ... | ... |
courses/templates/course/course_card.html
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | <div class="panel panel-info"> |
4 | 4 | <div class="panel-heading course"> |
5 | 5 | <div class="row"> |
6 | - <div class="col-xs-5 col-md-5 titleTopic"> | |
6 | + <div class="col-xs-6 col-md-6 titleTopic"> | |
7 | 7 | <a role="button" href="{% url 'course:view' course.slug %}"> |
8 | 8 | <h4>{{course.name}}</h4> |
9 | 9 | </a> | ... | ... |
courses/templates/course/view.html
... | ... | @@ -23,30 +23,36 @@ |
23 | 23 | {% block content %} |
24 | 24 | |
25 | 25 | <div class="col-md-12 cards-content"> |
26 | - <div class="panel panel-info"> | |
27 | - <div class="panel-heading course-detail"> | |
28 | - <div class="row"> | |
29 | - <div class="col-xs-8 col-md-11 .titleTopic-detail"> | |
30 | - <h4>{{course.name}}</h4> | |
31 | - </div> | |
32 | - {% if user|has_role:'professor' or user|has_role:'system_admin' %} | |
33 | - <div class="col-xs-4 col-md-1" id="divMoreActions"> | |
26 | + <div class="group course-card "> | |
27 | + <div class="panel panel-info"> | |
28 | + <div class="panel-heading course"> | |
29 | + <div class="row"> | |
30 | + <div class="col-xs-6 col-md-6 titleTopic"> | |
31 | + <h4>{{course.name}}</h4> | |
32 | + </div> | |
33 | + {% if user|has_role:'professor' or user|has_role:'system_admin' %} | |
34 | + <div class="col-xs-6 col-md-6 divMoreActions" > | |
34 | 35 | <div class="btn-group"> |
35 | 36 | <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> |
36 | 37 | <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i> |
37 | - <div class="ripple-container"></div></button> | |
38 | + </button> | |
38 | 39 | <ul class="dropdown-menu pull-right" aria-labelledby="moreActions"> |
39 | - <li><a href="{% url 'course:replicate_course' course.slug %}"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i> {% trans "Replicate" %}</a></li> | |
40 | - <li><a href="{% url 'course:update' course.slug %}"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i> {% trans "Edit" %}</a></li> | |
41 | - <li><a href="javascript:javascript:delete_course('{% url 'course:delete' course.slug %}', '{{ course.slug }}', '{% trans "Are you sure you want to delete this course?" %}', '{% url 'course:manage' %}')" data-toggle="modal" data-target="#myModal2"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> {% trans "Remove" %}</a></li> | |
40 | + <li><a href="{% url 'course:replicate_course' course.slug %}"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i>{% trans 'Replicate' %}</a></li> | |
41 | + <li><a href="{% url 'course:update' course.slug %}"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i>{% trans 'Edit' %}</a></li> | |
42 | + <li><a href="javascript:delete_course.get('{% url 'course:delete' course.slug %}','#course','#modal_course')"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> {% trans 'Remove' %}</a></li> | |
42 | 43 | </ul> |
43 | 44 | </div> |
44 | 45 | </div> |
46 | + {% elif user|has_role:'student' %} | |
47 | + {% if not request.user in course.students.all %} | |
48 | + <a onclick="subscribe($(this), '{% url 'course:subscribe' course.slug %}', {{ course.id}}, '{% trans 'Are you sure you want to subscribe to this course?' %}')"><button class="btn btn-sm btn-primary btn-raised pull-right">{% trans 'Subscribe' %}</button></a> | |
49 | + {% endif %} | |
45 | 50 | {% endif %} |
51 | + </div> | |
52 | + </div> | |
53 | + <div class="panel-body"> | |
54 | + <p><b>{% trans 'Coordinator' %}: </b>{{course.coordenator}}</p> | |
46 | 55 | </div> |
47 | - </div> | |
48 | - <div class="panel-body"> | |
49 | - <p><b>{% trans 'Coordinator' %}: </b>{{course.coordenator}}</p> | |
50 | 56 | </div> |
51 | 57 | </div> |
52 | 58 | |
... | ... | @@ -70,18 +76,18 @@ |
70 | 76 | </div> |
71 | 77 | |
72 | 78 | <div class="panel-group ui-accordion ui-widget ui-helper-reset ui-sortable" id="accordion" role="tablist" aria-multiselectable="false"></div> |
73 | -<div class="cards-detail"> | |
79 | + <div class="cards-detail"> | |
74 | 80 | {% for subject in subjects %} |
75 | 81 | <div class="panel panel-default panel_{{ subject.id }}"> |
76 | 82 | <div class="panel-heading heading_{{subject.id}} subject ui-sortable-handle"> |
77 | 83 | <div class="row"> |
78 | - <div class="col-xs-9 col-md-10 titleTopic"> | |
84 | + <div class="col-xs-9 col-md-6 titleTopic"> | |
79 | 85 | <a role="button" href="{% url 'course:view_subject' subject.slug %}"> |
80 | 86 | <h4>{{subject.name}}</h4> |
81 | 87 | </a> |
82 | 88 | </div> |
83 | 89 | {% if user|has_role:'professor' or user|has_role:'system_admin' %} |
84 | - <div class="col-xs-3 col-md-1" id="divMoreActions"> | |
90 | + <div class="col-xs-3 col-md-6 divMoreActions"> | |
85 | 91 | <div class="btn-group"> |
86 | 92 | <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> |
87 | 93 | <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i> | ... | ... |
courses/templates/subject/form_view_student.html
courses/templates/subject/form_view_teacher.html
... | ... | @@ -6,9 +6,9 @@ |
6 | 6 | <div class="panel-heading topic"> |
7 | 7 | <div class="row"> |
8 | 8 | <div class="col-md-1 moreAccordion" data-toggle="collapse" data-parent="#accordion-{{topic.slug}}" href=".collapseTopic-{{topic.slug}}" aria-expanded="false" aria-controls="collapseTopic-{{topic.slug}}"> |
9 | - <button class="btn btn-default btn-sm caret-square" onclick="openTopic('{% url 'course:topic_log' topic.id %}', '{{topic.id}}', $(this));"><i class="fa fa-caret-square-o-down fa-2x" aria-hidden="true"></i></button> | |
9 | + <button class="btn btn-default btn-sm caret-square" onclick="openTopic('{% url 'course:topic_log' topic.id %}', '{{topic.id}}', $(this));"><i class="fa fa-angle-down fa-2x" aria-hidden="true"></i></button> | |
10 | 10 | </div> |
11 | - <div class="col-xs-9 col-md-9 titleTopic"> | |
11 | + <div class="col-xs-9 col-md-9 titleTopic Topic-detail"> | |
12 | 12 | <a href="{% url 'course:view_topic' topic.slug %}" role="button"> |
13 | 13 | <h4>{{topic}}</h4> |
14 | 14 | </a> |
... | ... | @@ -127,13 +127,6 @@ |
127 | 127 | {% list_topic_foruns request topic %} |
128 | 128 | </ul> |
129 | 129 | </div> |
130 | - <div class="editation editation_{{topic.slug}}"> | |
131 | - | |
132 | - {# exercícios do tópico no modo de edição #} | |
133 | - <ul> | |
134 | - {% list_topic_exercise_edit request topic %} | |
135 | - </ul> | |
136 | - </div> | |
137 | 130 | </div> |
138 | 131 | </div> |
139 | 132 | ... | ... |
courses/templates/subject/index.html
... | ... | @@ -19,14 +19,13 @@ |
19 | 19 | |
20 | 20 | {% block content %} |
21 | 21 | <div class="panel panel-info"> |
22 | - <div class="panel-heading course-detail"> | |
22 | + <div class="panel-heading course"> | |
23 | 23 | <div class="row"> |
24 | - <div class="col-md-10 col-sm-10"> | |
24 | + <div class="col-xs-6 col-md-6 titleTopic"> | |
25 | 25 | <h4>{{subject}}</h4> |
26 | 26 | </div> |
27 | - | |
28 | 27 | {# dropdown de subject com as opções de replicar, editar e deletar #} |
29 | - <div class="col-xs-4 col-md-2 divMoreActions"> | |
28 | + <div class="col-xs-6 col-md-6 divMoreActions"> | |
30 | 29 | {% professor_subject subject user as subject_professor%} |
31 | 30 | {% if subject_professor %} |
32 | 31 | <div class="btn-group"> |
... | ... | @@ -41,10 +40,8 @@ |
41 | 40 | </div> |
42 | 41 | {% endif %} |
43 | 42 | </div> |
44 | - | |
45 | 43 | </div> |
46 | 44 | </div> |
47 | - | |
48 | 45 | {# informações do subject(professor, descrição etc) #} |
49 | 46 | <div class="panel-body"> |
50 | 47 | <p><b>{% trans "Professor" %}:</b> {% for professor in subject.professors.all %}{% if not forloop.first %},{% endif %} |
... | ... | @@ -62,7 +59,6 @@ |
62 | 59 | </div> |
63 | 60 | </div> |
64 | 61 | </div> |
65 | - | |
66 | 62 | </div> |
67 | 63 | |
68 | 64 | {# lista de tópicos #} | ... | ... |
courses/templates/topic/index.html
... | ... | @@ -19,13 +19,13 @@ |
19 | 19 | {% block content %} |
20 | 20 | <div class="col-md-12 col-xs-12 col-sm-12"> |
21 | 21 | <div class="panel panel-info"> |
22 | - <div class="panel-heading"> | |
23 | - <div class="row"> | |
24 | - <div class="col-md-10 col-sm-7"> | |
25 | - <h3> {{topic.name}} </h3> | |
26 | - </div> | |
27 | - <div class="col-xs-4 col-md-2 divMoreActions"> | |
28 | - {% professor_subject subject user as permissions%} | |
22 | + <div class="panel-heading course"> | |
23 | + <div class="row"> | |
24 | + <div class="col-md-10 col-sm-7 titleTopic"> | |
25 | + <h4> {{topic.name}}</h4> | |
26 | + </div> | |
27 | + <div class="col-xs-4 col-md-2 divMoreActions"> | |
28 | + {% professor_subject subject user as permissions%} | |
29 | 29 | {% if permissions %} |
30 | 30 | <div class="btn-group"> |
31 | 31 | <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> |
... | ... | @@ -110,8 +110,8 @@ |
110 | 110 | </div> |
111 | 111 | </div> |
112 | 112 | <div class="col-md-6"> |
113 | - <h3>{% trans 'Students - Specific Exercises' %}</h3> | |
114 | - <br/> | |
113 | + <h3>{% trans 'Students - Specific Exercises' %}</h3> | |
114 | + <br/> | |
115 | 115 | </div> |
116 | 116 | {# mostra a lista de usuários caso seja um professor ou admin #} |
117 | 117 | {% if user|has_role:'professor' or user|has_role:'system_admin' %} | ... | ... |
exercise/templates/exercise/exercise_edit.html
1 | 1 | {% load static i18n list_topic_foruns permission_tags %} |
2 | 2 | <div id="exercise-topic{{ topic.id }}-exercises-edit"> |
3 | 3 | {% for exercise in exercises %} |
4 | - <li class="icon_edit_remove" id = "exercise_edit_icon_{{ exercise.slug }}"> <a href="javascript:modal.get('', '#exercisesModalEdit', '#requisicoes_ajax')"><i class="fa fa-pencil fa-lg" aria-hidden="true"></i></a> <a href="javascript:modal.get('', '#exerciseDeleteModal', '#requisicoes_ajax')"><i class="fa fa-trash fa-lg" aria-hidden="true"></i></a></li> | |
4 | + <li class="icon_edit_remove" id = "exercise_edit_icon_{{ exercise.slug }}"> <a href="javascript:modal.get('{% url 'course:exercise:update_exercise' exercise.slug %}', '#exercisesModalEdit', '#requisicoes_ajax')"><i class="fa fa-pencil fa-lg" aria-hidden="true"></i></a> <a href="javascript:modal.get('', '#exerciseDeleteModal', '#requisicoes_ajax')"><i class="fa fa-trash fa-lg" aria-hidden="true"></i></a></li> | |
5 | 5 | <li id = "exercise_edit_{{ exercise.slug }}"><i class="fa fa-file" aria-hidden="true"></i> <a href="javascript:modal.get('', '#viewExerciseModal','#requisicoes_ajax')">{{exercise.name_exercise}}</a></li> |
6 | 6 | {% endfor %} |
7 | 7 | </div> | ... | ... |
... | ... | @@ -0,0 +1,120 @@ |
1 | +{% load static widget_tweaks i18n %} | |
2 | + | |
3 | +<!-- MODAL CREATE FILE --> | |
4 | +<link rel="stylesheet" type="text/css" href="{% static 'css/file.css' %}"> | |
5 | + | |
6 | +<div class="erro-update"> | |
7 | + <div class="modal fade" id="exercisesModalEdit" tabindex="-1" role="dialog" aria-labelledby="updateFileLabel" style="z-index: 10"> | |
8 | + <div class="modal-dialog" role="document"> | |
9 | + <div class="modal-content"> | |
10 | + <div class="modal-header"> | |
11 | + <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> | |
12 | + <h4 class="modal-title" id="updateFileLabel">{% trans 'Edit Material' %}</h4> | |
13 | + </div> | |
14 | + <div class="modal-body"> | |
15 | + <!-- Card --> | |
16 | + <form class="form-horizontal" method="post" id="form-update-exercise" enctype="multipart/form-data"> | |
17 | + {% csrf_token %} | |
18 | + {% if messages %} | |
19 | + {% for message in messages %} | |
20 | + <div class="alert alert-{{ message.tags }} alert-dismissible" role="alert"> | |
21 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
22 | + <span aria-hidden="true">×</span> | |
23 | + </button> | |
24 | + <p>{{ message }}</p> | |
25 | + </div> | |
26 | + {% endfor %} | |
27 | + {% endif %} | |
28 | + <fieldset> | |
29 | + {% for field in form %} | |
30 | + <div class="form-group is-empy{% if form.has_error %} has-error {% endif %} is-fileinput"> | |
31 | + <div class="col-md-12"> | |
32 | + {% if field.field.required %} | |
33 | + <label for="{{ field.auto_id }}" class="control-label">{{ field.label }}<span>*</span></label> | |
34 | + {% else %} | |
35 | + <label for="{{ field.auto_id }}" class=" control-label">{{ field.label }}</label> | |
36 | + {% endif %} | |
37 | + {% if field.auto_id == 'id_file' %} | |
38 | + <input class="form-control input-sm" id="id_file_url" name="file_url" type="file"> | |
39 | + <div class="input-group"> | |
40 | + <input type="text" readonly="" class="form-control" placeholder="{% trans 'Choose your file...' %}"> | |
41 | + <span class="input-group-btn input-group-sm"> | |
42 | + <button type="button" class="btn btn-fab btn-fab-mini"> | |
43 | + <i class="material-icons">attach_file</i> | |
44 | + </button> | |
45 | + </span> | |
46 | + </div> | |
47 | + <div class="crearfix"> | |
48 | + <a href="{{ file.file_url.url }}" target="_blank">{% trans "See current file" %}</a> | |
49 | + </div> | |
50 | + {% else %} | |
51 | + {% render_field field class='form-control input-sm' %} | |
52 | + <span id="helpBlock" class="help-block">{{ field.help_text }}</span> | |
53 | + {% endif %} | |
54 | + </div> | |
55 | + | |
56 | + {% if field.errors %} | |
57 | + <div class="alert alert-danger alert-dismissible clearfix" role="alert"> | |
58 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
59 | + <span aria-hidden="true">×</span> | |
60 | + </button> | |
61 | + <ul> | |
62 | + {% for error in field.errors %} | |
63 | + <li>{{ error }}</li> | |
64 | + {% endfor %} | |
65 | + </ul> | |
66 | + </div> | |
67 | + {% endif %} | |
68 | + </div> | |
69 | + {% endfor %} | |
70 | + | |
71 | + <div class="form-group"> | |
72 | + <div class="col-md-12 text-center"> | |
73 | + <p><b>{% trans 'The file size shouldnt exceed 10MB' %}</b></p> | |
74 | + </div> | |
75 | + </div> | |
76 | + | |
77 | + <div class="form-group"> | |
78 | + <div class="col-md-12"> | |
79 | + <button type="button" class="btn btn-default btn-raised" data-dismiss="modal">{% trans "Close" %}</button> | |
80 | + <button class="btn btn-raised btn-primary" type="submit">{% trans 'Submit' %}</button> | |
81 | + </div> | |
82 | + </div> | |
83 | + </fieldset> | |
84 | + </form> | |
85 | + <!-- .end Card --> | |
86 | + </div> | |
87 | + </div> | |
88 | + </div> | |
89 | + </div> | |
90 | +</div> | |
91 | + | |
92 | +{% block script_file %} | |
93 | + | |
94 | + {# // <script src="{% static 'js/file.js' %}"></script> #} | |
95 | + <script type="text/javascript"> | |
96 | + $("#form-update-exercise").submit(function(event) { | |
97 | + var data = new FormData($('#form-update-exercise').get(0)); | |
98 | + $.ajax({ | |
99 | + url: "{% url 'course:exercise:update_exercise' exercise.slug %}", | |
100 | + type: $("#form-update-exercise").attr('method'), | |
101 | + data: data, | |
102 | + cache: false, | |
103 | + processData: false, | |
104 | + contentType: false, | |
105 | + success: function(data) { | |
106 | + $('#Carrinho').modal('hide'); | |
107 | + $('#file_edit_{{ exercise.slug }}').replaceWith(data); | |
108 | + $('#file_{{ exercise.slug }}').replaceWith(data); | |
109 | + }, | |
110 | + error: function(data){ | |
111 | + $('.erro-update').html(data.responseText); | |
112 | + $('.modal-backdrop').remove(); | |
113 | + $('#Carrinho').modal(); | |
114 | + } | |
115 | + }); | |
116 | + event.preventDefault(); | |
117 | + }); | |
118 | + </script> | |
119 | +{% endblock script_file %} | |
120 | +<!-- EndModal --> | |
0 | 121 | \ No newline at end of file | ... | ... |
exercise/templatetags/list_topic_exercises.py
... | ... | @@ -19,7 +19,7 @@ def list_topic_exercise_edit(request, topic): |
19 | 19 | context = { |
20 | 20 | 'request': request, |
21 | 21 | } |
22 | - context['exercises'] = Exercise.objects.filter(topic = topic) | |
22 | + context['exercises'] = Exercise.objects.filter(topic=topic) | |
23 | 23 | context['topic'] = topic |
24 | 24 | |
25 | 25 | return context | ... | ... |