Commit 9e4a8e34b8cb979fcd369be4ba459b066d90f1eb
1 parent
fe09c7da
Exists in
master
and in
3 other branches
Adding post height limit and button to see complete
Showing
4 changed files
with
46 additions
and
17 deletions
Show diff stats
amadeus/static/js/mural.js
@@ -37,6 +37,8 @@ var loadPosts = function() { | @@ -37,6 +37,8 @@ var loadPosts = function() { | ||
37 | $(".posts").append(data); | 37 | $(".posts").append(data); |
38 | 38 | ||
39 | $('.mural').data('page', pageNum); | 39 | $('.mural').data('page', pageNum); |
40 | + | ||
41 | + setTimeout(function () { postHeightLimits() }, 10); | ||
40 | }, | 42 | }, |
41 | complete: function(data, textStatus){ | 43 | complete: function(data, textStatus){ |
42 | // Turn the scroll monitor back on | 44 | // Turn the scroll monitor back on |
@@ -77,8 +79,34 @@ $(function () { | @@ -77,8 +79,34 @@ $(function () { | ||
77 | 79 | ||
78 | $(this).animate({scrollTop: height}, 0); | 80 | $(this).animate({scrollTop: height}, 0); |
79 | }); | 81 | }); |
82 | + | ||
83 | + postHeightLimits(); | ||
84 | + | ||
80 | }); | 85 | }); |
81 | 86 | ||
87 | +function postHeightLimits() { | ||
88 | + $('.post-body').each(function () { | ||
89 | + if ($(this).outerHeight() > 500) { | ||
90 | + var post = $(this), | ||
91 | + btn = post.parent().find('.see-complete'); | ||
92 | + | ||
93 | + post.attr('style', 'overflow:hidden;max-height:500px'); | ||
94 | + | ||
95 | + btn.attr('style', 'display:block'); | ||
96 | + | ||
97 | + btn.click(function () { | ||
98 | + seeComplete($(this), post); | ||
99 | + }); | ||
100 | + } | ||
101 | + }); | ||
102 | +} | ||
103 | + | ||
104 | +function seeComplete(btn, post) { | ||
105 | + post.attr('style', ''); | ||
106 | + | ||
107 | + btn.attr('style', 'display:none'); | ||
108 | +} | ||
109 | + | ||
82 | function setPostFormSubmit(post = "") { | 110 | function setPostFormSubmit(post = "") { |
83 | var frm = $('#post-form'); | 111 | var frm = $('#post-form'); |
84 | 112 | ||
@@ -100,12 +128,14 @@ function setPostFormSubmit(post = "") { | @@ -100,12 +128,14 @@ function setPostFormSubmit(post = "") { | ||
100 | old.remove(); | 128 | old.remove(); |
101 | } else { | 129 | } else { |
102 | $('.posts').prepend(data.view); | 130 | $('.posts').prepend(data.view); |
103 | - | 131 | + |
104 | new_posts.push(data.new_id); | 132 | new_posts.push(data.new_id); |
105 | 133 | ||
106 | $('.no-subjects').attr('style', 'display:none'); | 134 | $('.no-subjects').attr('style', 'display:none'); |
107 | } | 135 | } |
108 | 136 | ||
137 | + setTimeout(function () { postHeightLimits() }, 100); | ||
138 | + | ||
109 | $('#post-modal-form').modal('hide'); | 139 | $('#post-modal-form').modal('hide'); |
110 | 140 | ||
111 | alertify.success(data.message); | 141 | alertify.success(data.message); |
@@ -122,7 +152,7 @@ function setPostFormSubmit(post = "") { | @@ -122,7 +152,7 @@ function setPostFormSubmit(post = "") { | ||
122 | return false; | 152 | return false; |
123 | }); | 153 | }); |
124 | } | 154 | } |
125 | - | 155 | + |
126 | function favorite(btn) { | 156 | function favorite(btn) { |
127 | var action = btn.data('action'), | 157 | var action = btn.data('action'), |
128 | url = btn.data('url'); | 158 | url = btn.data('url'); |
log/mixins.py
@@ -11,16 +11,17 @@ class LogMixin(object): | @@ -11,16 +11,17 @@ class LogMixin(object): | ||
11 | log_resource = "" | 11 | log_resource = "" |
12 | 12 | ||
13 | def createLog(self, actor = None, component = '', log_action = '', log_resource = '', context = {}): | 13 | def createLog(self, actor = None, component = '', log_action = '', log_resource = '', context = {}): |
14 | - log = Log() | ||
15 | - log.user = str(actor) | ||
16 | - log.user_id = actor.id | ||
17 | - log.user_email = actor.email | ||
18 | - log.context = context | ||
19 | - log.component = component | ||
20 | - log.action = log_action | ||
21 | - log.resource = log_resource | 14 | + if actor.is_authenticated: |
15 | + log = Log() | ||
16 | + log.user = str(actor) | ||
17 | + log.user_id = actor.id | ||
18 | + log.user_email = actor.email | ||
19 | + log.context = context | ||
20 | + log.component = component | ||
21 | + log.action = log_action | ||
22 | + log.resource = log_resource | ||
22 | 23 | ||
23 | - log.save() | 24 | + log.save() |
24 | 25 | ||
25 | def dispatch(self, request, *args, **kwargs): | 26 | def dispatch(self, request, *args, **kwargs): |
26 | return super(LogMixin, self).dispatch(request, *args, **kwargs) | 27 | return super(LogMixin, self).dispatch(request, *args, **kwargs) |
27 | \ No newline at end of file | 28 | \ No newline at end of file |
mural/templates/mural/_view.html
@@ -43,6 +43,7 @@ | @@ -43,6 +43,7 @@ | ||
43 | <img src="{{ post.image.url }}" class="img-responsive center-block" /> | 43 | <img src="{{ post.image.url }}" class="img-responsive center-block" /> |
44 | {% endif %} | 44 | {% endif %} |
45 | </div> | 45 | </div> |
46 | + <button type="button" class="btn btn-block btn-default btn-sm see-complete" style="display:none">{% trans 'See complete post' %}</button> | ||
46 | <div class="col-md-12 comment-section"> | 47 | <div class="col-md-12 comment-section"> |
47 | <button type="button" class="btn btn-block btn-default btn-sm loading" style="display:none"><span class="fa fa-spin fa-circle-o-notch"></span></button> | 48 | <button type="button" class="btn btn-block btn-default btn-sm loading" style="display:none"><span class="fa fa-spin fa-circle-o-notch"></span></button> |
48 | <button type="button" onclick="loadComments($(this))" data-url="{% url 'mural:load_comments' post.mural_ptr_id post.id %}" data-post="{{ post.id }}" class="btn btn-block btn-default btn-sm load-btn">{% trans 'See more comments...' %}</button> | 49 | <button type="button" onclick="loadComments($(this))" data-url="{% url 'mural:load_comments' post.mural_ptr_id post.id %}" data-post="{{ post.id }}" class="btn btn-block btn-default btn-sm load-btn">{% trans 'See more comments...' %}</button> |
@@ -61,4 +62,4 @@ | @@ -61,4 +62,4 @@ | ||
61 | </div> | 62 | </div> |
62 | </div> | 63 | </div> |
63 | </div> | 64 | </div> |
64 | -</div> | ||
65 | \ No newline at end of file | 65 | \ No newline at end of file |
66 | +</div> |
subjects/views.py
@@ -550,11 +550,8 @@ class SubjectSearchView(LoginRequiredMixin, LogMixin, ListView): | @@ -550,11 +550,8 @@ class SubjectSearchView(LoginRequiredMixin, LogMixin, ListView): | ||
550 | 550 | ||
551 | if tags[0] == '': | 551 | if tags[0] == '': |
552 | return HttpResponseRedirect(request.META.get('HTTP_REFERER')) | 552 | return HttpResponseRedirect(request.META.get('HTTP_REFERER')) |
553 | - if request.method.lower() in self.http_method_names: | ||
554 | - handler = getattr(self, request.method.lower(), self.http_method_not_allowed) | ||
555 | - else: | ||
556 | - handler = self.http_method_not_allowed | ||
557 | - return handler(request, *args, **kwargs) | 553 | + |
554 | + return super(SubjectSearchView, self).dispatch(request, *args, **kwargs) | ||
558 | 555 | ||
559 | def get_queryset(self): | 556 | def get_queryset(self): |
560 | 557 |