Commit 96a2172bb692ce82e4bfb131c1daa60c56d22000
Exists in
master
and in
5 other branches
Merge branch 'dev' of https://github.com/amadeusproject/amadeuslms into dev
Showing
6 changed files
with
56 additions
and
75 deletions
Show diff stats
courses/templates/topic/link_topic_list.html
1 | {% load static i18n list_topic_foruns permission_tags %} | 1 | {% load static i18n list_topic_foruns permission_tags %} |
2 | +<div id="list-topic{{ topic.id }}-links"> | ||
2 | {% for link in links%} | 3 | {% for link in links%} |
3 | - <li><i class="fa fa-link" aria-hidden="true"></i> <a href="#" data-toggle="modal" data-target="#linksModal{{slug}}{{ forloop.counter }}">{{link}}</a></li> | ||
4 | - <!--MODAL VIEW LINK--> | ||
5 | - <div class="modal fade" id="linksModal{{slug}}{{ forloop.counter}}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> | ||
6 | - <div class="modal-dialog" role="document"> | ||
7 | - <div class="modal-content"> | ||
8 | - <div class="modal-header"> | ||
9 | - <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> | ||
10 | - <h4 class="modal-title" id="myModalLabel">Link</h4> | ||
11 | - </div> | ||
12 | - <div class="modal-body"> | ||
13 | - <!-- Card --> | ||
14 | - <article class="card animated fadeInLeft"> | ||
15 | - <div class="card-block"> | ||
16 | - <b class="card-title">{{link.name}}</b><p></p> | ||
17 | - <p class="card-text"> </p><p>{{link.link_description}}</p> | ||
18 | - <a href="{{ link.link_url }}" class="btn btn-primary">Read more</a> | ||
19 | - </div> | ||
20 | - </article> | ||
21 | - <!-- .end Card --> | ||
22 | - </div> | ||
23 | - </div> | ||
24 | - </div> | ||
25 | - </div> | ||
26 | - <!-- EndModal --> | 4 | + <li><i class="fa fa-link" aria-hidden="true"></i> <a href="javascript:get_modal_link('{% url 'course:links:view_link' link.slug %}', '#viewLinkModal','#divModalLink')">{{link}}</a></li> |
27 | {% endfor %} | 5 | {% endfor %} |
6 | +</div> | ||
7 | +<div class = 'row' id ="divModalLink"> | ||
8 | + | ||
9 | +</div> |
courses/templates/topic/link_topic_list_edit.html
1 | {% load static i18n list_topic_foruns permission_tags %} | 1 | {% load static i18n list_topic_foruns permission_tags %} |
2 | +<div id="list-topic{{ topic.id }}-links-edit"> | ||
2 | {% for link in links%} | 3 | {% for link in links%} |
4 | + | ||
3 | <li class="icon_edit_remove"> <a href="#" data-toggle="modal" data-target="#linksModalEdit"><i class="fa fa-pencil fa-lg" aria-hidden="true"></i></a> <a href="#" data-toggle="modal" data-target="#removeLink"><i class="fa fa-trash fa-lg" aria-hidden="true"></i></a></li> | 5 | <li class="icon_edit_remove"> <a href="#" data-toggle="modal" data-target="#linksModalEdit"><i class="fa fa-pencil fa-lg" aria-hidden="true"></i></a> <a href="#" data-toggle="modal" data-target="#removeLink"><i class="fa fa-trash fa-lg" aria-hidden="true"></i></a></li> |
4 | - <li><i class="fa fa-link" aria-hidden="true"></i> <a href="#" data-toggle="modal" data-target="#linksModal{{slug}}{{ forloop.counter }}">{{link}}</a></li> | 6 | + <li><i class="fa fa-link" aria-hidden="true"></i> <a href="javascript:get_modal_link('{% url 'course:links:view_link' link.slug %}', '#viewLinkModal','#divModalLink')">{{link}}</a></li> |
5 | 7 | ||
6 | - <!--MODAL VIEW LINK--> | ||
7 | - <div class="modal fade" id="linksModal{{slug}}{{ forloop.counter}}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> | ||
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="myModalLabel">Link</h4> | ||
13 | - </div> | ||
14 | - <div class="modal-body"> | ||
15 | - <!-- Card --> | ||
16 | - <article class="card animated fadeInLeft"> | ||
17 | - <div class="card-block"> | ||
18 | - <b class="card-title">{{link.name}}</b><p></p> | ||
19 | - <p class="card-text"> </p><p>{{link.link_description}}</p> | ||
20 | - <a href="{{ link.link_url }}" class="btn btn-primary">Read more</a> | ||
21 | - </div> | ||
22 | - </article> | ||
23 | - <!-- .end Card --> | ||
24 | - </div> | ||
25 | - </div> | ||
26 | - </div> | ||
27 | - </div> | ||
28 | - <!-- EndModal --> | ||
29 | {% endfor %} | 8 | {% endfor %} |
30 | - <div class = "row" id="divModalLink"> | ||
31 | - </div> | 9 | +</div> |
courses/templatetags/list_topic_foruns.py
@@ -59,7 +59,7 @@ def list_topic_link_edit(request,topic): | @@ -59,7 +59,7 @@ def list_topic_link_edit(request,topic): | ||
59 | 'request':request | 59 | 'request':request |
60 | } | 60 | } |
61 | context['links'] = Link.objects.filter(topic = topic) | 61 | context['links'] = Link.objects.filter(topic = topic) |
62 | - context['slug'] = topic.slug | 62 | + context['topic'] = topic |
63 | return context | 63 | return context |
64 | 64 | ||
65 | @register.inclusion_tag('topic/link_topic_list.html') | 65 | @register.inclusion_tag('topic/link_topic_list.html') |
@@ -68,5 +68,5 @@ def list_topic_link(request,topic): | @@ -68,5 +68,5 @@ def list_topic_link(request,topic): | ||
68 | 'request':request | 68 | 'request':request |
69 | } | 69 | } |
70 | context['links'] = Link.objects.filter(topic = topic) | 70 | context['links'] = Link.objects.filter(topic = topic) |
71 | - context['slug'] = topic.slug | 71 | + context['topic'] = topic |
72 | return context | 72 | return context |
courses/urls.py
1 | from django.conf.urls import url, include | 1 | from django.conf.urls import url, include |
2 | 2 | ||
3 | from . import views | 3 | from . import views |
4 | -from links import views as linkviews | ||
5 | urlpatterns = [ | 4 | urlpatterns = [ |
6 | url(r'^$', views.IndexView.as_view(), name='manage'), | 5 | url(r'^$', views.IndexView.as_view(), name='manage'), |
7 | url(r'^create/$', views.CreateCourseView.as_view(), name='create'), | 6 | url(r'^create/$', views.CreateCourseView.as_view(), name='create'), |
@@ -22,9 +21,6 @@ urlpatterns = [ | @@ -22,9 +21,6 @@ urlpatterns = [ | ||
22 | url(r'^subjects/subscribe/(?P<slug>[\w_-]+)/$', views.subscribe_subject, name='subscribe_subject'), | 21 | url(r'^subjects/subscribe/(?P<slug>[\w_-]+)/$', views.subscribe_subject, name='subscribe_subject'), |
23 | url(r'^topics/create/(?P<slug>[\w_-]+)/$', views.CreateTopicView.as_view(), name='create_topic'), | 22 | url(r'^topics/create/(?P<slug>[\w_-]+)/$', views.CreateTopicView.as_view(), name='create_topic'), |
24 | url(r'^topics/update/(?P<slug>[\w_-]+)/$', views.UpdateTopicView.as_view(), name='update_topic'), | 23 | url(r'^topics/update/(?P<slug>[\w_-]+)/$', views.UpdateTopicView.as_view(), name='update_topic'), |
25 | - url(r'^topics/createlink/$', linkviews.CreateLink.as_view(),name = 'create_link'), | ||
26 | - url(r'^topics/deletelink/(?P<linkname>[\w_-]+)/$', linkviews.deleteLink,name = 'delete_link'), | ||
27 | - url(r'^topics/updatelink/(?P<linkname>[\w_-]+)/$', linkviews.UpdateLink.as_view(),name = 'update_link'), | ||
28 | url(r'^topics/(?P<slug>[\w_-]+)/$', views.TopicsView.as_view(), name='view_topic'), | 24 | url(r'^topics/(?P<slug>[\w_-]+)/$', views.TopicsView.as_view(), name='view_topic'), |
29 | url(r'^subjects/categories$',views.IndexSubjectCategoryView.as_view(), name='subject_category_index'), | 25 | url(r'^subjects/categories$',views.IndexSubjectCategoryView.as_view(), name='subject_category_index'), |
30 | url(r'^forum/', include('forum.urls', namespace = 'forum')), | 26 | url(r'^forum/', include('forum.urls', namespace = 'forum')), |
@@ -33,4 +29,4 @@ urlpatterns = [ | @@ -33,4 +29,4 @@ urlpatterns = [ | ||
33 | url(r'^files/', include('files.urls', namespace = 'file')), | 29 | url(r'^files/', include('files.urls', namespace = 'file')), |
34 | url(r'^upload-material/$', views.UploadMaterialView.as_view(), name='upload_material'), | 30 | url(r'^upload-material/$', views.UploadMaterialView.as_view(), name='upload_material'), |
35 | url(r'^links/',include('links.urls',namespace = 'links')), | 31 | url(r'^links/',include('links.urls',namespace = 'links')), |
36 | -] | ||
37 | \ No newline at end of file | 32 | \ No newline at end of file |
33 | +] |
links/static/links.js
1 | function get_modal_link(url, id,div_content){ | 1 | function get_modal_link(url, id,div_content){ |
2 | $.get(url, function (data) { | 2 | $.get(url, function (data) { |
3 | - //alert(data); | ||
4 | - // $(div_content).empty(); | ||
5 | - // $(div_content).append(data); | 3 | + $(div_content).empty(); |
4 | + $(div_content).append(data); | ||
6 | $(id).modal('show'); | 5 | $(id).modal('show'); |
7 | }); | 6 | }); |
8 | 7 |
links/templates/links/create_link.html
1 | +{% load widget_tweaks i18n %} | ||
2 | + | ||
1 | <!--MODAL CREATE LINK--> | 3 | <!--MODAL CREATE LINK--> |
2 | -<div class="modal fade" id="createLinksModal" tabindex="-1" role="dialog" aria-labelledby="createLink" style="display: none;"> | 4 | +<div class="modal fade" id="createLinksModal" tabindex="-1" role="dialog" aria-labelledby="createLink"> |
3 | <div class="modal-dialog" role="document"> | 5 | <div class="modal-dialog" role="document"> |
4 | <div class="modal-content"> | 6 | <div class="modal-content"> |
5 | <div class="modal-header"> | 7 | <div class="modal-header"> |
@@ -8,25 +10,49 @@ | @@ -8,25 +10,49 @@ | ||
8 | </div> | 10 | </div> |
9 | <div class="modal-body"> | 11 | <div class="modal-body"> |
10 | <!-- Card --> | 12 | <!-- Card --> |
11 | - <div class="form-group is-empty"> | ||
12 | - <label class="control-label" for="inputDefault">Name</label> | ||
13 | - <input type="text" class="form-control" id="inputDefault"> | ||
14 | - </div> | ||
15 | - <div class="form-group is-empty"> | ||
16 | - <label class="control-label" for="inputDefault">Url</label> | ||
17 | - <input type="text" class="form-control" id="inputDefault"> | ||
18 | - </div> | ||
19 | - <div class="form-group is-empty"> | ||
20 | - <label class="control-label" for="inputDefault">Descrição</label> | ||
21 | - <textarea class="form-control" rows="3"></textarea> | ||
22 | - </div> | 13 | + <form method="post" action="" id="form-link" enctype="multipart/form-data"> |
14 | + {% csrf_token %} | ||
15 | + {% for field in form %} | ||
16 | + {% if field.field.required %} | ||
17 | + <label for="{{ field.auto_id }}">{{ field.label }}<span>*</span></label> | ||
18 | + {% else %} | ||
19 | + <label for="{{ field.auto_id }}">{{ field.label }}</label> | ||
20 | + {% endif %} | ||
21 | + {% render_field field class='form-control' %} | ||
22 | + {% endfor %} | ||
23 | <div class="form-group"> | 23 | <div class="form-group"> |
24 | <a href="javascript:void(0)" class="btn btn-raised btn-default" data-dismiss="modal">Cancel</a> | 24 | <a href="javascript:void(0)" class="btn btn-raised btn-default" data-dismiss="modal">Cancel</a> |
25 | - <a href="javascript:void(0)" class="btn btn-raised btn-primary">Submit</a> | ||
26 | - </div> | 25 | + <button class="btn btn-raised btn-primary" type="submit">Submit</button> |
26 | + </div> | ||
27 | <!-- .end Card --> | 27 | <!-- .end Card --> |
28 | </div> | 28 | </div> |
29 | </div> | 29 | </div> |
30 | </div> | 30 | </div> |
31 | </div> | 31 | </div> |
32 | <!-- EndModal --> | 32 | <!-- EndModal --> |
33 | + | ||
34 | +{# // <script src="{% static '/links.js' %}"></script> #} | ||
35 | +<script type="text/javascript"> | ||
36 | + $("#form-link").submit(function(event) { | ||
37 | + var data = new FormData($('#form-link').get(0)); | ||
38 | + $.ajax({ | ||
39 | + url: "{% url 'course:links:create_link' topic.slug %}", | ||
40 | + type: $("#form-link").attr('method'), | ||
41 | + data: data, | ||
42 | + cache: false, | ||
43 | + processData: false, | ||
44 | + contentType: false, | ||
45 | + success: function(data) { | ||
46 | + $('#createLinksModal').modal('hide'); | ||
47 | + $('#list-topic{{ topic.id }}-links').append(data); | ||
48 | + $('#list-topic{{ topic.id }}-links-edit').append(data); | ||
49 | + }, | ||
50 | + error: function(data){ | ||
51 | + $('.erro').html(data.responseText); | ||
52 | + $('.modal-backdrop').remove(); | ||
53 | + $('#createLinksModal').modal(); | ||
54 | + } | ||
55 | + }); | ||
56 | + event.preventDefault(); | ||
57 | + }); | ||
58 | +</script> |