Commit 069dc0641643bf0de382219520b6cb1193fffa70
1 parent
f9ed2485
Exists in
master
and in
3 other branches
Adding mural subject page
Showing
13 changed files
with
332 additions
and
81 deletions
Show diff stats
amadeus/static/css/.sass-cache/a7f87b90919294b62ab4f8079e31dcda8f485534/black.sassc
No preview for this file type
amadeus/static/css/.sass-cache/a7f87b90919294b62ab4f8079e31dcda8f485534/red.sassc
No preview for this file type
amadeus/static/js/mural_category.js
| ... | ... | @@ -17,6 +17,7 @@ $('.mural-category').on('shown.bs.collapse', function(e) { |
| 17 | 17 | loading = $(this).find('.loading-posts'), |
| 18 | 18 | more = $(this).find('.more-posts'), |
| 19 | 19 | filters = $(this).find('.post-filters'), |
| 20 | + clear_filters = $(this).find('.clear_filter'), | |
| 20 | 21 | mural = post_section.parent().parent(); |
| 21 | 22 | |
| 22 | 23 | if (post_section.children().length == 0) { |
| ... | ... | @@ -164,6 +165,14 @@ $('.mural-category').on('shown.bs.collapse', function(e) { |
| 164 | 165 | |
| 165 | 166 | return false; |
| 166 | 167 | }); |
| 168 | + | |
| 169 | + clear_filters.click(function () { | |
| 170 | + var frm = $(this).parent(); | |
| 171 | + | |
| 172 | + frm.find("input[type='checkbox']").prop('checked', false); | |
| 173 | + | |
| 174 | + frm.submit(); | |
| 175 | + }); | |
| 167 | 176 | } |
| 168 | 177 | }); |
| 169 | 178 | ... | ... |
| ... | ... | @@ -0,0 +1,26 @@ |
| 1 | +$('.mural-subject').on('shown.bs.collapse', function(e) { | |
| 2 | + if($(this).is(e.target)){ | |
| 3 | + var li = $(".breadcrumb").find('li:last-child'); | |
| 4 | + var li_text = $(li).html(); | |
| 5 | + var url = $(".mural_url").val(); | |
| 6 | + var new_li = $(li).clone(); | |
| 7 | + | |
| 8 | + new_li.html($(this).parent().find('.panel-title span').text()); | |
| 9 | + | |
| 10 | + $(li).html("<a href='" + url + "'>" + li_text + "</a>"); | |
| 11 | + $(li).append("<span class='divider'>/</span>"); | |
| 12 | + | |
| 13 | + new_li.appendTo('.breadcrumb'); | |
| 14 | + } | |
| 15 | +}); | |
| 16 | + | |
| 17 | +$('.mural-subject').on('hidden.bs.collapse', function(e) { | |
| 18 | + if($(this).is(e.target)){ | |
| 19 | + $(".breadcrumb").find('li:last-child').remove(); | |
| 20 | + | |
| 21 | + var li = $(".breadcrumb").find('li:last-child'); | |
| 22 | + var text = $(li).find('a').text(); | |
| 23 | + | |
| 24 | + $(li).html(text); | |
| 25 | + } | |
| 26 | +}); | |
| 0 | 27 | \ No newline at end of file | ... | ... |
mural/templates/mural/_view.html
| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | <i class="fa {{ post.action|action_icon }}"></i> |
| 13 | 13 | {{ post.get_action_display }} |
| 14 | 14 | </span> |
| 15 | - {% if request.user == post.user or request.user.is_staff %} | |
| 15 | + {% if post|show_settings:request.user %} | |
| 16 | 16 | <span class="btn-group pull-right"> |
| 17 | 17 | <button class="btn btn-sm btn_menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> |
| 18 | 18 | <i class="fa fa-ellipsis-v" aria-hidden="true"></i> | ... | ... |
mural/templates/mural/_view_comment.html
| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | <i class="fa fa-commenting-o"></i> |
| 14 | 14 | {% trans 'Comment' %} |
| 15 | 15 | </span> |
| 16 | - {% if request.user == comment.user or request.user.is_staff %} | |
| 16 | + {% if comment|show_settings_comment:request.user %} | |
| 17 | 17 | <span class="btn-group pull-right"> |
| 18 | 18 | <button class="btn btn-sm btn_menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> |
| 19 | 19 | <i class="fa fa-ellipsis-v" aria-hidden="true"></i> | ... | ... |
mural/templates/mural/list.html
| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | <ul class="core-subjects-options"> |
| 17 | 17 | <a href="{% url 'mural:manage_general' %}"><li class="active">{% trans "General" %} ({{ totals.general }})</li></a> |
| 18 | 18 | <a href="{% url 'mural:manage_category' %}"><li>{% trans "Per Category" %} ({{ totals.category }})</li></a> |
| 19 | - <a href=""><li>{% trans "Per Subject" %} ({{ totals.subject }})</li></a> | |
| 19 | + <a href="{% url 'mural:manage_subject' %}"><li>{% trans "Per Subject" %} ({{ totals.subject }})</li></a> | |
| 20 | 20 | </ul> |
| 21 | 21 | </div> |
| 22 | 22 | ... | ... |
mural/templates/mural/list_category.html
| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | <ul class="core-subjects-options"> |
| 19 | 19 | <a href="{% url 'mural:manage_general' %}"><li>{% trans "General" %} ({{ totals.general }})</li></a> |
| 20 | 20 | <a href="{% url 'mural:manage_category' %}"><li class="active">{% trans "Per Category" %} (<span class="cat_badge">{{ totals.category }}</span>)</li></a> |
| 21 | - <a href=""><li>{% trans "Per Subject" %} ({{ totals.subject }})</li></a> | |
| 21 | + <a href="{% url 'mural:manage_subject' %}"><li>{% trans "Per Subject" %} ({{ totals.subject }})</li></a> | |
| 22 | 22 | </ul> |
| 23 | 23 | </div> |
| 24 | 24 | |
| ... | ... | @@ -28,97 +28,99 @@ |
| 28 | 28 | {% for category in categories %} |
| 29 | 29 | {% category_permissions request.user category as has_category_permissions %} |
| 30 | 30 | |
| 31 | - {% if category.visible %} | |
| 32 | - <div class="panel panel-info category-panel"> | |
| 33 | - <div class="panel-heading"> | |
| 34 | - {% elif has_category_permissions %} | |
| 35 | - <div class="panel special-panel"> | |
| 36 | - <div class="panel-heading panel-invisible"> | |
| 37 | - {% endif %} | |
| 38 | - | |
| 39 | - <div class="row"> | |
| 40 | - <div class="col-md-12 category-header"> | |
| 41 | - <h4 class="panel-title"> | |
| 42 | - <a class="category-course-link pull-left" data-parent="#accordion" data-toggle="collapse" href="#{{category.slug}}"> | |
| 43 | - <button class="btn btn-default btn-xs text-center cat-selector"><i class="fa fa-angle-right fa-2x" aria-hidden="true"></i></button> <span>{{ category.name }}</span> | |
| 44 | - | |
| 45 | - ({{ category|unviewed:request.user }}) | |
| 46 | - </a> | |
| 47 | - </h4> | |
| 48 | - | |
| 49 | - <div class="col-md-5 pull-right category-card-items"> | |
| 50 | - {% if has_category_permissions %} | |
| 51 | - <a href="" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | |
| 52 | - <i class="fa fa-ellipsis-v" aria-hidden="true"></i> | |
| 31 | + {% if category.visible or has_category_permissions %} | |
| 32 | + {% if category.visible %} | |
| 33 | + <div class="panel panel-info category-panel"> | |
| 34 | + <div class="panel-heading"> | |
| 35 | + {% elif has_category_permissions %} | |
| 36 | + <div class="panel special-panel"> | |
| 37 | + <div class="panel-heading panel-invisible"> | |
| 38 | + {% endif %} | |
| 39 | + | |
| 40 | + <div class="row"> | |
| 41 | + <div class="col-md-12 category-header"> | |
| 42 | + <h4 class="panel-title"> | |
| 43 | + <a class="category-course-link pull-left" data-parent="#accordion" data-toggle="collapse" href="#{{category.slug}}"> | |
| 44 | + <button class="btn btn-default btn-xs text-center cat-selector"><i class="fa fa-angle-right fa-2x" aria-hidden="true"></i></button> <span>{{ category.name }}</span> | |
| 45 | + | |
| 46 | + ({{ category|unviewed:request.user }}) | |
| 53 | 47 | </a> |
| 54 | - <ul class="dropdown-menu pull-right" aria-labelledby="moreActions"> | |
| 55 | - {% if request.user.is_staff %} | |
| 56 | - <li><a href="{% url 'categories:replicate' category.slug %}"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i> {% trans 'Replicate' %}</a></li> | |
| 57 | - {% endif %} | |
| 58 | - <li><a href="{% url 'categories:update' category.slug %}"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i> {% trans 'Edit' %}</a></li> | |
| 59 | - <li> | |
| 60 | - <a href="javascript:delete_course.get('{% url 'categories:delete' category.slug %}?view=index','#category','#modal_course')" aria-hidden="true"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> {% trans 'Remove' %}</a></li> | |
| 61 | - </ul> | |
| 62 | - {% endif %} | |
| 48 | + </h4> | |
| 49 | + | |
| 50 | + <div class="col-md-5 pull-right category-card-items"> | |
| 51 | + {% if has_category_permissions %} | |
| 52 | + <a href="" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | |
| 53 | + <i class="fa fa-ellipsis-v" aria-hidden="true"></i> | |
| 54 | + </a> | |
| 55 | + <ul class="dropdown-menu pull-right" aria-labelledby="moreActions"> | |
| 56 | + {% if request.user.is_staff %} | |
| 57 | + <li><a href="{% url 'categories:replicate' category.slug %}"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i> {% trans 'Replicate' %}</a></li> | |
| 58 | + {% endif %} | |
| 59 | + <li><a href="{% url 'categories:update' category.slug %}"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i> {% trans 'Edit' %}</a></li> | |
| 60 | + <li> | |
| 61 | + <a href="javascript:delete_course.get('{% url 'categories:delete' category.slug %}?view=index','#category','#modal_course')" aria-hidden="true"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> {% trans 'Remove' %}</a></li> | |
| 62 | + </ul> | |
| 63 | + {% endif %} | |
| 64 | + </div> | |
| 63 | 65 | </div> |
| 64 | 66 | </div> |
| 65 | 67 | </div> |
| 66 | - </div> | |
| 67 | - <div id="{{category.slug}}" class="panel-collapse panel-body collapse mural-category"> | |
| 68 | - <div class="col-md-12 cards-content mural" data-url="{% url 'mural:load_category' category.id %}"> | |
| 69 | - <div class="col-md-9 col-sm-9 col-xs-9 mural-list"> | |
| 70 | - <div class="post_make panel panel-default"> | |
| 71 | - <div class="panel-body"> | |
| 72 | - <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 user-img text-center"> | |
| 73 | - <img src="{{ request.user.image_url }}" class="img-responsive" /> | |
| 74 | - </div> | |
| 75 | - <div class="col-lg-11 col-md-11 col-sm-11 col-xs-11 post-field"> | |
| 76 | - <div> | |
| 77 | - <h4 data-url="{% url 'mural:create_category' category.slug %}">{% trans 'Wish to make a new post?' %}</h4> | |
| 68 | + <div id="{{category.slug}}" class="panel-collapse panel-body collapse mural-category"> | |
| 69 | + <div class="col-md-12 cards-content mural" data-url="{% url 'mural:load_category' category.id %}"> | |
| 70 | + <div class="col-md-9 col-sm-9 col-xs-9 mural-list"> | |
| 71 | + <div class="post_make panel panel-default"> | |
| 72 | + <div class="panel-body"> | |
| 73 | + <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 user-img text-center"> | |
| 74 | + <img src="{{ request.user.image_url }}" class="img-responsive" /> | |
| 75 | + </div> | |
| 76 | + <div class="col-lg-11 col-md-11 col-sm-11 col-xs-11 post-field"> | |
| 77 | + <div> | |
| 78 | + <h4 data-url="{% url 'mural:create_category' category.slug %}">{% trans 'Wish to make a new post?' %}</h4> | |
| 79 | + </div> | |
| 78 | 80 | </div> |
| 79 | 81 | </div> |
| 80 | 82 | </div> |
| 81 | - </div> | |
| 82 | 83 | |
| 83 | - <div class="posts"> | |
| 84 | - </div> | |
| 85 | - | |
| 86 | - <button type="button" class="btn btn-block btn-success btn-raised more-posts" style="display:none"> | |
| 87 | - {% trans 'See more posts' %} | |
| 88 | - </button> | |
| 84 | + <div class="posts"> | |
| 85 | + </div> | |
| 89 | 86 | |
| 90 | - <div class="alert alert-success loading-posts" role="alert"> | |
| 91 | - <center> | |
| 92 | - <span class="fa fa-spin fa-circle-o-notch"></span> | |
| 93 | - </center> | |
| 94 | - </div> | |
| 87 | + <button type="button" class="btn btn-block btn-success btn-raised more-posts" style="display:none"> | |
| 88 | + {% trans 'See more posts' %} | |
| 89 | + </button> | |
| 95 | 90 | |
| 96 | - <div class="text-center no-subjects" style="display:none"> | |
| 97 | - <i class="fa fa-list"></i> | |
| 98 | - <h4>{% trans 'There are no posts in this mural yet.' %}</h4> | |
| 99 | - </div> | |
| 100 | - </div> | |
| 101 | - <div class="col-md-3 col-sm-3 col-xs-3 post-filter"> | |
| 102 | - <h4>{% trans 'Filter' %}</h4> | |
| 103 | - | |
| 104 | - <form class="post-filters" action="" method="GET"> | |
| 105 | - <div class="checkbox"> | |
| 106 | - <label> | |
| 107 | - <input name="favorite" type="checkbox"> {% trans 'Favorite posts' %} <i class="fa fa-thumb-tack"></i> | |
| 108 | - </label> | |
| 91 | + <div class="alert alert-success loading-posts" role="alert"> | |
| 92 | + <center> | |
| 93 | + <span class="fa fa-spin fa-circle-o-notch"></span> | |
| 94 | + </center> | |
| 109 | 95 | </div> |
| 110 | - <div class="checkbox"> | |
| 111 | - <label> | |
| 112 | - <input name="mine" type="checkbox"> {% trans 'Only my posts' %} | |
| 113 | - </label> | |
| 96 | + | |
| 97 | + <div class="text-center no-subjects" style="display:none"> | |
| 98 | + <i class="fa fa-list"></i> | |
| 99 | + <h4>{% trans 'There are no posts in this mural yet.' %}</h4> | |
| 114 | 100 | </div> |
| 115 | - <button type="submit" class="btn btn-success btn-raised btn-block">{% trans 'Filter' %}</button> | |
| 116 | - <button type="button" class="clear_filter btn btn-default btn-raised btn-block">{% trans 'Clean Filters' %}</button> | |
| 117 | - </form> | |
| 101 | + </div> | |
| 102 | + <div class="col-md-3 col-sm-3 col-xs-3 post-filter"> | |
| 103 | + <h4>{% trans 'Filter' %}</h4> | |
| 104 | + | |
| 105 | + <form class="post-filters" action="" method="GET"> | |
| 106 | + <div class="checkbox"> | |
| 107 | + <label> | |
| 108 | + <input name="favorite" type="checkbox"> {% trans 'Favorite posts' %} <i class="fa fa-thumb-tack"></i> | |
| 109 | + </label> | |
| 110 | + </div> | |
| 111 | + <div class="checkbox"> | |
| 112 | + <label> | |
| 113 | + <input name="mine" type="checkbox"> {% trans 'Only my posts' %} | |
| 114 | + </label> | |
| 115 | + </div> | |
| 116 | + <button type="submit" class="btn btn-success btn-raised btn-block">{% trans 'Filter' %}</button> | |
| 117 | + <button type="button" class="clear_filter btn btn-default btn-raised btn-block">{% trans 'Clean Filters' %}</button> | |
| 118 | + </form> | |
| 119 | + </div> | |
| 118 | 120 | </div> |
| 119 | 121 | </div> |
| 120 | 122 | </div> |
| 121 | - </div> | |
| 123 | + {% endif %} | |
| 122 | 124 | {% endfor %} |
| 123 | 125 | |
| 124 | 126 | {% pagination request paginator page_obj %} |
| ... | ... | @@ -126,6 +128,8 @@ |
| 126 | 128 | {% endif %} |
| 127 | 129 | </div> |
| 128 | 130 | |
| 131 | + <div id="modal_course"></div> | |
| 132 | + | |
| 129 | 133 | <div class="modal fade" id="post-modal-form" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"></div> |
| 130 | 134 | |
| 131 | 135 | <script type="text/javascript" src="{% static 'js/category.js' %}"></script> | ... | ... |
| ... | ... | @@ -0,0 +1,137 @@ |
| 1 | +{% extends 'base.html' %} | |
| 2 | + | |
| 3 | +{% load static i18n pagination permissions_tags mural_filters %} | |
| 4 | +{% load django_bootstrap_breadcrumbs %} | |
| 5 | + | |
| 6 | +{% block breadcrumbs %} | |
| 7 | + {{ block.super }} | |
| 8 | + | |
| 9 | + {% trans 'Mural: Per Subject' as subject %} | |
| 10 | + | |
| 11 | + {% breadcrumb subject 'mural:manage_category' %} | |
| 12 | +{% endblock %} | |
| 13 | + | |
| 14 | +{% block content %} | |
| 15 | + <input type="hidden" value="{% url 'mural:manage_subject' %}" class="mural_url" /> | |
| 16 | + | |
| 17 | + <div id="core-subjects-options-div"> | |
| 18 | + <ul class="core-subjects-options"> | |
| 19 | + <a href="{% url 'mural:manage_general' %}"><li>{% trans "General" %} ({{ totals.general }})</li></a> | |
| 20 | + <a href="{% url 'mural:manage_category' %}"><li>{% trans "Per Category" %} ({{ totals.category }})</li></a> | |
| 21 | + <a href="{% url 'mural:manage_subject' %}"><li class="active">{% trans "Per Subject" %} (<span class="sub_badge">{{ totals.subject }}</span>)</li></a> | |
| 22 | + </ul> | |
| 23 | + </div> | |
| 24 | + | |
| 25 | + <div class="col-md-12 cards-content"> | |
| 26 | + {% if subjects.count > 0 %} | |
| 27 | + <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> | |
| 28 | + {% for subject in subjects %} | |
| 29 | + {% subject_permissions request.user subject as has_subject_permissions %} | |
| 30 | + | |
| 31 | + {% if subject.visible or has_subject_permissions %} | |
| 32 | + {% if subject.visible %} | |
| 33 | + <div class="panel panel-info subject-panel"> | |
| 34 | + <div class="panel-heading"> | |
| 35 | + {% elif has_subject_permissions %} | |
| 36 | + <div class="panel panel-info subject-panel-invisible"> | |
| 37 | + <div class="panel-heading panel-invisible"> | |
| 38 | + {% endif %} | |
| 39 | + <div class="row"> | |
| 40 | + <div class="col-md-12 category-header"> | |
| 41 | + <h4 class="panel-title"> | |
| 42 | + <a class="category-course-link pull-left" data-parent="#accordion" data-toggle="collapse" href="#{{subject.slug}}"> | |
| 43 | + <button class="btn btn-default btn-xs text-center cat-selector"><i class="fa fa-angle-right fa-2x" aria-hidden="true"></i></button> <span>{{ subject }}</span> | |
| 44 | + | |
| 45 | + ({{ subject|sub_unviewed:request.user }}) | |
| 46 | + </a> | |
| 47 | + </h4> | |
| 48 | + | |
| 49 | + <div class="col-md-5 pull-right category-card-items"> | |
| 50 | + {% if has_subject_permissions %} | |
| 51 | + <a href="" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | |
| 52 | + <i class="fa fa-ellipsis-v" aria-hidden="true"></i> | |
| 53 | + </a> | |
| 54 | + <ul class="dropdown-menu pull-right" aria-labelledby="moreActions"> | |
| 55 | + {% if request.user not in subject.professor.all %} | |
| 56 | + <li><a href="{% url 'subjects:replicate' subject.slug %}"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i>{% trans 'Replicate' %}</a></li> | |
| 57 | + {% endif %} | |
| 58 | + <li><a href="{% url 'subjects:update' subject.slug %}"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i>{% trans 'Edit' %}</a></li> | |
| 59 | + <li><a href="{% url 'groups:index' subject.slug %}"><i class="fa fa-group fa-fw" aria-hidden="true"></i>{% trans 'Groups' %}</a></li> | |
| 60 | + <li><a href="javascript:delete_subject.get('{% url 'subjects:delete' subject.slug %}?view=index','#subject','#modal_subject')"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> {% trans 'Remove' %}</a></li> | |
| 61 | + </ul> | |
| 62 | + {% endif %} | |
| 63 | + </div> | |
| 64 | + </div> | |
| 65 | + </div> | |
| 66 | + </div> | |
| 67 | + <div id="{{subject.slug}}" class="panel-collapse panel-body collapse mural-subject"> | |
| 68 | + <div class="col-md-12 cards-content mural" data-url="{% url 'mural:load_category' subject.id %}"> | |
| 69 | + <div class="col-md-9 col-sm-9 col-xs-9 mural-list"> | |
| 70 | + <div class="post_make panel panel-default"> | |
| 71 | + <div class="panel-body"> | |
| 72 | + <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 user-img text-center"> | |
| 73 | + <img src="{{ request.user.image_url }}" class="img-responsive" /> | |
| 74 | + </div> | |
| 75 | + <div class="col-lg-11 col-md-11 col-sm-11 col-xs-11 post-field"> | |
| 76 | + <div> | |
| 77 | + <h4 data-url="{% url 'mural:create_category' subject.slug %}">{% trans 'Wish to make a new post?' %}</h4> | |
| 78 | + </div> | |
| 79 | + </div> | |
| 80 | + </div> | |
| 81 | + </div> | |
| 82 | + | |
| 83 | + <div class="posts"> | |
| 84 | + </div> | |
| 85 | + | |
| 86 | + <button type="button" class="btn btn-block btn-success btn-raised more-posts" style="display:none"> | |
| 87 | + {% trans 'See more posts' %} | |
| 88 | + </button> | |
| 89 | + | |
| 90 | + <div class="alert alert-success loading-posts" role="alert"> | |
| 91 | + <center> | |
| 92 | + <span class="fa fa-spin fa-circle-o-notch"></span> | |
| 93 | + </center> | |
| 94 | + </div> | |
| 95 | + | |
| 96 | + <div class="text-center no-subjects" style="display:none"> | |
| 97 | + <i class="fa fa-list"></i> | |
| 98 | + <h4>{% trans 'There are no posts in this mural yet.' %}</h4> | |
| 99 | + </div> | |
| 100 | + </div> | |
| 101 | + <div class="col-md-3 col-sm-3 col-xs-3 post-filter"> | |
| 102 | + <h4>{% trans 'Filter' %}</h4> | |
| 103 | + | |
| 104 | + <form class="post-filters" action="" method="GET"> | |
| 105 | + <div class="checkbox"> | |
| 106 | + <label> | |
| 107 | + <input name="favorite" type="checkbox"> {% trans 'Favorite posts' %} <i class="fa fa-thumb-tack"></i> | |
| 108 | + </label> | |
| 109 | + </div> | |
| 110 | + <div class="checkbox"> | |
| 111 | + <label> | |
| 112 | + <input name="mine" type="checkbox"> {% trans 'Only my posts' %} | |
| 113 | + </label> | |
| 114 | + </div> | |
| 115 | + <button type="submit" class="btn btn-success btn-raised btn-block">{% trans 'Filter' %}</button> | |
| 116 | + <button type="button" class="clear_filter btn btn-default btn-raised btn-block">{% trans 'Clean Filters' %}</button> | |
| 117 | + </form> | |
| 118 | + </div> | |
| 119 | + </div> | |
| 120 | + </div> | |
| 121 | + </div> | |
| 122 | + {% endif %} | |
| 123 | + {% endfor %} | |
| 124 | + | |
| 125 | + {% pagination request paginator page_obj %} | |
| 126 | + </div> | |
| 127 | + {% endif %} | |
| 128 | + </div> | |
| 129 | + | |
| 130 | + <div id="modal_subject"></div> | |
| 131 | + | |
| 132 | + <div class="modal fade" id="post-modal-form" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"></div> | |
| 133 | + | |
| 134 | + <script type="text/javascript" src="{% static 'js/category.js' %}"></script> | |
| 135 | + <script type="text/javascript" src="{% static 'js/mural.js' %}"></script> | |
| 136 | + <script type="text/javascript" src="{% static 'js/mural_subject.js' %}"></script> | |
| 137 | +{% endblock %} | |
| 0 | 138 | \ No newline at end of file | ... | ... |
mural/templatetags/mural_filters.py
| ... | ... | @@ -49,4 +49,38 @@ def fav_class(post, user): |
| 49 | 49 | def unviewed(category, user): |
| 50 | 50 | count = MuralVisualizations.objects.filter(Q(user = user) & Q(viewed = False) & (Q(post__categorypost__space = category) | Q(comment__post__categorypost__space = category))).count() |
| 51 | 51 | |
| 52 | - return count | |
| 53 | 52 | \ No newline at end of file |
| 53 | + return count | |
| 54 | + | |
| 55 | +@register.filter(name = 'sub_unviewed') | |
| 56 | +def sub_unviewed(subject, user): | |
| 57 | + count = MuralVisualizations.objects.filter(Q(user = user) & Q(viewed = False) & (Q(post__subjectpost__space = subject) | Q(comment__post__subjectpost__space = subject))).count() | |
| 58 | + | |
| 59 | + return count | |
| 60 | + | |
| 61 | +@register.filter(name = 'show_settings') | |
| 62 | +def show_settings(post, user): | |
| 63 | + if user.is_staff: | |
| 64 | + return True | |
| 65 | + | |
| 66 | + if post.user == user: | |
| 67 | + return True | |
| 68 | + | |
| 69 | + if post._my_subclass == "categorypost": | |
| 70 | + if post.space.coordinators == user: | |
| 71 | + return True | |
| 72 | + | |
| 73 | + return False | |
| 74 | + | |
| 75 | +@register.filter(name = 'show_settings_comment') | |
| 76 | +def show_settings_comment(comment, user): | |
| 77 | + if user.is_staff: | |
| 78 | + return True | |
| 79 | + | |
| 80 | + if comment.user == user: | |
| 81 | + return True | |
| 82 | + | |
| 83 | + if comment.post._my_subclass == "categorypost": | |
| 84 | + if comment.post.space.coordinators == user: | |
| 85 | + return True | |
| 86 | + | |
| 87 | + return False | ... | ... |
mural/urls.py
| ... | ... | @@ -4,6 +4,7 @@ from . import views |
| 4 | 4 | urlpatterns = [ |
| 5 | 5 | url(r'^$', views.GeneralIndex.as_view(), name='manage_general'), |
| 6 | 6 | url(r'^categories/$', views.CategoryIndex.as_view(), name='manage_category'), |
| 7 | + url(r'^subjects/$', views.SubjectIndex.as_view(), name='manage_subject'), | |
| 7 | 8 | url(r'^create_gen/$', views.GeneralCreate.as_view(), name='create_general'), |
| 8 | 9 | url(r'^create_cat/(?P<slug>[\w_-]+)/$', views.CategoryCreate.as_view(), name='create_category'), |
| 9 | 10 | url(r'^update_gen/(?P<pk>[\w_-]+)/$', views.GeneralUpdate.as_view(), name='update_general'), | ... | ... |
mural/views.py
| ... | ... | @@ -417,6 +417,45 @@ class CategoryDelete(LoginRequiredMixin, generic.DeleteView): |
| 417 | 417 | |
| 418 | 418 | return reverse_lazy('mural:deleted_post') |
| 419 | 419 | |
| 420 | +""" | |
| 421 | + Section for SubjectPost classes | |
| 422 | +""" | |
| 423 | +class SubjectIndex(LoginRequiredMixin, generic.ListView): | |
| 424 | + login_url = reverse_lazy("users:login") | |
| 425 | + redirect_field_name = 'next' | |
| 426 | + | |
| 427 | + template_name = 'mural/list_subject.html' | |
| 428 | + context_object_name = "subjects" | |
| 429 | + paginate_by = 10 | |
| 430 | + | |
| 431 | + totals = {} | |
| 432 | + | |
| 433 | + def get_queryset(self): | |
| 434 | + user = self.request.user | |
| 435 | + | |
| 436 | + if user.is_staff: | |
| 437 | + subjects = Subject.objects.all() | |
| 438 | + else: | |
| 439 | + subjects = Subject.objects.filter(Q(category__coordinators__pk = user.pk) | Q(professor__pk = user.pk) | Q(students__pk = user.pk, visible = True)).distinct() | |
| 440 | + | |
| 441 | + self.totals['general'] = MuralVisualizations.objects.filter(Q(user = user) & Q(viewed = False) & (Q(post__generalpost__isnull = False) | Q(comment__post__generalpost__isnull = False))).distinct().count() | |
| 442 | + self.totals['category'] = MuralVisualizations.objects.filter(Q(user = user) & Q(viewed = False) & (Q(user__is_staff = True) | Q(post__categorypost__space__coordinators = user) | Q(comment__post__categorypost__space__coordinators = user) | Q(post__categorypost__space__subject_category__students = user) | Q(comment__post__categorypost__space__subject_category__students = user) | Q(post__categorypost__space__subject_category__professor = user) | Q(comment__post__categorypost__space__subject_category__professor = user))).distinct().count() | |
| 443 | + self.totals['subject'] = MuralVisualizations.objects.filter(Q(user = user) & Q(viewed = False) & (Q(post__subjectpost__space__professor = user) | Q(comment__post__subjectpost__space__professor = user) | Q(post__subjectpost__space__students = user) | Q(comment__post__subjectpost__space__students = user))).distinct().count() | |
| 444 | + | |
| 445 | + return subjects | |
| 446 | + | |
| 447 | + def get_context_data(self, **kwargs): | |
| 448 | + context = super(SubjectIndex, self).get_context_data(**kwargs) | |
| 449 | + | |
| 450 | + context['title'] = _('Mural - Per Subject') | |
| 451 | + context['totals'] = self.totals | |
| 452 | + context['mural_menu_active'] = 'subjects_menu_active' | |
| 453 | + | |
| 454 | + return context | |
| 455 | + | |
| 456 | +""" | |
| 457 | + Section for common post functions | |
| 458 | +""" | |
| 420 | 459 | def render_post(request, post, msg, ptype): |
| 421 | 460 | if ptype == 'gen': |
| 422 | 461 | post = get_object_or_404(GeneralPost, id = post) | ... | ... |
subjects/templates/subjects/initial.html