Commit 80e6a9ec2939bb94509c61a041811af8303c7e01
Exists in
master
and in
5 other branches
Merge branch 'dev' of https://github.com/amadeusproject/amadeuslms into dev
Showing
13 changed files
with
164 additions
and
64 deletions
Show diff stats
courses/templates/subject/form_view_teacher.html
... | ... | @@ -4,6 +4,7 @@ |
4 | 4 | <script type="text/javascript" src="{% static 'js/forum.js' %}"></script> |
5 | 5 | <script src="{% static 'js/file.js' %}"></script> |
6 | 6 | <script type="text/javascript" src="{% static 'js/material.js' %}"></script> |
7 | + <script type = "text/javascript" src="{% static 'link.js' %}"></script> | |
7 | 8 | {% endblock %} |
8 | 9 | |
9 | 10 | <div class="panel-group accordion ui-accordion ui-widget ui-helper-reset ui-sortable" role="tablist" aria-multiselectable="false"> |
... | ... | @@ -54,7 +55,7 @@ |
54 | 55 | <div class="dropdown"> |
55 | 56 | <a href="#" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-plus-circle fa-lg" aria-hidden="true"></i></a> |
56 | 57 | <ul class="dropdown-menu" aria-labelledby="dLabel"> |
57 | - <li><a href="javascript:void(0)" data-toggle="modal" data-target="#createLinksModal">Create a Link<div class="ripple-container"><div class="ripple ripple-on ripple-out" style="left: 54.5312px; top: 22px; background-color: rgb(0, 150, 136); transform: scale(20);"></div></div></a></li> | |
58 | + <li><a href=" javascript:get_modal_link('{% url 'course:links:create_link' %}', '#createLinksModal','#divModalLink') ">Create a Link<div class="ripple-container"><div class="ripple ripple-on ripple-out" style="left: 54.5312px; top: 22px; background-color: rgb(0, 150, 136); transform: scale(20);"></div></div></a></li> | |
58 | 59 | <li> |
59 | 60 | <a href="javascript:get_modal_file('{% url 'course:file:create_file' topic.slug %}', '#fileModal', '#divModalFile')"> |
60 | 61 | {% trans "Create a file" %} |
... | ... | @@ -69,7 +70,7 @@ |
69 | 70 | </div> |
70 | 71 | <ul> |
71 | 72 | {% list_topic_file request topic %} |
72 | - <li><i class="fa fa-link" aria-hidden="true"></i> <a href="#" data-toggle="modal" data-target="#linksModal">Link 1</a></li> | |
73 | + {% list_topic_link request topic%} | |
73 | 74 | <li><i class="fa fa-file-code-o" aria-hidden="true"></i> <a href="#" data-toggle="modal" data-target="#embedModal">EMBED Material</a></li> |
74 | 75 | </ul> |
75 | 76 | </div> |
... | ... | @@ -115,12 +116,13 @@ |
115 | 116 | <div class="dropdown"> |
116 | 117 | <a href="#" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-plus-circle fa-lg" aria-hidden="true"></i></a> |
117 | 118 | <ul class="dropdown-menu" aria-labelledby="dLabel"> |
118 | - <li><a href="javascript:void(0)" data-toggle="modal" data-target="#createLinksModal">Create a Link</a></li> | |
119 | + <li><a href=" javascript:get_modal_link('{% url 'course:links:create_link' %}', '#createLinksModal','#divModalLink') ">Create a Link</a></li> | |
119 | 120 | <li><a href="javascript:void(0)" data-toggle="modal" data-target="#fileModal">Create a file</a></li> |
120 | 121 | </ul> |
121 | 122 | </div> |
122 | 123 | </div> |
123 | 124 | <ul> |
125 | + {% list_topic_link_edit request topic%} | |
124 | 126 | {% list_topic_file_edit request topic %} |
125 | 127 | </ul> |
126 | 128 | </div> |
... | ... | @@ -175,31 +177,6 @@ |
175 | 177 | </div> |
176 | 178 | </div> |
177 | 179 | <!-- END --> |
178 | - <!--MODAL VIEW LINK--> | |
179 | - <div class="modal fade" id="linksModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> | |
180 | - <div class="modal-dialog" role="document"> | |
181 | - <div class="modal-content"> | |
182 | - <div class="modal-header"> | |
183 | - <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> | |
184 | - <h4 class="modal-title" id="myModalLabel">Links</h4> | |
185 | - </div> | |
186 | - <div class="modal-body"> | |
187 | - <!-- Card --> | |
188 | - <article class="card animated fadeInLeft"> | |
189 | - <img class="card-img-top img-responsive" src="https://www.python.org/static/opengraph-icon-200x200.png" align="left"> | |
190 | - <div class="card-block"> | |
191 | - <b class="card-title">Python</b><p></p> | |
192 | - <b class="text-muted">Guido van Rossum</b> | |
193 | - <p class="card-text"> </p><p>Python is a widely used high-level, general-purpose, interpreted, dynamic programming language. Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than possible in languages such as C++ or Java.</p> | |
194 | - <a href="https://www.python.org/" class="btn btn-primary">Read more</a> | |
195 | - </div> | |
196 | - </article> | |
197 | - <!-- .end Card --> | |
198 | - </div> | |
199 | - </div> | |
200 | - </div> | |
201 | - </div> | |
202 | - <!-- EndModal --> | |
203 | 180 | {% professor_subject topic.subject user as professor_links %} |
204 | 181 | {% if professor_links%} |
205 | 182 | {% include "links/create_link.html" %} | ... | ... |
... | ... | @@ -0,0 +1,27 @@ |
1 | +{% load static i18n list_topic_foruns permission_tags %} | |
2 | +{% 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 --> | |
27 | +{% endfor %} | ... | ... |
... | ... | @@ -0,0 +1,31 @@ |
1 | +{% load static i18n list_topic_foruns permission_tags %} | |
2 | +{% for link in links%} | |
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> | |
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> | |
5 | + | |
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 %} | |
30 | + <div class = "row" id="divModalLink"> | |
31 | + </div> | ... | ... |
courses/templatetags/list_topic_foruns.py
1 | 1 | from django import template |
2 | 2 | |
3 | +from links.models import Link | |
3 | 4 | from forum.models import Forum |
4 | 5 | from poll.models import Poll |
5 | 6 | from files.models import TopicFile |
... | ... | @@ -51,3 +52,21 @@ def list_topic_file_edit(request, topic): |
51 | 52 | context['topic'] = topic |
52 | 53 | |
53 | 54 | return context |
55 | + | |
56 | +@register.inclusion_tag('topic/link_topic_list_edit.html') | |
57 | +def list_topic_link_edit(request,topic): | |
58 | + context = { | |
59 | + 'request':request | |
60 | + } | |
61 | + context['links'] = Link.objects.filter(topic = topic) | |
62 | + context['slug'] = topic.slug | |
63 | + return context | |
64 | + | |
65 | +@register.inclusion_tag('topic/link_topic_list.html') | |
66 | +def list_topic_link(request,topic): | |
67 | + context = { | |
68 | + 'request':request | |
69 | + } | |
70 | + context['links'] = Link.objects.filter(topic = topic) | |
71 | + context['slug'] = topic.slug | |
72 | + return context | ... | ... |
courses/urls.py
... | ... | @@ -30,6 +30,7 @@ urlpatterns = [ |
30 | 30 | url(r'^exam/', include('exam.urls', namespace = 'exam')), |
31 | 31 | url(r'^files/', include('files.urls', namespace = 'file')), |
32 | 32 | url(r'^upload-material/$', views.UploadMaterialView.as_view(), name='upload_material'), |
33 | + url(r'^links/',include('links.urls',namespace = 'links')), | |
33 | 34 | |
34 | 35 | |
35 | 36 | ... | ... |
forum/tests/test_model_answer.py
... | ... | @@ -93,16 +93,26 @@ class PostAnswerTestCase (TestCase): |
93 | 93 | ) |
94 | 94 | self.post_student.save() |
95 | 95 | |
96 | - self.answer = PostAnswer.objects.create( | |
96 | + self.answerStudent = PostAnswer.objects.create( | |
97 | 97 | user = self.user_student, |
98 | 98 | post = self.post_professor, |
99 | 99 | message = 'testing a post answer', |
100 | 100 | modification_date = '2016-10-05', |
101 | 101 | answer_date = '2016-10-04', |
102 | 102 | ) |
103 | - self.answer.save() | |
103 | + self.answerStudent.save() | |
104 | + | |
105 | + self.answerProfessor = PostAnswer.objects.create( | |
106 | + user = self.user_professor, | |
107 | + post = self.post_student, | |
108 | + message = 'testing a post answer', | |
109 | + modification_date = '2016-10-05', | |
110 | + answer_date = '2016-10-04', | |
111 | + ) | |
112 | + self.answerProfessor.save() | |
104 | 113 | |
105 | 114 | def test_create_answer_post (self): |
115 | + list_answers = PostAnswer.objects.filter(user=self.user_professor).count() | |
106 | 116 | answer = PostAnswer.objects.create( |
107 | 117 | user = self.user_professor, |
108 | 118 | post = self.post_student, |
... | ... | @@ -112,19 +122,46 @@ class PostAnswerTestCase (TestCase): |
112 | 122 | ) |
113 | 123 | answer.save() |
114 | 124 | |
115 | - self.assertEquals (answer, PostAnswer.objects.get(user=self.user_professor, post=self.post_student)) | |
125 | + self.assertEquals (list_answers+1, PostAnswer.objects.filter(user=self.user_professor, post=self.post_student).count()) | |
126 | + | |
127 | + list_answers = PostAnswer.objects.filter(user=self.user_student).count() | |
128 | + answer = PostAnswer.objects.create( | |
129 | + user = self.user_student, | |
130 | + post = self.post_professor, | |
131 | + message = 'testing a post answer2', | |
132 | + modification_date = '2016-10-05', | |
133 | + answer_date = '2016-10-04', | |
134 | + ) | |
135 | + answer.save() | |
136 | + | |
137 | + self.assertEquals (list_answers+1, PostAnswer.objects.filter(user=self.user_student, post=self.post_professor).count()) | |
116 | 138 | |
117 | 139 | def test_update_answer_post (self): |
118 | - self.answer.message = 'updating a answer post' | |
119 | - self.answer.save() | |
140 | + self.answerStudent.message = 'updating a student answer post' | |
141 | + self.answerStudent.save() | |
142 | + answer = PostAnswer.objects.get(message='updating a student answer post') | |
120 | 143 | |
121 | - self.assertEquals(self.answer, PostAnswer.objects.all()[0]) | |
144 | + self.assertEquals(self.answerStudent, answer) | |
122 | 145 | |
123 | - def test_delete_answer_post (self): | |
124 | - answer = PostAnswer.objects.get(user=self.user_student, post=self.post_professor) | |
125 | - self.answer.delete() | |
126 | 146 | |
127 | - try: | |
128 | - answer = PostAnswer.objects.get(user=self.user_student, post=self.post_professor) | |
129 | - except: | |
130 | - pass | |
131 | 147 | \ No newline at end of file |
148 | + self.answerProfessor.message = 'updating a professor answer post' | |
149 | + self.answerProfessor.save() | |
150 | + answer = PostAnswer.objects.get(message='updating a professor answer post') | |
151 | + | |
152 | + self.assertEquals(self.answerProfessor, answer) | |
153 | + | |
154 | + def test_delete_answer_post (self): | |
155 | + list_studentAnswers = PostAnswer.objects.filter(user=self.user_student).count() | |
156 | + self.assertEquals(list_studentAnswers, 1) | |
157 | + | |
158 | + self.answerStudent.delete() | |
159 | + list_studentAnswers = PostAnswer.objects.filter(user=self.user_student).count() | |
160 | + self.assertEquals(list_studentAnswers, 0) | |
161 | + | |
162 | + list_professorAnswers = PostAnswer.objects.filter(user=self.user_professor).count() | |
163 | + self.assertEquals(list_professorAnswers, 1) | |
164 | + | |
165 | + self.answerProfessor.delete() | |
166 | + list_professorAnswers = PostAnswer.objects.filter(user=self.user_professor).count() | |
167 | + self.assertEquals(list_professorAnswers, 0) | |
168 | + | |
132 | 169 | \ No newline at end of file | ... | ... |
forum/tests/test_model_forum.py
... | ... | @@ -77,6 +77,8 @@ class ForumTestCase (TestCase): |
77 | 77 | self.forum.save() |
78 | 78 | |
79 | 79 | def test_create_forum (self): |
80 | + list_forum = Forum.objects.all().count() | |
81 | + | |
80 | 82 | forum = Forum.objects.create( |
81 | 83 | topic=self.topic, |
82 | 84 | name = 'forum test2', |
... | ... | @@ -87,20 +89,18 @@ class ForumTestCase (TestCase): |
87 | 89 | ) |
88 | 90 | forum.save() |
89 | 91 | |
90 | - self.assertEquals(forum, Forum.objects.filter(name='forum test2')[0]) | |
92 | + self.assertEquals(list_forum+1, Forum.objects.all().count()) | |
91 | 93 | |
92 | - def test_update_forum(self): | |
94 | + def test_update_forum(self): | |
95 | + list_forum = Forum.objects.all().count() | |
93 | 96 | self.forum.name = 'forum test updated' |
94 | 97 | self.forum.save() |
95 | 98 | |
96 | 99 | self.assertEquals(self.forum, Forum.objects.get(name='forum test updated')) |
100 | + self.assertEquals(list_forum, Forum.objects.all().count()) | |
97 | 101 | |
98 | 102 | def test_delete_forum (self): |
99 | - forum = Forum.objects.get(name='forum test') | |
103 | + list_forum = Forum.objects.all().count() | |
100 | 104 | self.forum.delete() |
101 | 105 | |
102 | - try: | |
103 | - forum = Forum.objects.get(name='forum test') | |
104 | - except: | |
105 | - pass | |
106 | - | |
107 | 106 | \ No newline at end of file |
107 | + self.assertEquals(list_forum-1, Forum.objects.all().count()) | |
108 | 108 | \ No newline at end of file | ... | ... |
links/admin.py
... | ... | @@ -3,8 +3,8 @@ from django.contrib import admin |
3 | 3 | from .models import Link |
4 | 4 | |
5 | 5 | class LinkAdmin(admin.ModelAdmin): |
6 | - list_display = ['name', 'link','description'] | |
7 | - search_fields = ['name', 'link','description'] | |
6 | + list_display = ['name', 'link_url','link_description'] | |
7 | + search_fields = ['name', 'link_url','link_description'] | |
8 | 8 | |
9 | 9 | |
10 | 10 | admin.site.register(Link, LinkAdmin) | ... | ... |
links/forms.py
... | ... | @@ -5,16 +5,16 @@ import validators |
5 | 5 | class CreateLinkForm(forms.ModelForm): |
6 | 6 | |
7 | 7 | def clean_link(self): |
8 | - link = self.cleaned_data['link'] | |
9 | - if not validators.url(link): | |
8 | + link_url = self.cleaned_data['link_url'] | |
9 | + if not validators.url(link_url): | |
10 | 10 | raise forms.ValidationError(_('Please enter a valid URL')) |
11 | - return link | |
11 | + return link_url | |
12 | 12 | |
13 | 13 | class Meta: |
14 | 14 | model = Link |
15 | - fields = ['name','link','description'] | |
15 | + fields = ['name','link_url','link_description'] | |
16 | 16 | |
17 | 17 | class UpdateLinkForm(forms.ModelForm): |
18 | 18 | class Meta: |
19 | 19 | model = Link |
20 | - fields = ['name','link','description'] | |
20 | + fields = ['name','link_url','link_description'] | ... | ... |
links/models.py
1 | - | |
2 | 1 | from django.db import models |
3 | 2 | from courses.models import Material |
4 | 3 | from autoslug.fields import AutoSlugField |
5 | 4 | # Create your models here. |
6 | -class Link(models.Model): | |
7 | - name = models.CharField(max_length=100) | |
8 | - link = models.URLField() | |
9 | - description = models.CharField(max_length=200) | |
5 | +class Link(Material): | |
6 | + link_url = models.URLField() | |
7 | + link_description = models.CharField(max_length=200) | |
10 | 8 | class Meta: |
11 | 9 | verbose_name = 'Link' |
12 | 10 | verbose_name_plural = "Links" | ... | ... |
links/urls.py
... | ... | @@ -2,5 +2,7 @@ from django.conf.urls import url, include |
2 | 2 | from . import views |
3 | 3 | |
4 | 4 | urlpatterns = [ |
5 | - url(r'^$', views.CreateLink.as_view(), name='teste') | |
5 | + url(r'^$', views.CreateLink.as_view(), name='create_link'), | |
6 | + url(r'^deletelink/(?P<linkname>[\w_-]+)/$', views.deleteLink,name = 'delete_link'), | |
7 | + url(r'^updatelink/(?P<linkname>[\w_-]+)/$', views.UpdateLink.as_view(),name = 'update_link'), | |
6 | 8 | ] | ... | ... |
links/views.py
... | ... | @@ -13,7 +13,7 @@ class CreateLink(generic.CreateView): |
13 | 13 | template_name = 'links/create_link.html' |
14 | 14 | form_class = CreateLinkForm |
15 | 15 | success_url = reverse_lazy('course:manage') |
16 | - context_object_name = 'links' | |
16 | + context_object_name = 'form' | |
17 | 17 | |
18 | 18 | def form_valid(self, form): |
19 | 19 | form.save() |
... | ... | @@ -26,7 +26,6 @@ class CreateLink(generic.CreateView): |
26 | 26 | context['form'] = CreateLinkForm |
27 | 27 | return context |
28 | 28 | |
29 | - | |
30 | 29 | def deleteLink(request,linkname): |
31 | 30 | link = get_object_or_404(Link,name = linkname) |
32 | 31 | link.delete() | ... | ... |