Commit 0e9f592225b8eeddd36d54030d53528d5df26a34
Exists in
master
and in
3 other branches
Merge branch 'refactoring' of https://github.com/amadeusproject/amadeuslms into refactoring
Showing
11 changed files
with
311 additions
and
74 deletions
Show diff stats
amadeus/static/css/base/amadeus.css
@@ -1349,9 +1349,9 @@ div.dataTables_wrapper div.dataTables_paginate { | @@ -1349,9 +1349,9 @@ div.dataTables_wrapper div.dataTables_paginate { | ||
1349 | border-width: 1px; | 1349 | border-width: 1px; |
1350 | border-style: solid; | 1350 | border-style: solid; |
1351 | border-radius: 10px; | 1351 | border-radius: 10px; |
1352 | - margin-right: 10px; | 1352 | + margin-right: 5px; |
1353 | position: relative; | 1353 | position: relative; |
1354 | - top: 3px; | 1354 | + top: -1px; |
1355 | display: inline-block; | 1355 | display: inline-block; |
1356 | border-spacing: 0; | 1356 | border-spacing: 0; |
1357 | border-collapse: collapse; | 1357 | border-collapse: collapse; |
amadeus/static/js/chat.js
1 | +var new_msgs = {}; | ||
2 | + | ||
1 | function getModalInfo(btn, space, space_type) { | 3 | function getModalInfo(btn, space, space_type) { |
2 | var url = btn.data('url'); | 4 | var url = btn.data('url'); |
3 | 5 | ||
@@ -6,13 +8,15 @@ function getModalInfo(btn, space, space_type) { | @@ -6,13 +8,15 @@ function getModalInfo(btn, space, space_type) { | ||
6 | url: url, | 8 | url: url, |
7 | data: {'space': space, 'space_type': space_type}, | 9 | data: {'space': space, 'space_type': space_type}, |
8 | success: function (response) { | 10 | success: function (response) { |
11 | + var modal_shown = $("#chat-modal-info").is(":visible"); | ||
12 | + | ||
9 | $("#chat-modal-info").html(response); | 13 | $("#chat-modal-info").html(response); |
10 | 14 | ||
11 | $("#chat-modal-info").modal('show'); | 15 | $("#chat-modal-info").modal('show'); |
12 | 16 | ||
13 | $.material.init(); | 17 | $.material.init(); |
14 | 18 | ||
15 | - $('#chat-modal-info').on('shown.bs.modal', function () { | 19 | + if (modal_shown) { |
16 | $(".messages-container").each(function () { | 20 | $(".messages-container").each(function () { |
17 | var height = $(this)[0].scrollHeight; | 21 | var height = $(this)[0].scrollHeight; |
18 | 22 | ||
@@ -20,7 +24,19 @@ function getModalInfo(btn, space, space_type) { | @@ -20,7 +24,19 @@ function getModalInfo(btn, space, space_type) { | ||
20 | }); | 24 | }); |
21 | 25 | ||
22 | setShortChatFormSubmit(); | 26 | setShortChatFormSubmit(); |
23 | - }); | 27 | + setFiltersSubmitAndPagination(); |
28 | + } else { | ||
29 | + $('#chat-modal-info').on('shown.bs.modal', function () { | ||
30 | + $(".messages-container").each(function () { | ||
31 | + var height = $(this)[0].scrollHeight; | ||
32 | + | ||
33 | + $(this).animate({scrollTop: height}, 0); | ||
34 | + }); | ||
35 | + | ||
36 | + setShortChatFormSubmit(); | ||
37 | + setFiltersSubmitAndPagination(); | ||
38 | + }); | ||
39 | + } | ||
24 | 40 | ||
25 | $("#msg_editable").on('click', function () { | 41 | $("#msg_editable").on('click', function () { |
26 | $(this).trigger('focusin'); | 42 | $(this).trigger('focusin'); |
@@ -93,9 +109,13 @@ function setChatFormSubmit() { | @@ -93,9 +109,13 @@ function setChatFormSubmit() { | ||
93 | $(this).animate({scrollTop: height}, 0); | 109 | $(this).animate({scrollTop: height}, 0); |
94 | }); | 110 | }); |
95 | 111 | ||
96 | - $('#chat-modal-form').modal('hide'); | 112 | + if (typeof(new_msgs[data.talk_id]) == 'undefined') { |
113 | + new_msgs[data.talk_id] = []; | ||
114 | + } | ||
115 | + | ||
116 | + new_msgs[data.talk_id].push(data.new_id); | ||
97 | 117 | ||
98 | - alertify.success(data.message); | 118 | + $('#chat-modal-form').modal('hide'); |
99 | }, | 119 | }, |
100 | error: function(data) { | 120 | error: function(data) { |
101 | $("#chat-modal-form").html(data.responseText); | 121 | $("#chat-modal-form").html(data.responseText); |
@@ -137,13 +157,16 @@ function setShortChatFormSubmit() { | @@ -137,13 +157,16 @@ function setShortChatFormSubmit() { | ||
137 | $(this).animate({scrollTop: height}, 0); | 157 | $(this).animate({scrollTop: height}, 0); |
138 | }); | 158 | }); |
139 | 159 | ||
160 | + if (typeof(new_msgs[data.talk_id]) == 'undefined') { | ||
161 | + new_msgs[data.talk_id] = []; | ||
162 | + } | ||
163 | + | ||
164 | + new_msgs[data.talk_id].push(data.new_id); | ||
165 | + | ||
140 | editable.html(""); | 166 | editable.html(""); |
141 | editable.trigger("focusout"); | 167 | editable.trigger("focusout"); |
142 | - | ||
143 | - alertify.success(data.message); | ||
144 | }, | 168 | }, |
145 | error: function(data) { | 169 | error: function(data) { |
146 | - alertify.error(data.responseText); | ||
147 | setShortChatFormSubmit(); | 170 | setShortChatFormSubmit(); |
148 | }, | 171 | }, |
149 | cache: false, | 172 | cache: false, |
@@ -154,4 +177,133 @@ function setShortChatFormSubmit() { | @@ -154,4 +177,133 @@ function setShortChatFormSubmit() { | ||
154 | 177 | ||
155 | return false; | 178 | return false; |
156 | }); | 179 | }); |
180 | +} | ||
181 | + | ||
182 | +function favorite(btn) { | ||
183 | + var action = btn.data('action'), | ||
184 | + url = btn.data('url'); | ||
185 | + | ||
186 | + $.ajax({ | ||
187 | + url: url, | ||
188 | + data: {'action': action}, | ||
189 | + dataType: 'json', | ||
190 | + success: function (response) { | ||
191 | + if (action == 'favorite') { | ||
192 | + btn.switchClass("btn_fav", "btn_unfav", 250, "easeInOutQuad"); | ||
193 | + btn.data('action', 'unfavorite'); | ||
194 | + } else { | ||
195 | + btn.switchClass("btn_unfav", "btn_fav", 250, "easeInOutQuad"); | ||
196 | + btn.data('action', 'favorite'); | ||
197 | + } | ||
198 | + | ||
199 | + btn.attr('data-original-title', response.label); | ||
200 | + } | ||
201 | + }); | ||
202 | +} | ||
203 | + | ||
204 | +function setFiltersSubmitAndPagination() { | ||
205 | + var filters = $('#chat-filters'), | ||
206 | + clear_filters = $('#clear_filter'), | ||
207 | + messages = $('.messages-container'), | ||
208 | + loading = messages.find('.loading-msgs'), | ||
209 | + more = messages.find('.more-msgs'), | ||
210 | + msg_section = $('.messages-list'); | ||
211 | + | ||
212 | + filters.submit(function () { | ||
213 | + var favorite = $(this).find("input[name='favorite']").is(':checked') ? "True" : "", | ||
214 | + mine = $(this).find("input[name='mine']").is(':checked') ? "True" : "", | ||
215 | + url = messages.data('url'); | ||
216 | + | ||
217 | + msg_section.html(''); | ||
218 | + | ||
219 | + more.hide(); | ||
220 | + loading.show(); | ||
221 | + | ||
222 | + $.ajax({ | ||
223 | + url: url, | ||
224 | + data: {'favorite': favorite, 'mine': mine}, | ||
225 | + dataType: 'json', | ||
226 | + success: function (data) { | ||
227 | + loading.hide(); | ||
228 | + | ||
229 | + if (data.count > 0) { | ||
230 | + msg_section.append(data.messages); | ||
231 | + | ||
232 | + messages.data('pages', data.num_pages); | ||
233 | + messages.data('page', data.num_page); | ||
234 | + | ||
235 | + if (data.num_page < data.num_pages) { | ||
236 | + more.show(); | ||
237 | + } else { | ||
238 | + more.hide(); | ||
239 | + } | ||
240 | + } | ||
241 | + | ||
242 | + messages.data('fav', favorite); | ||
243 | + messages.data('mine', mine); | ||
244 | + | ||
245 | + messages.each(function () { | ||
246 | + var height = $(this)[0].scrollHeight; | ||
247 | + | ||
248 | + $(this).animate({scrollTop: height}, 0); | ||
249 | + }); | ||
250 | + } | ||
251 | + }); | ||
252 | + | ||
253 | + return false; | ||
254 | + }); | ||
255 | + | ||
256 | + clear_filters.click(function () { | ||
257 | + var frm = $(this).parent(); | ||
258 | + | ||
259 | + $("input[type='checkbox']").prop('checked', false); | ||
260 | + | ||
261 | + frm.submit(); | ||
262 | + }); | ||
263 | + | ||
264 | + more.click(function () { | ||
265 | + var url = messages.data('url'), | ||
266 | + pageNum = messages.data('page'), | ||
267 | + numberPages = messages.data('pages'), | ||
268 | + favorites = messages.data('fav'), | ||
269 | + mine = messages.data('mine'), | ||
270 | + talk = messages.data('talk'); | ||
271 | + | ||
272 | + var showing; | ||
273 | + | ||
274 | + if (typeof(new_msgs[talk]) == 'undefined') { | ||
275 | + showing = ""; | ||
276 | + } else { | ||
277 | + showing = new_msgs[talk].join(','); | ||
278 | + } | ||
279 | + | ||
280 | + if (pageNum == numberPages) { | ||
281 | + return false | ||
282 | + } | ||
283 | + | ||
284 | + pageNum = pageNum + 1; | ||
285 | + | ||
286 | + more.hide(); | ||
287 | + loading.show(); | ||
288 | + | ||
289 | + $.ajax({ | ||
290 | + url: url, | ||
291 | + data: {'page': pageNum, 'favorite': favorites, 'mine': mine, 'showing': showing}, | ||
292 | + dataType: 'json', | ||
293 | + success: function (data) { | ||
294 | + loading.hide(); | ||
295 | + | ||
296 | + msg_section.prepend(data.messages); | ||
297 | + | ||
298 | + messages.data('pages', data.num_pages); | ||
299 | + messages.data('page', data.num_page); | ||
300 | + | ||
301 | + if (data.num_page < data.num_pages) { | ||
302 | + more.show(); | ||
303 | + } else { | ||
304 | + more.hide(); | ||
305 | + } | ||
306 | + } | ||
307 | + }); | ||
308 | + }); | ||
157 | } | 309 | } |
158 | \ No newline at end of file | 310 | \ No newline at end of file |
categories/locale/pt_BR/LC_MESSAGES/django.po
@@ -96,11 +96,11 @@ msgstr "Inscrever-se" | @@ -96,11 +96,11 @@ msgstr "Inscrever-se" | ||
96 | 96 | ||
97 | #: .\templates\categories\delete.html:12 | 97 | #: .\templates\categories\delete.html:12 |
98 | msgid "Are you sure you want to delete the category" | 98 | msgid "Are you sure you want to delete the category" |
99 | -msgstr "Voce tem certeza que seja deletar esta categoria" | 99 | +msgstr "Você tem certeza que deseja deletar a categoria" |
100 | 100 | ||
101 | #: .\templates\categories\delete.html:12 | 101 | #: .\templates\categories\delete.html:12 |
102 | msgid "All its data will be lost and can't be recovered" | 102 | msgid "All its data will be lost and can't be recovered" |
103 | -msgstr "Todos os seus dados seråo perdido e não podem ser recuperados" | 103 | +msgstr "Todos os seus dados serão perdidos e não poderão ser recuperados" |
104 | 104 | ||
105 | #: .\templates\categories\delete.html:18 | 105 | #: .\templates\categories\delete.html:18 |
106 | msgid "Close" | 106 | msgid "Close" |
chat/templates/chat/_message.html
1 | +{% load chat_tags %} | ||
2 | + | ||
1 | <div class="col-md-12 message-view"> | 3 | <div class="col-md-12 message-view"> |
2 | <h4 class="message-user"> | 4 | <h4 class="message-user"> |
3 | {{ talk_msg.user }} | 5 | {{ talk_msg.user }} |
@@ -5,7 +7,7 @@ | @@ -5,7 +7,7 @@ | ||
5 | ({{ talk_msg.create_date }}) | 7 | ({{ talk_msg.create_date }}) |
6 | </span> | 8 | </span> |
7 | <span class="btn-group pull-right"> | 9 | <span class="btn-group pull-right"> |
8 | - <button class="btn btn-sm btn_menu btn_fav" onclick="favorite($(this))" data-url="" data-action="" data-toggle="tooltip" data-placement="top" title=""> | 10 | + <button class="btn btn-sm btn_menu {{ talk_msg|fav_class:request.user }}" onclick="favorite($(this))" data-url="{% url 'chat:favorite' talk_msg.id %}" data-action="{{ talk_msg|fav_action:request.user }}" data-toggle="tooltip" data-placement="top" title="{{ talk_msg|fav_label:request.user }}"> |
9 | <i class="fa fa-thumb-tack"></i> | 11 | <i class="fa fa-thumb-tack"></i> |
10 | </button> | 12 | </button> |
11 | </span> | 13 | </span> |
chat/templates/chat/talk.html
@@ -22,7 +22,7 @@ | @@ -22,7 +22,7 @@ | ||
22 | <div class="talk-filter"> | 22 | <div class="talk-filter"> |
23 | <h4>{% trans 'Filter' %}</h4> | 23 | <h4>{% trans 'Filter' %}</h4> |
24 | 24 | ||
25 | - <form id="post-filters" class="form-inline" action="" method="GET"> | 25 | + <form id="chat-filters" class="form-inline" action="" method="GET"> |
26 | <div class="checkbox"> | 26 | <div class="checkbox"> |
27 | <label> | 27 | <label> |
28 | <input name="favorite" type="checkbox"> {% trans 'Favorite messages' %} <i class="fa fa-thumb-tack"></i> | 28 | <input name="favorite" type="checkbox"> {% trans 'Favorite messages' %} <i class="fa fa-thumb-tack"></i> |
@@ -39,7 +39,16 @@ | @@ -39,7 +39,16 @@ | ||
39 | </div> | 39 | </div> |
40 | </div> | 40 | </div> |
41 | <div class="row-fluid"> | 41 | <div class="row-fluid"> |
42 | - <div class="messages-container"> | 42 | + <div class="messages-container" data-talk="{{ talk_id }}" data-url="{% url 'chat:load_messages' talk_id %}" data-page="{{ page_obj.number }}" data-pages="{{ paginator.num_pages }}"> |
43 | + <button type="button" class="btn btn-block btn-success btn-raised more-msgs" style="{% if paginator.num_pages == page_obj.number %}display:none;{% endif %}margin:0px"> | ||
44 | + {% trans 'See old messages' %} | ||
45 | + </button> | ||
46 | + | ||
47 | + <div class="alert alert-success loading-msgs" role="alert" style="display:none"> | ||
48 | + <center> | ||
49 | + <span class="fa fa-spin fa-circle-o-notch"></span> | ||
50 | + </center> | ||
51 | + </div> | ||
43 | <div class="messages_new"> | 52 | <div class="messages_new"> |
44 | {% trans 'You have new messages...' %} | 53 | {% trans 'You have new messages...' %} |
45 | </div> | 54 | </div> |
chat/templatetags/chat_tags.py
@@ -7,7 +7,7 @@ from django.contrib.sessions.models import Session | @@ -7,7 +7,7 @@ from django.contrib.sessions.models import Session | ||
7 | 7 | ||
8 | from log.models import Log | 8 | from log.models import Log |
9 | 9 | ||
10 | -from chat.models import TalkMessages, ChatVisualizations | 10 | +from chat.models import TalkMessages, ChatVisualizations, ChatFavorites |
11 | 11 | ||
12 | register = template.Library() | 12 | register = template.Library() |
13 | 13 | ||
@@ -55,4 +55,25 @@ def last_message(chat): | @@ -55,4 +55,25 @@ def last_message(chat): | ||
55 | def notifies(chat, user): | 55 | def notifies(chat, user): |
56 | total = ChatVisualizations.objects.filter(message__talk = chat, user = user).count() | 56 | total = ChatVisualizations.objects.filter(message__talk = chat, user = user).count() |
57 | 57 | ||
58 | - return total | ||
59 | \ No newline at end of file | 58 | \ No newline at end of file |
59 | + return total | ||
60 | + | ||
61 | +@register.filter(name = 'fav_label') | ||
62 | +def fav_label(message, user): | ||
63 | + if ChatFavorites.objects.filter(message = message, user = user).exists(): | ||
64 | + return _('Unfavorite') | ||
65 | + | ||
66 | + return _('Favorite') | ||
67 | + | ||
68 | +@register.filter(name = 'fav_action') | ||
69 | +def fav_action(message, user): | ||
70 | + if ChatFavorites.objects.filter(message = message, user = user).exists(): | ||
71 | + return "unfavorite" | ||
72 | + | ||
73 | + return "favorite" | ||
74 | + | ||
75 | +@register.filter(name = 'fav_class') | ||
76 | +def fav_class(message, user): | ||
77 | + if ChatFavorites.objects.filter(message = message, user = user).exists(): | ||
78 | + return "btn_unfav" | ||
79 | + | ||
80 | + return "btn_fav" | ||
60 | \ No newline at end of file | 81 | \ No newline at end of file |
chat/urls.py
@@ -5,6 +5,8 @@ urlpatterns = [ | @@ -5,6 +5,8 @@ urlpatterns = [ | ||
5 | url(r'^$', views.GeneralIndex.as_view(), name='manage_general'), | 5 | url(r'^$', views.GeneralIndex.as_view(), name='manage_general'), |
6 | url(r'^participants/$', views.GeneralParticipants.as_view(), name='participants_general'), | 6 | url(r'^participants/$', views.GeneralParticipants.as_view(), name='participants_general'), |
7 | url(r'^render_message/([\w_-]+)/$', views.render_message, name='render_message'), | 7 | url(r'^render_message/([\w_-]+)/$', views.render_message, name='render_message'), |
8 | + url(r'^favorite/([\w_-]+)/$', views.favorite, name='favorite'), | ||
9 | + url(r'^load_messages/([\w_-]+)/$', views.load_messages, name='load_messages'), | ||
8 | url(r'^talk/(?P<email>[\w.%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4})/$', views.GetTalk.as_view(), name = 'talk'), | 10 | url(r'^talk/(?P<email>[\w.%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4})/$', views.GetTalk.as_view(), name = 'talk'), |
9 | url(r'^send_message/(?P<email>[\w.%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4})/(?P<talk_id>[\w_-]+)/(?P<space>[\w_-]+)/(?P<space_type>[\w_-]+)/$', views.SendMessage.as_view(), name = 'create'), | 11 | url(r'^send_message/(?P<email>[\w.%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4})/(?P<talk_id>[\w_-]+)/(?P<space>[\w_-]+)/(?P<space_type>[\w_-]+)/$', views.SendMessage.as_view(), name = 'create'), |
10 | url(r'^participant/profile/(?P<email>[\w.%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4})/$', views.ParticipantProfile.as_view(), name = 'profile'), | 12 | url(r'^participant/profile/(?P<email>[\w.%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4})/$', views.ParticipantProfile.as_view(), name = 'profile'), |
chat/views.py
@@ -7,10 +7,12 @@ from django.http import JsonResponse | @@ -7,10 +7,12 @@ from django.http import JsonResponse | ||
7 | from django.template.loader import render_to_string | 7 | from django.template.loader import render_to_string |
8 | from django.core.urlresolvers import reverse, reverse_lazy | 8 | from django.core.urlresolvers import reverse, reverse_lazy |
9 | import textwrap | 9 | import textwrap |
10 | +from datetime import datetime | ||
10 | from django.utils import formats | 11 | from django.utils import formats |
11 | from django.utils.html import strip_tags | 12 | from django.utils.html import strip_tags |
12 | from django.utils.translation import ugettext_lazy as _ | 13 | from django.utils.translation import ugettext_lazy as _ |
13 | from django.contrib.auth.mixins import LoginRequiredMixin | 14 | from django.contrib.auth.mixins import LoginRequiredMixin |
15 | +from django.contrib.auth.decorators import login_required | ||
14 | from django.db.models import Q | 16 | from django.db.models import Q |
15 | 17 | ||
16 | from channels import Group | 18 | from channels import Group |
@@ -20,7 +22,7 @@ from categories.models import Category | @@ -20,7 +22,7 @@ from categories.models import Category | ||
20 | from subjects.models import Subject | 22 | from subjects.models import Subject |
21 | from users.models import User | 23 | from users.models import User |
22 | 24 | ||
23 | -from .models import Conversation, GeneralTalk, CategoryTalk, SubjectTalk, TalkMessages, ChatVisualizations | 25 | +from .models import Conversation, GeneralTalk, CategoryTalk, SubjectTalk, TalkMessages, ChatVisualizations, ChatFavorites |
24 | from .forms import ChatMessageForm | 26 | from .forms import ChatMessageForm |
25 | 27 | ||
26 | class GeneralIndex(LoginRequiredMixin, generic.ListView): | 28 | class GeneralIndex(LoginRequiredMixin, generic.ListView): |
@@ -81,7 +83,7 @@ class GeneralParticipants(LoginRequiredMixin, generic.ListView): | @@ -81,7 +83,7 @@ class GeneralParticipants(LoginRequiredMixin, generic.ListView): | ||
81 | 83 | ||
82 | context['title'] = _('Messages - Participants') | 84 | context['title'] = _('Messages - Participants') |
83 | context['totals'] = self.totals | 85 | context['totals'] = self.totals |
84 | - context['search'] = self.request.GET.get('search') | 86 | + context['search'] = self.request.GET.get('search', '') |
85 | context['chat_menu_active'] = 'subjects_menu_active' | 87 | context['chat_menu_active'] = 'subjects_menu_active' |
86 | 88 | ||
87 | return context | 89 | return context |
@@ -222,8 +224,71 @@ def render_message(request, talk_msg): | @@ -222,8 +224,71 @@ def render_message(request, talk_msg): | ||
222 | context = {} | 224 | context = {} |
223 | context['talk_msg'] = msg | 225 | context['talk_msg'] = msg |
224 | 226 | ||
225 | - message = _('Message sent successfully!') | ||
226 | - | ||
227 | html = render_to_string("chat/_message.html", context, request) | 227 | html = render_to_string("chat/_message.html", context, request) |
228 | 228 | ||
229 | - return JsonResponse({'message': message, 'view': html, 'new_id': msg.id}) | ||
230 | \ No newline at end of file | 229 | \ No newline at end of file |
230 | + return JsonResponse({'view': html, 'new_id': msg.id, 'talk_id': msg.talk.id}) | ||
231 | + | ||
232 | +@login_required | ||
233 | +def favorite(request, message): | ||
234 | + action = request.GET.get('action', '') | ||
235 | + message = get_object_or_404(TalkMessages, id = message) | ||
236 | + | ||
237 | + if action == 'favorite': | ||
238 | + ChatFavorites.objects.create(message = message, user = request.user) | ||
239 | + | ||
240 | + return JsonResponse({'label': _('Unfavorite')}) | ||
241 | + else: | ||
242 | + ChatFavorites.objects.filter(message = message, user = request.user).delete() | ||
243 | + | ||
244 | + return JsonResponse({'label': _('Favorite')}) | ||
245 | + | ||
246 | +def load_messages(request, talk): | ||
247 | + context = { | ||
248 | + 'request': request, | ||
249 | + } | ||
250 | + | ||
251 | + user = request.user | ||
252 | + favorites = request.GET.get('favorite', False) | ||
253 | + mines = request.GET.get('mine', False) | ||
254 | + showing = request.GET.get('showing', '') | ||
255 | + n_views = 0 | ||
256 | + | ||
257 | + if not favorites: | ||
258 | + if mines: | ||
259 | + messages = TalkMessages.objects.filter(talk__id = talk, user = user) | ||
260 | + else: | ||
261 | + messages = TalkMessages.objects.filter(talk__id = talk) | ||
262 | + else: | ||
263 | + if mines: | ||
264 | + messages = TalkMessages.objects.filter(talk__id = talk, chat_favorites_message__isnull = False, chat_favorites_message__user = user, user = user) | ||
265 | + else: | ||
266 | + messages = TalkMessages.objects.filter(talk__id = talk, chat_favorites_message__isnull = False, chat_favorites_message__user = user) | ||
267 | + | ||
268 | + if showing: #Exclude ajax creation messages results | ||
269 | + showing = showing.split(',') | ||
270 | + messages = messages.exclude(id__in = showing) | ||
271 | + | ||
272 | + has_page = request.GET.get('page', None) | ||
273 | + | ||
274 | + if has_page is None: | ||
275 | + views = ChatVisualizations.objects.filter(Q(user = user) & Q(viewed = False) & (Q(message__talk__id = talk))) | ||
276 | + n_views = views.count() | ||
277 | + views.update(viewed = True, date_viewed = datetime.now()) | ||
278 | + | ||
279 | + paginator = Paginator(messages.order_by("-create_date"), 20) | ||
280 | + | ||
281 | + try: | ||
282 | + page_number = int(request.GET.get('page', 1)) | ||
283 | + except ValueError: | ||
284 | + raise Http404 | ||
285 | + | ||
286 | + try: | ||
287 | + page_obj = paginator.page(page_number) | ||
288 | + except EmptyPage: | ||
289 | + raise Http404 | ||
290 | + | ||
291 | + context['messages'] = page_obj.object_list | ||
292 | + | ||
293 | + response = render_to_string("chat/_list_messages.html", context, request) | ||
294 | + | ||
295 | + return JsonResponse({"messages": response, "unviewed": n_views, "count": messages.count(), "num_pages": paginator.num_pages, "num_page": page_obj.number}) | ||
231 | \ No newline at end of file | 296 | \ No newline at end of file |
subjects/locale/pt_BR/LC_MESSAGES/django.po
@@ -27,28 +27,20 @@ msgid "There is another subject with this name, try another one." | @@ -27,28 +27,20 @@ msgid "There is another subject with this name, try another one." | ||
27 | msgstr "Já existe um assunto com esse nome, tente outro." | 27 | msgstr "Já existe um assunto com esse nome, tente outro." |
28 | 28 | ||
29 | #: subjects/forms.py:76 subjects/forms.py:180 | 29 | #: subjects/forms.py:76 subjects/forms.py:180 |
30 | -#, fuzzy | ||
31 | -#| msgid "this date must be today or after" | ||
32 | msgid "This date must be today or after" | 30 | msgid "This date must be today or after" |
33 | msgstr "Essa data deve ser hoje ou depois disso" | 31 | msgstr "Essa data deve ser hoje ou depois disso" |
34 | 32 | ||
35 | #: subjects/forms.py:86 subjects/forms.py:190 | 33 | #: subjects/forms.py:86 subjects/forms.py:190 |
36 | -#, fuzzy | ||
37 | -#| msgid "this date must be today or after" | ||
38 | msgid "This date must be equal subscribe begin or after" | 34 | msgid "This date must be equal subscribe begin or after" |
39 | -msgstr "Essa data deve ser hoje ou depois disso" | 35 | +msgstr "Essa data deve ser igual ou depois de começarem as incrições" |
40 | 36 | ||
41 | #: subjects/forms.py:96 subjects/forms.py:200 | 37 | #: subjects/forms.py:96 subjects/forms.py:200 |
42 | -#, fuzzy | ||
43 | -#| msgid "this date must be today or after" | ||
44 | msgid "This date must be after subscribe end" | 38 | msgid "This date must be after subscribe end" |
45 | -msgstr "Essa data deve ser hoje ou depois disso" | 39 | +msgstr "Essa data deve ser depois do fim das inscrições" |
46 | 40 | ||
47 | #: subjects/forms.py:105 subjects/forms.py:209 | 41 | #: subjects/forms.py:105 subjects/forms.py:209 |
48 | -#, fuzzy | ||
49 | -#| msgid "this date must be today or after" | ||
50 | msgid "This date must be equal init date or after" | 42 | msgid "This date must be equal init date or after" |
51 | -msgstr "Essa data deve ser hoje ou depois disso" | 43 | +msgstr "Essa data deve ser igual ou depois da data de início" |
52 | 44 | ||
53 | #: subjects/models.py:14 subjects/models.py:20 | 45 | #: subjects/models.py:14 subjects/models.py:20 |
54 | msgid "Name" | 46 | msgid "Name" |
@@ -227,13 +219,11 @@ msgstr "Não possui professores" | @@ -227,13 +219,11 @@ msgstr "Não possui professores" | ||
227 | 219 | ||
228 | #: subjects/templates/subjects/resource_card.html:50 | 220 | #: subjects/templates/subjects/resource_card.html:50 |
229 | msgid "Category" | 221 | msgid "Category" |
230 | -msgstr "" | 222 | +msgstr "Categoria" |
231 | 223 | ||
232 | #: subjects/templates/subjects/resource_card.html:53 | 224 | #: subjects/templates/subjects/resource_card.html:53 |
233 | -#, fuzzy | ||
234 | -#| msgid "Subjects" | ||
235 | msgid "Subject" | 225 | msgid "Subject" |
236 | -msgstr "Assuntos" | 226 | +msgstr "Assunto" |
237 | 227 | ||
238 | #: subjects/templates/subjects/resource_card.html:61 | 228 | #: subjects/templates/subjects/resource_card.html:61 |
239 | msgid "Access Resource" | 229 | msgid "Access Resource" |
youtube_video/forms.py
@@ -59,7 +59,7 @@ class YTVideoForm(forms.ModelForm): | @@ -59,7 +59,7 @@ class YTVideoForm(forms.ModelForm): | ||
59 | same_name = topic.resource_topic.filter(name__unaccent__iexact = name).count() | 59 | same_name = topic.resource_topic.filter(name__unaccent__iexact = name).count() |
60 | 60 | ||
61 | if same_name > 0: | 61 | if same_name > 0: |
62 | - self._errors['name'] = [_('This subject already has a youtube video with this name')] | 62 | + self._errors['name'] = [_('This subject already has a resource with this name')] |
63 | 63 | ||
64 | return ValueError | 64 | return ValueError |
65 | 65 |
youtube_video/locale/pt_BR/LC_MESSAGES/django.po
@@ -8,7 +8,7 @@ msgid "" | @@ -8,7 +8,7 @@ msgid "" | ||
8 | msgstr "" | 8 | msgstr "" |
9 | "Project-Id-Version: PACKAGE VERSION\n" | 9 | "Project-Id-Version: PACKAGE VERSION\n" |
10 | "Report-Msgid-Bugs-To: \n" | 10 | "Report-Msgid-Bugs-To: \n" |
11 | -"POT-Creation-Date: 2017-03-09 17:01-0300\n" | 11 | +"POT-Creation-Date: 2017-03-22 11:57-0300\n" |
12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
13 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | 13 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
14 | "Language-Team: LANGUAGE <LL@li.org>\n" | 14 | "Language-Team: LANGUAGE <LL@li.org>\n" |
@@ -18,106 +18,102 @@ msgstr "" | @@ -18,106 +18,102 @@ msgstr "" | ||
18 | "Content-Transfer-Encoding: 8bit\n" | 18 | "Content-Transfer-Encoding: 8bit\n" |
19 | "Plural-Forms: nplurals=2; plural=(n > 1);\n" | 19 | "Plural-Forms: nplurals=2; plural=(n > 1);\n" |
20 | 20 | ||
21 | -#: youtube_video/forms.py:36 | 21 | +#: .\forms.py:36 |
22 | msgid "Tags" | 22 | msgid "Tags" |
23 | msgstr "Tags" | 23 | msgstr "Tags" |
24 | 24 | ||
25 | -#: youtube_video/forms.py:42 | 25 | +#: .\forms.py:42 |
26 | msgid "Video title" | 26 | msgid "Video title" |
27 | msgstr "Título do Vídeo" | 27 | msgstr "Título do Vídeo" |
28 | 28 | ||
29 | -#: youtube_video/forms.py:62 | ||
30 | -msgid "This subject already has a youtube video with this name" | ||
31 | -msgstr "Esse assunto já possui um vídeo do YouTube com esse nome" | 29 | +#: .\forms.py:62 |
30 | +msgid "This subject already has a resource with this name" | ||
31 | +msgstr "Esse assunto já possui um recurso com esse nome" | ||
32 | 32 | ||
33 | -#: youtube_video/forms.py:71 | ||
34 | -#, fuzzy | ||
35 | -#| msgid "Invalid URL. It should be an embed YouTube link." | 33 | +#: .\forms.py:71 |
36 | msgid "Invalid URL. It should be an YouTube link." | 34 | msgid "Invalid URL. It should be an YouTube link." |
37 | -msgstr "URL inválida. Ela deve ser uma URL de embed do YouTube." | 35 | +msgstr "URL inválida. Ela deve ser uma URL de um vídeo do YouTube." |
38 | 36 | ||
39 | -#: youtube_video/models.py:8 | 37 | +#: .\models.py:8 |
40 | msgid "URL" | 38 | msgid "URL" |
41 | msgstr "URL" | 39 | msgstr "URL" |
42 | 40 | ||
43 | -#: youtube_video/models.py:11 | 41 | +#: .\models.py:11 |
44 | msgid "YTVideo" | 42 | msgid "YTVideo" |
45 | msgstr "Vídeo do YouTube" | 43 | msgstr "Vídeo do YouTube" |
46 | 44 | ||
47 | -#: youtube_video/models.py:12 | 45 | +#: .\models.py:12 |
48 | msgid "YTVideos" | 46 | msgid "YTVideos" |
49 | msgstr "Vídeos do YouTube" | 47 | msgstr "Vídeos do YouTube" |
50 | 48 | ||
51 | -#: youtube_video/models.py:30 | 49 | +#: .\models.py:30 |
52 | msgid "Are you sure you want delete the YouTube Video" | 50 | msgid "Are you sure you want delete the YouTube Video" |
53 | msgstr "Você tem certeza que deseja deletar o Vídeo do YouTube" | 51 | msgstr "Você tem certeza que deseja deletar o Vídeo do YouTube" |
54 | 52 | ||
55 | -#: youtube_video/templates/youtube/_form.html:49 | 53 | +#: .\templates\youtube\_form.html:49 |
56 | msgid "Common resources settings" | 54 | msgid "Common resources settings" |
57 | msgstr "Configurações comuns à todos os recursos" | 55 | msgstr "Configurações comuns à todos os recursos" |
58 | 56 | ||
59 | -#: youtube_video/templates/youtube/_form.html:98 | 57 | +#: .\templates\youtube\_form.html:98 |
60 | msgid "Pendencies Notifications" | 58 | msgid "Pendencies Notifications" |
61 | msgstr "Notificações de Pendências" | 59 | msgstr "Notificações de Pendências" |
62 | 60 | ||
63 | -#: youtube_video/templates/youtube/_form.html:119 | 61 | +#: .\templates\youtube\_form.html:119 |
64 | msgid "Action not performed by the user" | 62 | msgid "Action not performed by the user" |
65 | msgstr "Ação não realizada pelo usuário" | 63 | msgstr "Ação não realizada pelo usuário" |
66 | 64 | ||
67 | -#: youtube_video/templates/youtube/_form.html:145 | 65 | +#: .\templates\youtube\_form.html:145 |
68 | msgid "Wished period" | 66 | msgid "Wished period" |
69 | msgstr "Período desejado" | 67 | msgstr "Período desejado" |
70 | 68 | ||
71 | -#: youtube_video/templates/youtube/_form.html:242 | 69 | +#: .\templates\youtube\_form.html:242 |
72 | msgid "Attribute students to YouTube Video" | 70 | msgid "Attribute students to YouTube Video" |
73 | msgstr "Atribuir estudantes ao Vídeo do YouTube" | 71 | msgstr "Atribuir estudantes ao Vídeo do YouTube" |
74 | 72 | ||
75 | -#: youtube_video/templates/youtube/_form.html:262 | 73 | +#: .\templates\youtube\_form.html:262 |
76 | msgid "Attribute groups to YouTube Video" | 74 | msgid "Attribute groups to YouTube Video" |
77 | msgstr "Atribuir grupos de estudo ao Vídeo do YouTube" | 75 | msgstr "Atribuir grupos de estudo ao Vídeo do YouTube" |
78 | 76 | ||
79 | -#: youtube_video/templates/youtube/_form.html:331 | 77 | +#: .\templates\youtube\_form.html:331 |
80 | msgid "Save" | 78 | msgid "Save" |
81 | msgstr "Salvar" | 79 | msgstr "Salvar" |
82 | 80 | ||
83 | -#: youtube_video/templates/youtube/_form.html:338 | 81 | +#: .\templates\youtube\_form.html:338 |
84 | msgid "Add new notification" | 82 | msgid "Add new notification" |
85 | msgstr "Adicionar nova notificação" | 83 | msgstr "Adicionar nova notificação" |
86 | 84 | ||
87 | -#: youtube_video/templates/youtube/_form.html:339 | 85 | +#: .\templates\youtube\_form.html:339 |
88 | msgid "Remove this" | 86 | msgid "Remove this" |
89 | msgstr "Remover essa notificação" | 87 | msgstr "Remover essa notificação" |
90 | 88 | ||
91 | -#: youtube_video/templates/youtube/create.html:21 | 89 | +#: .\templates\youtube\create.html:21 |
92 | msgid "Create YouTube Video" | 90 | msgid "Create YouTube Video" |
93 | msgstr "Adicionar Vídeo do YouTube" | 91 | msgstr "Adicionar Vídeo do YouTube" |
94 | 92 | ||
95 | -#: youtube_video/templates/youtube/update.html:21 | 93 | +#: .\templates\youtube\update.html:21 |
96 | msgid "Edit: " | 94 | msgid "Edit: " |
97 | msgstr "Editar: " | 95 | msgstr "Editar: " |
98 | 96 | ||
99 | -#: youtube_video/views.py:46 | 97 | +#: .\views.py:46 |
100 | #, python-format | 98 | #, python-format |
101 | msgid "%s - Video" | 99 | msgid "%s - Video" |
102 | msgstr "%s - Vídeo" | 100 | msgstr "%s - Vídeo" |
103 | 101 | ||
104 | -#: youtube_video/views.py:148 youtube_video/views.py:161 | ||
105 | -#: youtube_video/views.py:180 youtube_video/views.py:283 | ||
106 | -#: youtube_video/views.py:296 youtube_video/views.py:305 | 102 | +#: .\views.py:148 .\views.py:161 .\views.py:180 .\views.py:283 .\views.py:296 |
103 | +#: .\views.py:305 | ||
107 | msgid "Visualize" | 104 | msgid "Visualize" |
108 | msgstr "Visualizar" | 105 | msgstr "Visualizar" |
109 | 106 | ||
110 | -#: youtube_video/views.py:148 youtube_video/views.py:161 | ||
111 | -#: youtube_video/views.py:180 youtube_video/views.py:283 | ||
112 | -#: youtube_video/views.py:296 youtube_video/views.py:305 | 107 | +#: .\views.py:148 .\views.py:161 .\views.py:180 .\views.py:283 .\views.py:296 |
108 | +#: .\views.py:305 | ||
113 | msgid "Finish" | 109 | msgid "Finish" |
114 | msgstr "Finalizar" | 110 | msgstr "Finalizar" |
115 | 111 | ||
116 | -#: youtube_video/views.py:227 | 112 | +#: .\views.py:227 |
117 | msgid "Create Youtube Video" | 113 | msgid "Create Youtube Video" |
118 | msgstr "Adicionar Vídeo do YouTube" | 114 | msgstr "Adicionar Vídeo do YouTube" |
119 | 115 | ||
120 | -#: youtube_video/views.py:238 | 116 | +#: .\views.py:238 |
121 | #, python-format | 117 | #, python-format |
122 | msgid "" | 118 | msgid "" |
123 | "The Youtube Video \"%s\" was added to the Topic \"%s\" of the virtual " | 119 | "The Youtube Video \"%s\" was added to the Topic \"%s\" of the virtual " |
@@ -126,16 +122,16 @@ msgstr "" | @@ -126,16 +122,16 @@ msgstr "" | ||
126 | "O Vídeo do YouTube \"%s\" foi adicionado ao tópico \"%s\" do ambiente " | 122 | "O Vídeo do YouTube \"%s\" foi adicionado ao tópico \"%s\" do ambiente " |
127 | "virtual \"%s\" com sucesso!" | 123 | "virtual \"%s\" com sucesso!" |
128 | 124 | ||
129 | -#: youtube_video/views.py:346 | 125 | +#: .\views.py:346 |
130 | msgid "Update YouTube Video" | 126 | msgid "Update YouTube Video" |
131 | msgstr "Atualizar Vídeo do YouTube" | 127 | msgstr "Atualizar Vídeo do YouTube" |
132 | 128 | ||
133 | -#: youtube_video/views.py:357 | 129 | +#: .\views.py:357 |
134 | #, python-format | 130 | #, python-format |
135 | msgid "The YouTube Video \"%s\" was updated successfully!" | 131 | msgid "The YouTube Video \"%s\" was updated successfully!" |
136 | msgstr "O Vídeo do YouTube \"%s\" foi atualizado com sucesso!" | 132 | msgstr "O Vídeo do YouTube \"%s\" foi atualizado com sucesso!" |
137 | 133 | ||
138 | -#: youtube_video/views.py:393 | 134 | +#: .\views.py:393 |
139 | #, python-format | 135 | #, python-format |
140 | msgid "" | 136 | msgid "" |
141 | "The YouTube Video \"%s\" was removed successfully from virtual environment " | 137 | "The YouTube Video \"%s\" was removed successfully from virtual environment " |