Commit 47688d9066d19bc17f1d2780dd8a4915f2ca0441
Exists in
master
and in
3 other branches
Merge branch 'refactoring' of https://github.com/amadeusproject/amadeuslms into refactoring
Showing
14 changed files
with
193 additions
and
123 deletions
Show diff stats
amadeus/static/css/base/amadeus.css
@@ -752,29 +752,21 @@ a.add-row { | @@ -752,29 +752,21 @@ a.add-row { | ||
752 | } | 752 | } |
753 | 753 | ||
754 | .resource_list { | 754 | .resource_list { |
755 | - margin-left: 30px; | 755 | + margin-left: 20px; |
756 | border-top: none !important; | 756 | border-top: none !important; |
757 | } | 757 | } |
758 | 758 | ||
759 | -.resource_list > .list-group-item:first-child { | ||
760 | - border-top-left-radius: 4px !important; | ||
761 | - border-top-right-radius: 4px !important; | ||
762 | -} | ||
763 | - | ||
764 | .resource_list > .list-group-item { | 759 | .resource_list > .list-group-item { |
765 | position: relative; | 760 | position: relative; |
766 | display: block; | 761 | display: block; |
767 | - padding: 10px 15px; | 762 | + padding: 10px 0px 10px 15px; |
768 | margin-bottom: -1px; | 763 | margin-bottom: -1px; |
769 | - border-width: 1px !important; | ||
770 | overflow: inherit; | 764 | overflow: inherit; |
771 | cursor: pointer; | 765 | cursor: pointer; |
772 | } | 766 | } |
773 | 767 | ||
774 | .resource_list > .list-group-item:last-child { | 768 | .resource_list > .list-group-item:last-child { |
775 | margin-bottom: 0; | 769 | margin-bottom: 0; |
776 | - border-bottom-right-radius: 4px !important; | ||
777 | - border-bottom-left-radius: 4px !important; | ||
778 | } | 770 | } |
779 | 771 | ||
780 | .resource_list .list-group-item .list-group-item-heading { | 772 | .resource_list .list-group-item .list-group-item-heading { |
@@ -786,10 +778,40 @@ a.add-row { | @@ -786,10 +778,40 @@ a.add-row { | ||
786 | margin: 0px; | 778 | margin: 0px; |
787 | } | 779 | } |
788 | 780 | ||
781 | +.resource_list .btn-group button { | ||
782 | + margin-top: -5px; | ||
783 | + padding-right: 15px; | ||
784 | + padding-left: 15px; | ||
785 | +} | ||
786 | + | ||
787 | +.resource_list .btn-group button:focus { | ||
788 | + outline: none; | ||
789 | +} | ||
790 | + | ||
791 | +.resource_list .btn-group button:active { | ||
792 | + margin-top: -5px; | ||
793 | +} | ||
794 | + | ||
795 | +.resource_list .btn-group button i { | ||
796 | + margin-right: 0px; | ||
797 | +} | ||
798 | + | ||
799 | +.resource_list .fa-arrows { | ||
800 | + margin-right: 0px; | ||
801 | +} | ||
802 | + | ||
789 | .resource_list > .disabled a { | 803 | .resource_list > .disabled a { |
790 | cursor: not-allowed; | 804 | cursor: not-allowed; |
791 | } | 805 | } |
792 | 806 | ||
793 | .resource_list a:hover, .resource_list a:focus { | 807 | .resource_list a:hover, .resource_list a:focus { |
794 | text-decoration: none; | 808 | text-decoration: none; |
809 | +} | ||
810 | + | ||
811 | +.add_resource i { | ||
812 | + margin-right: 10px; | ||
813 | +} | ||
814 | + | ||
815 | +.add_resource ul { | ||
816 | + width: 100%; | ||
795 | } | 817 | } |
796 | \ No newline at end of file | 818 | \ No newline at end of file |
amadeus/static/css/themes/green.css
@@ -370,7 +370,7 @@ a.add-row { | @@ -370,7 +370,7 @@ a.add-row { | ||
370 | } | 370 | } |
371 | 371 | ||
372 | .resource_list > .disabled a { | 372 | .resource_list > .disabled a { |
373 | - color: #777; | 373 | + color: #BDBDBD; |
374 | } | 374 | } |
375 | 375 | ||
376 | .resource_list > .list-group-item:hover { | 376 | .resource_list > .list-group-item:hover { |
@@ -393,6 +393,10 @@ a.add-row { | @@ -393,6 +393,10 @@ a.add-row { | ||
393 | color: inherit; | 393 | color: inherit; |
394 | } | 394 | } |
395 | 395 | ||
396 | +.resource_list .btn-group button:active, .resource_list .btn-group button:focus, .resource_list .btn-group button:hover { | ||
397 | + background-color: initial !important; | ||
398 | +} | ||
399 | + | ||
396 | @media(max-width: 768px) { | 400 | @media(max-width: 768px) { |
397 | .navbar .navbar-nav .dropdown .dropdown-menu li > a { | 401 | .navbar .navbar-nav .dropdown .dropdown-menu li > a { |
398 | color: #333333 !important; | 402 | color: #333333 !important; |
subjects/templates/subjects/view.html
@@ -81,5 +81,17 @@ | @@ -81,5 +81,17 @@ | ||
81 | {% if resource_new_page %} | 81 | {% if resource_new_page %} |
82 | window.open("{{ resource_new_page_url }}"); | 82 | window.open("{{ resource_new_page_url }}"); |
83 | {% endif %} | 83 | {% endif %} |
84 | + | ||
85 | + $(function (){ | ||
86 | + var topic_slug = "{{ topic_slug }}" | ||
87 | + | ||
88 | + if (topic_slug != "") { | ||
89 | + $("#" + topic_slug).collapse('show'); | ||
90 | + | ||
91 | + $('html, body').animate({ | ||
92 | + scrollTop: $("#" + topic_slug).parent().offset().top | ||
93 | + }, 1000); | ||
94 | + } | ||
95 | + }); | ||
84 | </script> | 96 | </script> |
85 | {% endblock content %} | 97 | {% endblock content %} |
86 | \ No newline at end of file | 98 | \ No newline at end of file |
subjects/urls.py
@@ -10,6 +10,7 @@ urlpatterns = [ | @@ -10,6 +10,7 @@ urlpatterns = [ | ||
10 | url(r'^update/(?P<slug>[\w_-]+)/$', views.SubjectUpdateView.as_view(), name='update'), | 10 | url(r'^update/(?P<slug>[\w_-]+)/$', views.SubjectUpdateView.as_view(), name='update'), |
11 | url(r'^delete/(?P<slug>[\w_-]+)/$', views.SubjectDeleteView.as_view(), name='delete'), | 11 | url(r'^delete/(?P<slug>[\w_-]+)/$', views.SubjectDeleteView.as_view(), name='delete'), |
12 | url(r'^view/(?P<slug>[\w_-]+)/$', views.SubjectDetailView.as_view(), name='view'), | 12 | url(r'^view/(?P<slug>[\w_-]+)/$', views.SubjectDetailView.as_view(), name='view'), |
13 | + url(r'^view/(?P<slug>[\w_-]+)/(?P<topic_slug>[\w_-]+)/$', views.SubjectDetailView.as_view(), name='topic_view'), | ||
13 | url(r'^subscribe/(?P<slug>[\w_-]+)/$', views.SubjectSubscribeView.as_view(), name='subscribe'), | 14 | url(r'^subscribe/(?P<slug>[\w_-]+)/$', views.SubjectSubscribeView.as_view(), name='subscribe'), |
14 | url(r'^search/$', views.SubjectSearchView.as_view(), name='search'), | 15 | url(r'^search/$', views.SubjectSearchView.as_view(), name='search'), |
15 | url(r'^search/(?P<option>[\w_-]+)/$', views.SubjectSearchView.as_view(), name='search'), | 16 | url(r'^search/(?P<option>[\w_-]+)/$', views.SubjectSearchView.as_view(), name='search'), |
subjects/views.py
@@ -453,6 +453,9 @@ class SubjectDetailView(LoginRequiredMixin, DetailView): | @@ -453,6 +453,9 @@ class SubjectDetailView(LoginRequiredMixin, DetailView): | ||
453 | 453 | ||
454 | self.request.session['resources'] = None | 454 | self.request.session['resources'] = None |
455 | 455 | ||
456 | + if self.kwargs.get('topic_slug'): | ||
457 | + context['topic_slug'] = self.kwargs.get('topic_slug') | ||
458 | + | ||
456 | return context | 459 | return context |
457 | 460 | ||
458 | 461 |
topics/models.py
@@ -77,3 +77,19 @@ class Resource(KnowsChild): | @@ -77,3 +77,19 @@ class Resource(KnowsChild): | ||
77 | @always_as_child | 77 | @always_as_child |
78 | def access_link(self): | 78 | def access_link(self): |
79 | pass | 79 | pass |
80 | + | ||
81 | + """ | ||
82 | + Method to get the appropriated update link | ||
83 | + Must override in the child models | ||
84 | + """ | ||
85 | + @always_as_child | ||
86 | + def update_link(self): | ||
87 | + pass | ||
88 | + | ||
89 | + """ | ||
90 | + Method to get the appropriated delete link | ||
91 | + Must override in the child models | ||
92 | + """ | ||
93 | + @always_as_child | ||
94 | + def delete_link(self): | ||
95 | + pass | ||
80 | \ No newline at end of file | 96 | \ No newline at end of file |
@@ -0,0 +1,108 @@ | @@ -0,0 +1,108 @@ | ||
1 | +{% load static i18n pagination permissions_tags %} | ||
2 | +{% load django_bootstrap_breadcrumbs %} | ||
3 | + | ||
4 | +{% subject_permissions request.user topic.subject as has_subject_permissions %} | ||
5 | + | ||
6 | +<div id="resource_{{ topic.slug }}" class="list-group resource_list"> | ||
7 | + {% for resource in topic.resource_topic.all %} | ||
8 | + {% if resource.visible or has_subject_permissions %} | ||
9 | + <div class="list-group-item {% if not resource.visible %}disabled{% endif %}"> | ||
10 | + <input type="hidden" class="id_inp" name="id" value="{{ resource.id }}" /> | ||
11 | + <input type="hidden" class="order_inp" name="order" value="{{ resource.order }}" /> | ||
12 | + <input type="hidden" class="url_order" value="{% url 'topics:update_resource_order' %}" /> | ||
13 | + | ||
14 | + <h4 class="pull-left list-group-item-heading"> | ||
15 | + <a href="{% url resource.access_link resource.slug %}" class="resource_link" {% if resource.show_window %}target="_blank"{% endif %}> | ||
16 | + {{ resource }} | ||
17 | + </a> | ||
18 | + </h4> | ||
19 | + | ||
20 | + {% if has_subject_permissions %} | ||
21 | + <div class="pull-right category-card-items"> | ||
22 | + <a><i class="fa fa-arrows" aria-hidden="true"></i></a> | ||
23 | + <span class="btn-group pull-right"> | ||
24 | + <button class="btn btn-sm btn_menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | ||
25 | + <i class="fa fa-ellipsis-v" aria-hidden="true"></i> | ||
26 | + </button> | ||
27 | + <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="moreResources"> | ||
28 | + <li><a href="{% url resource.update_link topic.slug resource.slug %}" class="edit"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i>{% trans 'Edit' %}</a></li> | ||
29 | + <li><a href="javascript:delete_resource('{% url resource.delete_link resource.slug %}')" class="delete"><i class="fa fa-trash fa-fw" aria-hidden="true"></i>{% trans 'Remove' %}</a></li> | ||
30 | + </ul> | ||
31 | + </span> | ||
32 | + </div> | ||
33 | + {% endif %} | ||
34 | + <br clear="all" /> | ||
35 | + {% autoescape off %} | ||
36 | + {{ resource.brief_description }} | ||
37 | + {% endautoescape %} | ||
38 | + </div> | ||
39 | + {% endif %} | ||
40 | + {% endfor %} | ||
41 | +</div> | ||
42 | +<script type="text/javascript"> | ||
43 | + function delete_resource(url) { | ||
44 | + $('.modal').remove(); | ||
45 | + | ||
46 | + $.get(url, function (modal) { | ||
47 | + $("#resource_{{ topic.slug }}").parent().after(modal); | ||
48 | + | ||
49 | + $('.modal').modal('show'); | ||
50 | + }); | ||
51 | + } | ||
52 | + | ||
53 | + $(".list-group-item").unbind().on('click', function (e) { | ||
54 | + var arrow = $(this).find('i.fa-arrows').is(e.target), | ||
55 | + menu = $(this).find('i.fa-ellipsis-v').is(e.target), | ||
56 | + btn = $(this).find('button.btn_menu').is(e.target), | ||
57 | + del = $(this).find('a.delete').is(e.target), | ||
58 | + upd = $(this).find('a.edit').is(e.target); | ||
59 | + | ||
60 | + if (!arrow && !menu && !del && !upd && !btn) { | ||
61 | + var link = $(this).find('.resource_link').attr('href'), | ||
62 | + target = $(this).find('.resource_link').attr('target'); | ||
63 | + | ||
64 | + if (typeof(target) != 'undefined') { | ||
65 | + window.open(link, target); | ||
66 | + } else { | ||
67 | + window.location = link; | ||
68 | + } | ||
69 | + } | ||
70 | + }); | ||
71 | + | ||
72 | + $("#resource_{{ topic.slug }}").sortable({ | ||
73 | + delay: 100, | ||
74 | + distance: 5, | ||
75 | + handle: 'i.fa-arrows', | ||
76 | + update: function( event, ui ) { | ||
77 | + var cont = 1; | ||
78 | + var data = []; | ||
79 | + | ||
80 | + $("#resource_{{ topic.slug }}").find('.order_inp').each(function () { | ||
81 | + $(this).val(cont++); | ||
82 | + | ||
83 | + data.push({ | ||
84 | + 'resource_id': $(this).parent().find('.id_inp').val(), | ||
85 | + 'resource_order': $(this).val() | ||
86 | + }); | ||
87 | + }); | ||
88 | + | ||
89 | + data = JSON.stringify(data); | ||
90 | + | ||
91 | + sendUpdateResource(data); | ||
92 | + }, | ||
93 | + }); | ||
94 | + | ||
95 | + function sendUpdateResource(data) { | ||
96 | + $.ajax({ | ||
97 | + url: $("#resource_{{ topic.slug }}").find('.url_order').val(), | ||
98 | + dataType: 'json', | ||
99 | + data: {'data': data}, | ||
100 | + success: function(response) { | ||
101 | + console.log(response); | ||
102 | + }, | ||
103 | + error: function(response) { | ||
104 | + console.log(response); | ||
105 | + } | ||
106 | + }); | ||
107 | + } | ||
108 | +</script> | ||
0 | \ No newline at end of file | 109 | \ No newline at end of file |
topics/templates/topics/list.html
webpage/models.py
@@ -19,3 +19,9 @@ class Webpage(Resource): | @@ -19,3 +19,9 @@ class Webpage(Resource): | ||
19 | return 'webpages:window_view' | 19 | return 'webpages:window_view' |
20 | 20 | ||
21 | return 'webpages:view' | 21 | return 'webpages:view' |
22 | + | ||
23 | + def update_link(self): | ||
24 | + return 'webpages:update' | ||
25 | + | ||
26 | + def delete_link(self): | ||
27 | + return 'webpages:delete' |
webpage/templates/webpages/create.html
@@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
16 | {% block breadcrumbs %} | 16 | {% block breadcrumbs %} |
17 | {{ block.super }} | 17 | {{ block.super }} |
18 | 18 | ||
19 | - {% breadcrumb topic 'subjects:view' topic.subject.slug %} | 19 | + {% breadcrumb topic 'subjects:topic_view' topic.subject.slug topic.slug %} |
20 | 20 | ||
21 | {% trans 'Create Webpage' as bread %} | 21 | {% trans 'Create Webpage' as bread %} |
22 | {% breadcrumb bread 'webpages:create' topic.slug %} | 22 | {% breadcrumb bread 'webpages:create' topic.slug %} |
webpage/templates/webpages/list.html
@@ -1,108 +0,0 @@ | @@ -1,108 +0,0 @@ | ||
1 | -{% load static i18n pagination permissions_tags %} | ||
2 | -{% load django_bootstrap_breadcrumbs %} | ||
3 | - | ||
4 | -{% subject_permissions request.user topic.subject as has_subject_permissions %} | ||
5 | - | ||
6 | -<div id="resource_{{ topic.slug }}" class="list-group resource_list"> | ||
7 | - {% for resource in topic.resource_topic.all %} | ||
8 | - {% if resource.visible or has_subject_permissions %} | ||
9 | - <div class="list-group-item {% if not resource.visible %}disabled{% endif %}"> | ||
10 | - <input type="hidden" class="id_inp" name="id" value="{{ resource.id }}" /> | ||
11 | - <input type="hidden" class="order_inp" name="order" value="{{ resource.order }}" /> | ||
12 | - <input type="hidden" class="url_order" value="{% url 'topics:update_resource_order' %}" /> | ||
13 | - | ||
14 | - <h4 class="pull-left list-group-item-heading"> | ||
15 | - <a href="{% url resource.access_link resource.slug %}" class="resource_link" {% if resource.show_window %}target="_blank"{% endif %}> | ||
16 | - {{ resource }} | ||
17 | - </a> | ||
18 | - </h4> | ||
19 | - | ||
20 | - {% if has_subject_permissions %} | ||
21 | - <div class="pull-right category-card-items"> | ||
22 | - <a><i class="fa fa-arrows" aria-hidden="true"></i></a> | ||
23 | - <span class="btn-group"> | ||
24 | - <a href="" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | ||
25 | - <i class="fa fa-ellipsis-v" aria-hidden="true"></i> | ||
26 | - </a> | ||
27 | - <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="moreResources"> | ||
28 | - <li><a href="{% url 'webpages:update' topic.slug resource.slug %}" class="edit"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i>{% trans 'Edit' %}</a></li> | ||
29 | - <li><a href="javascript:delete_resource('{% url 'webpages:delete' resource.slug %}')" class="delete"><i class="fa fa-trash fa-fw" aria-hidden="true"></i>{% trans 'Remove' %}</a></li> | ||
30 | - </ul> | ||
31 | - </span> | ||
32 | - </div> | ||
33 | - {% endif %} | ||
34 | - <br clear="all" /> | ||
35 | - {% autoescape off %} | ||
36 | - {{ resource.brief_description }} | ||
37 | - {% endautoescape %} | ||
38 | - </div> | ||
39 | - {% endif %} | ||
40 | - {% endfor %} | ||
41 | -</div> | ||
42 | -<script type="text/javascript"> | ||
43 | - function delete_resource(url) { | ||
44 | - $('.modal').remove(); | ||
45 | - | ||
46 | - $.get(url, function (modal) { | ||
47 | - $("#resource_{{ topic.slug }}").parent().after(modal); | ||
48 | - | ||
49 | - $('.modal').modal('show'); | ||
50 | - }); | ||
51 | - } | ||
52 | - | ||
53 | - $(".list-group-item").unbind().on('click', function (e) { | ||
54 | - var arrow = $(this).find('i.fa-arrows').is(e.target), | ||
55 | - menu = $(this).find('i.fa-ellipsis-v').is(e.target), | ||
56 | - del = $(this).find('a.delete').is(e.target), | ||
57 | - upd = $(this).find('a.edit').is(e.target); | ||
58 | - | ||
59 | - | ||
60 | - if (!arrow && !menu && !del && !upd) { | ||
61 | - var link = $(this).find('.resource_link').attr('href'), | ||
62 | - target = $(this).find('.resource_link').attr('target'); | ||
63 | - | ||
64 | - if (typeof(target) != 'undefined') { | ||
65 | - window.open(link, target); | ||
66 | - } else { | ||
67 | - window.location = link; | ||
68 | - } | ||
69 | - } | ||
70 | - }); | ||
71 | - | ||
72 | - $("#resource_{{ topic.slug }}").sortable({ | ||
73 | - delay: 100, | ||
74 | - distance: 5, | ||
75 | - handle: 'i.fa-arrows', | ||
76 | - update: function( event, ui ) { | ||
77 | - var cont = 1; | ||
78 | - var data = []; | ||
79 | - | ||
80 | - $("#resource_{{ topic.slug }}").find('.order_inp').each(function () { | ||
81 | - $(this).val(cont++); | ||
82 | - | ||
83 | - data.push({ | ||
84 | - 'resource_id': $(this).parent().find('.id_inp').val(), | ||
85 | - 'resource_order': $(this).val() | ||
86 | - }); | ||
87 | - }); | ||
88 | - | ||
89 | - data = JSON.stringify(data); | ||
90 | - | ||
91 | - sendUpdateResource(data); | ||
92 | - }, | ||
93 | - }); | ||
94 | - | ||
95 | - function sendUpdateResource(data) { | ||
96 | - $.ajax({ | ||
97 | - url: $("#resource_{{ topic.slug }}").find('.url_order').val(), | ||
98 | - dataType: 'json', | ||
99 | - data: {'data': data}, | ||
100 | - success: function(response) { | ||
101 | - console.log(response); | ||
102 | - }, | ||
103 | - error: function(response) { | ||
104 | - console.log(response); | ||
105 | - } | ||
106 | - }); | ||
107 | - } | ||
108 | -</script> | ||
109 | \ No newline at end of file | 0 | \ No newline at end of file |
webpage/templates/webpages/update.html
@@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
16 | {% block breadcrumbs %} | 16 | {% block breadcrumbs %} |
17 | {{ block.super }} | 17 | {{ block.super }} |
18 | 18 | ||
19 | - {% breadcrumb topic 'subjects:view' topic.subject.slug %} | 19 | + {% breadcrumb topic 'subjects:topic_view' topic.subject.slug topic.slug %} |
20 | 20 | ||
21 | {% trans 'Edit: ' as bread %} | 21 | {% trans 'Edit: ' as bread %} |
22 | {% with bread|add:webpage.name as bread_slug %} | 22 | {% with bread|add:webpage.name as bread_slug %} |
webpage/templates/webpages/view.html
@@ -9,7 +9,7 @@ | @@ -9,7 +9,7 @@ | ||
9 | 9 | ||
10 | {% block breadcrumbs %} | 10 | {% block breadcrumbs %} |
11 | {{ block.super }} | 11 | {{ block.super }} |
12 | - {% breadcrumb topic 'subjects:view' subject.slug %} | 12 | + {% breadcrumb topic 'subjects:topic_view' subject.slug topic.slug %} |
13 | {% breadcrumb webpage 'webpages:view' webpage.slug %} | 13 | {% breadcrumb webpage 'webpages:view' webpage.slug %} |
14 | {% endblock %} | 14 | {% endblock %} |
15 | 15 |
webpage/views.py
@@ -123,6 +123,9 @@ class CreateView(LoginRequiredMixin, generic.edit.CreateView): | @@ -123,6 +123,9 @@ class CreateView(LoginRequiredMixin, generic.edit.CreateView): | ||
123 | self.object.topic = topic | 123 | self.object.topic = topic |
124 | self.object.order = topic.resource_topic.count() + 1 | 124 | self.object.order = topic.resource_topic.count() + 1 |
125 | 125 | ||
126 | + if not self.object.topic.visible and not self.object.topic.repository: | ||
127 | + self.object.visible = False | ||
128 | + | ||
126 | self.object.save() | 129 | self.object.save() |
127 | 130 | ||
128 | pendencies_form.instance = self.object | 131 | pendencies_form.instance = self.object |
@@ -201,6 +204,9 @@ class UpdateView(LoginRequiredMixin, generic.UpdateView): | @@ -201,6 +204,9 @@ class UpdateView(LoginRequiredMixin, generic.UpdateView): | ||
201 | def form_valid(self, form, pendencies_form): | 204 | def form_valid(self, form, pendencies_form): |
202 | self.object = form.save(commit = False) | 205 | self.object = form.save(commit = False) |
203 | 206 | ||
207 | + if not self.object.topic.visible and not self.object.topic.repository: | ||
208 | + self.object.visible = False | ||
209 | + | ||
204 | self.object.save() | 210 | self.object.save() |
205 | 211 | ||
206 | pendencies_form.instance = self.object | 212 | pendencies_form.instance = self.object |