Commit 7fdb91790eca99487abc5d5e528f240275c9b14d
1 parent
83e20f1d
Exists in
master
and in
3 other branches
Adding mural filter
Showing
7 changed files
with
82 additions
and
8 deletions
Show diff stats
amadeus/settings.py
amadeus/static/css/base/amadeus.css
@@ -964,6 +964,10 @@ li.item .notify_badge { | @@ -964,6 +964,10 @@ li.item .notify_badge { | ||
964 | margin: 7px 0 0 0 !important; | 964 | margin: 7px 0 0 0 !important; |
965 | } | 965 | } |
966 | 966 | ||
967 | +.mural .mural-list { | ||
968 | + padding-left: 0; | ||
969 | +} | ||
970 | + | ||
967 | .mural .post_make { | 971 | .mural .post_make { |
968 | padding: 10px; | 972 | padding: 10px; |
969 | margin-bottom: 10px; | 973 | margin-bottom: 10px; |
@@ -1075,6 +1079,11 @@ li.item .notify_badge { | @@ -1075,6 +1079,11 @@ li.item .notify_badge { | ||
1075 | cursor: text; | 1079 | cursor: text; |
1076 | } | 1080 | } |
1077 | 1081 | ||
1082 | +.post-filter h4 { | ||
1083 | + font-weight: 700; | ||
1084 | + margin-bottom: 15px; | ||
1085 | +} | ||
1086 | + | ||
1078 | .btn:focus, .btn:active:focus, .btn.active:focus, .btn.focus, .btn:active.focus, .btn.active.focus { | 1087 | .btn:focus, .btn:active:focus, .btn.active:focus, .btn.focus, .btn:active.focus, .btn.active.focus { |
1079 | outline: none; | 1088 | outline: none; |
1080 | } | 1089 | } |
1081 | \ No newline at end of file | 1090 | \ No newline at end of file |
amadeus/static/css/themes/green.css
@@ -542,6 +542,22 @@ a.add-row { | @@ -542,6 +542,22 @@ a.add-row { | ||
542 | color: #BBBBBB !important; | 542 | color: #BBBBBB !important; |
543 | } | 543 | } |
544 | 544 | ||
545 | +.post-filter { | ||
546 | + background: #DDDDDD; | ||
547 | +} | ||
548 | + | ||
549 | +.post-filter h4 { | ||
550 | + color: #4caf50; | ||
551 | +} | ||
552 | + | ||
553 | +.post-filter label { | ||
554 | + color: #333333; | ||
555 | +} | ||
556 | + | ||
557 | +.post-filter i { | ||
558 | + color: #FF0000; | ||
559 | +} | ||
560 | + | ||
545 | .btn:not(.btn-raised):not(.btn-link):focus, .btn:not(.btn-raised):not(.btn-link):hover, .input-group-btn .btn:not(.btn-raised):not(.btn-link):focus, .input-group-btn .btn:not(.btn-raised):not(.btn-link):hover { | 561 | .btn:not(.btn-raised):not(.btn-link):focus, .btn:not(.btn-raised):not(.btn-link):hover, .input-group-btn .btn:not(.btn-raised):not(.btn-link):focus, .input-group-btn .btn:not(.btn-raised):not(.btn-link):hover { |
546 | background-color: initial; | 562 | background-color: initial; |
547 | } | 563 | } |
mural/templates/mural/_view.html
1 | {% load i18n mural_filters %} | 1 | {% load i18n mural_filters %} |
2 | 2 | ||
3 | -<div id="post-{{ post.id }}" class="row panel panel-default"> | 3 | +<div id="post-{{ post.id }}" class="panel panel-default"> |
4 | <div class="panel-body post"> | 4 | <div class="panel-body post"> |
5 | <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 post-img"> | 5 | <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 post-img"> |
6 | <img src="{{ post.user.image_url }}" class="img-responsive" /> | 6 | <img src="{{ post.user.image_url }}" class="img-responsive" /> |
mural/templates/mural/list.html
@@ -21,8 +21,8 @@ | @@ -21,8 +21,8 @@ | ||
21 | </div> | 21 | </div> |
22 | 22 | ||
23 | <div class="col-md-12 cards-content mural"> | 23 | <div class="col-md-12 cards-content mural"> |
24 | - <div class="col-md-9 col-sm-9 col-xs-9"> | ||
25 | - <div class="row post_make panel panel-default"> | 24 | + <div class="col-md-9 col-sm-9 col-xs-9 mural-list"> |
25 | + <div class="post_make panel panel-default"> | ||
26 | <div class="panel-body"> | 26 | <div class="panel-body"> |
27 | <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 user-img text-center"> | 27 | <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 user-img text-center"> |
28 | <img src="{{ request.user.image_url }}" class="img-responsive" /> | 28 | <img src="{{ request.user.image_url }}" class="img-responsive" /> |
@@ -45,7 +45,23 @@ | @@ -45,7 +45,23 @@ | ||
45 | <h4>{% trans 'There are no posts in this mural yet.' %}</h4> | 45 | <h4>{% trans 'There are no posts in this mural yet.' %}</h4> |
46 | </div> | 46 | </div> |
47 | </div> | 47 | </div> |
48 | - <div class="col-md-3 col-sm-3 col-xs-3"> | 48 | + <div class="col-md-3 col-sm-3 col-xs-3 post-filter"> |
49 | + <h4>{% trans 'Filter' %}</h4> | ||
50 | + | ||
51 | + <form id="post-filters" action="" method="GET"> | ||
52 | + <div class="checkbox"> | ||
53 | + <label> | ||
54 | + <input name="favorite" type="checkbox" {{ favorites }}> {% trans 'Favorite posts' %} <i class="fa fa-thumb-tack"></i> | ||
55 | + </label> | ||
56 | + </div> | ||
57 | + <div class="checkbox"> | ||
58 | + <label> | ||
59 | + <input name="mine" type="checkbox" {{ mines }}> {% trans 'Only my posts' %} | ||
60 | + </label> | ||
61 | + </div> | ||
62 | + <button type="submit" class="btn btn-success btn-raised btn-block">{% trans 'Filter' %}</button> | ||
63 | + <button type="button" id="clear_filter" class="btn btn-default btn-raised btn-block">{% trans 'Clean Filters' %}</button> | ||
64 | + </form> | ||
49 | </div> | 65 | </div> |
50 | </div> | 66 | </div> |
51 | 67 | ||
@@ -67,6 +83,14 @@ | @@ -67,6 +83,14 @@ | ||
67 | } | 83 | } |
68 | }); | 84 | }); |
69 | }); | 85 | }); |
86 | + | ||
87 | + $("#clear_filter").click(function () { | ||
88 | + var frm = $(this).parent(); | ||
89 | + | ||
90 | + frm.find("input[type='checkbox']").prop('checked', false); | ||
91 | + | ||
92 | + frm.submit(); | ||
93 | + }); | ||
70 | }); | 94 | }); |
71 | 95 | ||
72 | function setPostFormSubmit(post = "") { | 96 | function setPostFormSubmit(post = "") { |
mural/templatetags/mural_filters.py
@@ -14,6 +14,8 @@ def is_edited(post): | @@ -14,6 +14,8 @@ def is_edited(post): | ||
14 | 14 | ||
15 | @register.filter(name = 'action_icon') | 15 | @register.filter(name = 'action_icon') |
16 | def action_icon(action): | 16 | def action_icon(action): |
17 | + icon = "" | ||
18 | + | ||
17 | if action == "comment": | 19 | if action == "comment": |
18 | icon = "fa-commenting-o" | 20 | icon = "fa-commenting-o" |
19 | elif action == "help": | 21 | elif action == "help": |
mural/views.py
@@ -22,7 +22,6 @@ class GeneralIndex(LoginRequiredMixin, generic.ListView): | @@ -22,7 +22,6 @@ class GeneralIndex(LoginRequiredMixin, generic.ListView): | ||
22 | redirect_field_name = 'next' | 22 | redirect_field_name = 'next' |
23 | 23 | ||
24 | template_name = 'mural/list.html' | 24 | template_name = 'mural/list.html' |
25 | - model = GeneralPost | ||
26 | context_object_name = "posts" | 25 | context_object_name = "posts" |
27 | paginate_by = 10 | 26 | paginate_by = 10 |
28 | 27 | ||
@@ -30,9 +29,20 @@ class GeneralIndex(LoginRequiredMixin, generic.ListView): | @@ -30,9 +29,20 @@ class GeneralIndex(LoginRequiredMixin, generic.ListView): | ||
30 | 29 | ||
31 | def get_queryset(self): | 30 | def get_queryset(self): |
32 | user = self.request.user | 31 | user = self.request.user |
32 | + favorites = self.request.GET.get('favorite', False) | ||
33 | + mines = self.request.GET.get('mine', False) | ||
34 | + | ||
35 | + if not favorites: | ||
36 | + if mines: | ||
37 | + general = GeneralPost.objects.extra(select = {"most_recent": "greatest(last_update, (select max(mural_comment.last_update) from mural_comment where mural_comment.post_id = mural_generalpost.mural_ptr_id))"}).filter(mural_ptr__user = user) | ||
38 | + else: | ||
39 | + general = GeneralPost.objects.extra(select = {"most_recent": "greatest(last_update, (select max(mural_comment.last_update) from mural_comment where mural_comment.post_id = mural_generalpost.mural_ptr_id))"}) | ||
40 | + else: | ||
41 | + if mines: | ||
42 | + general = GeneralPost.objects.extra(select = {"most_recent": "greatest(last_update, (select max(mural_comment.last_update) from mural_comment where mural_comment.post_id = mural_generalpost.mural_ptr_id))"}).filter(favorites_post__isnull = False, mural_ptr__user = user) | ||
43 | + else: | ||
44 | + general = GeneralPost.objects.extra(select = {"most_recent": "greatest(last_update, (select max(mural_comment.last_update) from mural_comment where mural_comment.post_id = mural_generalpost.mural_ptr_id))"}).filter(favorites_post__isnull = False) | ||
33 | 45 | ||
34 | - general = GeneralPost.objects.extra(select={"most_recent": "greatest(last_update, (select max(mural_comment.last_update) from mural_comment where mural_comment.post_id = mural_generalpost.mural_ptr_id))"}).order_by("-most_recent") | ||
35 | - | ||
36 | general_visualizations = MuralVisualizations.objects.filter(Q(user = user) & Q(viewed = False) & (Q(post__generalpost__isnull = False) | Q(comment__post__generalpost__isnull = False))).distinct() | 46 | general_visualizations = MuralVisualizations.objects.filter(Q(user = user) & Q(viewed = False) & (Q(post__generalpost__isnull = False) | Q(comment__post__generalpost__isnull = False))).distinct() |
37 | 47 | ||
38 | self.totals['general'] = general_visualizations.count() | 48 | self.totals['general'] = general_visualizations.count() |
@@ -41,7 +51,7 @@ class GeneralIndex(LoginRequiredMixin, generic.ListView): | @@ -41,7 +51,7 @@ class GeneralIndex(LoginRequiredMixin, generic.ListView): | ||
41 | 51 | ||
42 | general_visualizations.update(viewed = True) | 52 | general_visualizations.update(viewed = True) |
43 | 53 | ||
44 | - return general | 54 | + return general.order_by("-most_recent") |
45 | 55 | ||
46 | def get_context_data(self, **kwargs): | 56 | def get_context_data(self, **kwargs): |
47 | context = super(GeneralIndex, self).get_context_data(**kwargs) | 57 | context = super(GeneralIndex, self).get_context_data(**kwargs) |
@@ -49,6 +59,18 @@ class GeneralIndex(LoginRequiredMixin, generic.ListView): | @@ -49,6 +59,18 @@ class GeneralIndex(LoginRequiredMixin, generic.ListView): | ||
49 | context['title'] = _('Mural') | 59 | context['title'] = _('Mural') |
50 | context['totals'] = self.totals | 60 | context['totals'] = self.totals |
51 | context['mural_menu_active'] = 'subjects_menu_active' | 61 | context['mural_menu_active'] = 'subjects_menu_active' |
62 | + context['favorites'] = "" | ||
63 | + context['mines'] = "" | ||
64 | + | ||
65 | + favs = self.request.GET.get('favorite', False) | ||
66 | + | ||
67 | + if favs: | ||
68 | + context['favorites'] = "checked" | ||
69 | + | ||
70 | + mines = self.request.GET.get('mine', False) | ||
71 | + | ||
72 | + if mines: | ||
73 | + context['mines'] = "checked" | ||
52 | 74 | ||
53 | return context | 75 | return context |
54 | 76 |