Commit b87b184fa6ea18e5292517e2f6e4cd4ed5a1fb39
Exists in
master
and in
3 other branches
Merge branch 'refactoring' of https://github.com/amadeusproject/amadeuslms into refactoring
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 | 37 | $(".posts").append(data); |
38 | 38 | |
39 | 39 | $('.mural').data('page', pageNum); |
40 | + | |
41 | + setTimeout(function () { postHeightLimits() }, 10); | |
40 | 42 | }, |
41 | 43 | complete: function(data, textStatus){ |
42 | 44 | // Turn the scroll monitor back on |
... | ... | @@ -77,8 +79,34 @@ $(function () { |
77 | 79 | |
78 | 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 | 110 | function setPostFormSubmit(post = "") { |
83 | 111 | var frm = $('#post-form'); |
84 | 112 | |
... | ... | @@ -100,12 +128,14 @@ function setPostFormSubmit(post = "") { |
100 | 128 | old.remove(); |
101 | 129 | } else { |
102 | 130 | $('.posts').prepend(data.view); |
103 | - | |
131 | + | |
104 | 132 | new_posts.push(data.new_id); |
105 | 133 | |
106 | 134 | $('.no-subjects').attr('style', 'display:none'); |
107 | 135 | } |
108 | 136 | |
137 | + setTimeout(function () { postHeightLimits() }, 100); | |
138 | + | |
109 | 139 | $('#post-modal-form').modal('hide'); |
110 | 140 | |
111 | 141 | alertify.success(data.message); |
... | ... | @@ -122,7 +152,7 @@ function setPostFormSubmit(post = "") { |
122 | 152 | return false; |
123 | 153 | }); |
124 | 154 | } |
125 | - | |
155 | + | |
126 | 156 | function favorite(btn) { |
127 | 157 | var action = btn.data('action'), |
128 | 158 | url = btn.data('url'); | ... | ... |
log/mixins.py
... | ... | @@ -11,16 +11,17 @@ class LogMixin(object): |
11 | 11 | log_resource = "" |
12 | 12 | |
13 | 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 | 26 | def dispatch(self, request, *args, **kwargs): |
26 | 27 | return super(LogMixin, self).dispatch(request, *args, **kwargs) |
27 | 28 | \ No newline at end of file | ... | ... |
mural/templates/mural/_view.html
... | ... | @@ -43,6 +43,7 @@ |
43 | 43 | <img src="{{ post.image.url }}" class="img-responsive center-block" /> |
44 | 44 | {% endif %} |
45 | 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 | 47 | <div class="col-md-12 comment-section"> |
47 | 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 | 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 | 62 | </div> |
62 | 63 | </div> |
63 | 64 | </div> |
64 | -</div> | |
65 | 65 | \ No newline at end of file |
66 | +</div> | ... | ... |
subjects/views.py
... | ... | @@ -550,11 +550,8 @@ class SubjectSearchView(LoginRequiredMixin, LogMixin, ListView): |
550 | 550 | |
551 | 551 | if tags[0] == '': |
552 | 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 | 556 | def get_queryset(self): |
560 | 557 | ... | ... |