Commit 73bbb4447ec08e31834c2b461112420d03840b8b
1 parent
a9afab64
Exists in
master
and in
3 other branches
Colocando os logs para visualizar, iniciar, online e terminado uma webconferencia
Showing
3 changed files
with
137 additions
and
80 deletions
Show diff stats
webconference/templates/webconference/jitsi.html
... | ... | @@ -40,13 +40,11 @@ |
40 | 40 | api.executeCommand('email', '{{user.email}}'); |
41 | 41 | api.executeCommand('avatarUrl', '{{user_image}}'); |
42 | 42 | api.addEventListener('videoConferenceLeft', function(res){ |
43 | - console.log(res); | |
44 | - console.log("saiu"); | |
45 | 43 | $.ajax({ |
46 | 44 | method: "GET", |
47 | - url: "{% url 'webconferences:saiu'%}", | |
45 | + url: "{% url 'webconferences:exit'%}", | |
48 | 46 | dataType: 'json', |
49 | - data: $.extend(res,{'email':'{{user_email}}'}), | |
47 | + data: res, | |
50 | 48 | success: function(response) { |
51 | 49 | window.location.replace(response['url']); |
52 | 50 | console.log(response); |
... | ... | @@ -56,31 +54,21 @@ |
56 | 54 | } |
57 | 55 | }); |
58 | 56 | }); |
57 | + var repeater = setInterval(function () { | |
58 | + $.ajax({ | |
59 | + method: "GET", | |
60 | + url: "{% url 'webconferences:online'%}", | |
61 | + dataType: 'json', | |
62 | + data: {'slug':'{{name_room}}'}, | |
63 | + success: function(response) { | |
64 | + console.log(response); | |
65 | + }, | |
66 | + error: function(response) { | |
67 | + console.log(response); | |
68 | + } | |
69 | + }); | |
70 | + }, 60*1000); | |
59 | 71 | } |
60 | - // callfunction(); | |
61 | - var callCount = 1; | |
62 | - var repeater = setInterval(function () { | |
63 | - console.log(callCount); | |
64 | - if (callCount < 10) { | |
65 | - | |
66 | - var doc = document.getElementById('jitsiConferenceFrame0').document; | |
67 | - // var iframe = document.getElementById('jitsiConferenceFrame0'); | |
68 | - // var innerDoc = (iframe.contentDocument) ? iframe.contentDocument : iframe.contentWindow.document; | |
69 | - | |
70 | - // var ls = doc.getElementById('toolbar_button_link'); | |
71 | - console.log(doc); | |
72 | - // $("#jitsiConferenceFrame0").contents().find("#toolbar_button_link").remove(); | |
73 | - // $("a#toolbar_button_link.button.icon-link").remove(); | |
74 | - // console.log($("#toolbar_contact_list").remove()); | |
75 | - // $("#toolbar_button_link").remove(); //utilizandos para retirar o botão de compartilhar do jitsi | |
76 | - callCount += 1; | |
77 | - console.log("aqui"); | |
78 | - } else { | |
79 | - clearInterval(repeater); | |
80 | - } | |
81 | - }, 1000); | |
82 | - | |
83 | - // api.executeCommands({displayName: ['Jailson']}); | |
84 | 72 | </script> |
85 | 73 | |
86 | 74 | </body> | ... | ... |
webconference/urls.py
... | ... | @@ -11,6 +11,7 @@ urlpatterns = [ |
11 | 11 | url(r'^window_view/(?P<slug>[\w_-]+)/$', views.NewWindowView.as_view(), name = 'window_view'), |
12 | 12 | url(r'^view/(?P<slug>[\w_-]+)/$', views.InsideView.as_view(), name = 'view'), |
13 | 13 | url(r'^conference/(?P<slug>[\w_-]+)/$',views.Conference.as_view(), name = 'conference'), |
14 | - url(r'^saiu/$',views.saiu, name = 'saiu'), | |
14 | + url(r'^finish/$',views.finish, name = 'exit'), | |
15 | + url(r'^online/$',views.online, name = 'online'), | |
15 | 16 | url(r'^settings/$', views.ConferenceSettings.as_view(), name = 'settings'), |
16 | 17 | ] | ... | ... |
webconference/views.py
... | ... | @@ -11,6 +11,7 @@ from amadeus.permissions import has_subject_permissions, has_resource_permission |
11 | 11 | import time |
12 | 12 | from log.models import Log |
13 | 13 | from log.mixins import LogMixin |
14 | +from log.decorators import log_decorator | |
14 | 15 | |
15 | 16 | from topics.models import Topic |
16 | 17 | |
... | ... | @@ -20,13 +21,11 @@ from braces import views as braces_mixins |
20 | 21 | from .forms import WebconferenceForm, SettingsForm |
21 | 22 | from .models import Webconference, ConferenceSettings as Settings |
22 | 23 | |
23 | -class NewWindowView(LoginRequiredMixin, | |
24 | - # '''LogMixin,''' | |
25 | - generic.DetailView): | |
26 | - # log_component = 'resources' | |
27 | - # log_action = 'view' | |
28 | - # log_resource = 'webpage' | |
29 | - # log_context = {} | |
24 | +class NewWindowView(LoginRequiredMixin,LogMixin, generic.DetailView): | |
25 | + log_component = 'resources' | |
26 | + log_action = 'view' | |
27 | + log_resource = 'webconference' | |
28 | + log_context = {} | |
30 | 29 | |
31 | 30 | login_url = reverse_lazy("users:login") |
32 | 31 | redirect_field_name = 'next' |
... | ... | @@ -47,33 +46,46 @@ class NewWindowView(LoginRequiredMixin, |
47 | 46 | def get_context_data(self, **kwargs): |
48 | 47 | context = super(NewWindowView, self).get_context_data(**kwargs) |
49 | 48 | context['title'] = _("%s - Web Conference")%(self.object.name) |
50 | - # self.log_context['category_id'] = self.object.topic.subject.category.id | |
51 | - # self.log_context['category_name'] = self.object.topic.subject.category.name | |
52 | - # self.log_context['category_slug'] = self.object.topic.subject.category.slug | |
53 | - # self.log_context['subject_id'] = self.object.topic.subject.id | |
54 | - # self.log_context['subject_name'] = self.object.topic.subject.name | |
55 | - # self.log_context['subject_slug'] = self.object.topic.subject.slug | |
56 | - # self.log_context['topic_id'] = self.object.topic.id | |
57 | - # self.log_context['topic_name'] = self.object.topic.name | |
58 | - # self.log_context['topic_slug'] = self.object.topic.slug | |
59 | - # self.log_context['webpage_id'] = self.object.id | |
60 | - # self.log_context['webpage_name'] = self.object.name | |
61 | - # self.log_context['webpage_slug'] = self.object.slug | |
62 | - # self.log_context['timestamp_start'] = str(int(time.time())) | |
63 | - | |
64 | - # super(NewWindowView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
65 | - # | |
66 | - # self.request.session['log_id'] = Log.objects.latest('id').id | |
49 | + self.log_context['category_id'] = self.object.topic.subject.category.id | |
50 | + self.log_context['category_name'] = self.object.topic.subject.category.name | |
51 | + self.log_context['category_slug'] = self.object.topic.subject.category.slug | |
52 | + self.log_context['subject_id'] = self.object.topic.subject.id | |
53 | + self.log_context['subject_name'] = self.object.topic.subject.name | |
54 | + self.log_context['subject_slug'] = self.object.topic.subject.slug | |
55 | + self.log_context['topic_id'] = self.object.topic.id | |
56 | + self.log_context['topic_name'] = self.object.topic.name | |
57 | + self.log_context['topic_slug'] = self.object.topic.slug | |
58 | + self.log_context['webconference_id'] = self.object.id | |
59 | + self.log_context['webconference_name'] = self.object.name | |
60 | + self.log_context['webconference_slug'] = self.object.slug | |
61 | + self.log_context['webconference_view'] = str(int(time.time())) | |
62 | + | |
63 | + super(NewWindowView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
64 | + | |
65 | + self.request.session['log_id'] = Log.objects.latest('id').id | |
67 | 66 | |
68 | 67 | return context |
69 | 68 | |
70 | -class Conference(LoginRequiredMixin,generic.TemplateView): | |
69 | +class Conference(LoginRequiredMixin,LogMixin,generic.TemplateView): | |
70 | + | |
71 | + log_component = 'resources' | |
72 | + log_action = 'initwebconference' | |
73 | + log_resource = 'webconference' | |
74 | + log_context = {} | |
71 | 75 | |
72 | 76 | login_url = reverse_lazy("users:login") |
73 | 77 | redirect_field_name = 'next' |
74 | 78 | |
75 | 79 | template_name = 'webconference/jitsi.html' |
76 | 80 | |
81 | + def dispatch(self, request, *args, **kwargs): | |
82 | + slug = self.kwargs.get('slug', '') | |
83 | + conference = get_object_or_404(Webconference, slug = slug) | |
84 | + | |
85 | + if not has_resource_permissions(request.user, conference): | |
86 | + return redirect(reverse_lazy('subjects:home')) | |
87 | + | |
88 | + return super(Conference, self).dispatch(request, *args, **kwargs) | |
77 | 89 | |
78 | 90 | def get_context_data(self, **kwargs): |
79 | 91 | context = super(Conference, self).get_context_data(**kwargs) |
... | ... | @@ -84,20 +96,77 @@ class Conference(LoginRequiredMixin,generic.TemplateView): |
84 | 96 | except AttributeError: |
85 | 97 | context['domain'] = 'meet.jit.si' |
86 | 98 | |
99 | + conference = get_object_or_404(Webconference, slug = kwargs.get('slug')) | |
100 | + self.log_context['category_id'] = conference.topic.subject.category.id | |
101 | + self.log_context['category_name'] = conference.topic.subject.category.name | |
102 | + self.log_context['category_slug'] = conference.topic.subject.category.slug | |
103 | + self.log_context['subject_id'] = conference.topic.subject.id | |
104 | + self.log_context['subject_name'] = conference.topic.subject.name | |
105 | + self.log_context['subject_slug'] = conference.topic.subject.slug | |
106 | + self.log_context['topic_id'] = conference.topic.id | |
107 | + self.log_context['topic_name'] = conference.topic.name | |
108 | + self.log_context['topic_slug'] = conference.topic.slug | |
109 | + self.log_context['webconference_id'] = conference.id | |
110 | + self.log_context['webconference_name'] = conference.name | |
111 | + self.log_context['webconference_slug'] = conference.slug | |
112 | + self.log_context['webconference_init'] = str(int(time.time())) | |
113 | + | |
114 | + super(Conference, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
115 | + | |
87 | 116 | return context |
88 | 117 | |
89 | -def saiu(request): | |
118 | +@log_decorator('resources', 'online', 'webconference') | |
119 | +def online(request): | |
120 | + webconference = get_object_or_404(Webconference, slug = request.GET['slug']) | |
121 | + log_context = {} | |
122 | + log_context['category_id'] = webconference.topic.subject.category.id | |
123 | + log_context['category_name'] = webconference.topic.subject.category.name | |
124 | + log_context['category_slug'] = webconference.topic.subject.category.slug | |
125 | + log_context['subject_id'] = webconference.topic.subject.id | |
126 | + log_context['subject_name'] = webconference.topic.subject.name | |
127 | + log_context['subject_slug'] = webconference.topic.subject.slug | |
128 | + log_context['topic_id'] = webconference.topic.id | |
129 | + log_context['topic_name'] = webconference.topic.name | |
130 | + log_context['topic_slug'] = webconference.topic.slug | |
131 | + log_context['webconference_id'] = webconference.id | |
132 | + log_context['webconference_name'] = webconference.name | |
133 | + log_context['webconference_slug'] = webconference.slug | |
134 | + log_context['webconference_online'] = str(int(time.time())) | |
135 | + | |
136 | + request.log_context = log_context | |
137 | + | |
138 | + return JsonResponse({'message':'ok'}) | |
139 | + | |
140 | +@log_decorator('resources', 'finish', 'webconference') | |
141 | +def finish(request): | |
142 | + | |
143 | + webconference = get_object_or_404(Webconference, slug = request.GET['roomName']) | |
144 | + log_context = {} | |
145 | + log_context['category_id'] = webconference.topic.subject.category.id | |
146 | + log_context['category_name'] = webconference.topic.subject.category.name | |
147 | + log_context['category_slug'] = webconference.topic.subject.category.slug | |
148 | + log_context['subject_id'] = webconference.topic.subject.id | |
149 | + log_context['subject_name'] = webconference.topic.subject.name | |
150 | + log_context['subject_slug'] = webconference.topic.subject.slug | |
151 | + log_context['topic_id'] = webconference.topic.id | |
152 | + log_context['topic_name'] = webconference.topic.name | |
153 | + log_context['topic_slug'] = webconference.topic.slug | |
154 | + log_context['webconference_id'] = webconference.id | |
155 | + log_context['webconference_name'] = webconference.name | |
156 | + log_context['webconference_slug'] = webconference.slug | |
157 | + log_context['webconference_finish'] = str(int(time.time())) | |
158 | + | |
159 | + request.log_context = log_context | |
160 | + | |
90 | 161 | url = {'url': 'http://localhost:8000' + str(reverse_lazy('webconferences:view', kwargs = {'slug': request.GET['roomName']}))} |
91 | 162 | return JsonResponse(url, safe=False) |
92 | 163 | |
93 | 164 | |
94 | -class InsideView(LoginRequiredMixin, | |
95 | -# '''LogMixin,''' | |
96 | -generic.DetailView): | |
97 | - # log_component = 'resources' | |
98 | - # log_action = 'view' | |
99 | - # log_resource = 'webpage' | |
100 | - # log_context = {} | |
165 | +class InsideView(LoginRequiredMixin, LogMixin, generic.DetailView): | |
166 | + log_component = 'resources' | |
167 | + log_action = 'view' | |
168 | + log_resource = 'webconference' | |
169 | + log_context = {} | |
101 | 170 | |
102 | 171 | login_url = reverse_lazy("users:login") |
103 | 172 | redirect_field_name = 'next' |
... | ... | @@ -123,23 +192,23 @@ generic.DetailView): |
123 | 192 | context['topic'] = self.object.topic |
124 | 193 | context['subject'] = self.object.topic.subject |
125 | 194 | |
126 | - # self.log_context['category_id'] = self.object.topic.subject.category.id | |
127 | - # self.log_context['category_name'] = self.object.topic.subject.category.name | |
128 | - # self.log_context['category_slug'] = self.object.topic.subject.category.slug | |
129 | - # self.log_context['subject_id'] = self.object.topic.subject.id | |
130 | - # self.log_context['subject_name'] = self.object.topic.subject.name | |
131 | - # self.log_context['subject_slug'] = self.object.topic.subject.slug | |
132 | - # self.log_context['topic_id'] = self.object.topic.id | |
133 | - # self.log_context['topic_name'] = self.object.topic.name | |
134 | - # self.log_context['topic_slug'] = self.object.topic.slug | |
135 | - # self.log_context['webpage_id'] = self.object.id | |
136 | - # self.log_context['webpage_name'] = self.object.name | |
137 | - # self.log_context['webpage_slug'] = self.object.slug | |
138 | - # self.log_context['timestamp_start'] = str(int(time.time())) | |
139 | - # | |
140 | - # super(InsideView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
141 | - # | |
142 | - # self.request.session['log_id'] = Log.objects.latest('id').id | |
195 | + self.log_context['category_id'] = self.object.topic.subject.category.id | |
196 | + self.log_context['category_name'] = self.object.topic.subject.category.name | |
197 | + self.log_context['category_slug'] = self.object.topic.subject.category.slug | |
198 | + self.log_context['subject_id'] = self.object.topic.subject.id | |
199 | + self.log_context['subject_name'] = self.object.topic.subject.name | |
200 | + self.log_context['subject_slug'] = self.object.topic.subject.slug | |
201 | + self.log_context['topic_id'] = self.object.topic.id | |
202 | + self.log_context['topic_name'] = self.object.topic.name | |
203 | + self.log_context['topic_slug'] = self.object.topic.slug | |
204 | + self.log_context['webconference_id'] = self.object.id | |
205 | + self.log_context['webconference_name'] = self.object.name | |
206 | + self.log_context['webconference_slug'] = self.object.slug | |
207 | + self.log_context['webconference_view'] = str(int(time.time())) | |
208 | + | |
209 | + super(InsideView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
210 | + | |
211 | + self.request.session['log_id'] = Log.objects.latest('id').id | |
143 | 212 | |
144 | 213 | return context |
145 | 214 | |
... | ... | @@ -453,6 +522,5 @@ class ConferenceSettings(braces_mixins.LoginRequiredMixin, braces_mixins.Staffus |
453 | 522 | context = super(ConferenceSettings, self).get_context_data(**kwargs) |
454 | 523 | |
455 | 524 | context['title'] = _('Web Conference Settings') |
456 | - # context['settings_menu_active'] = "settings_menu_active" | |
457 | 525 | |
458 | 526 | return context | ... | ... |