Commit 2ff7c11e76f5c1471d579c59685fc9272595adb7
1 parent
23ae603c
Exists in
master
and in
2 other branches
Fixing bug of changing breadcrumb when error on update subject/resource
Showing
19 changed files
with
542 additions
and
555 deletions
Show diff stats
bulletin/templates/bulletin/update.html
| ... | ... | @@ -18,8 +18,8 @@ |
| 18 | 18 | {% breadcrumb topic 'subjects:topic_view' topic.subject.slug topic.slug %} |
| 19 | 19 | |
| 20 | 20 | {% trans 'Edit: ' as bread %} |
| 21 | - {% with bread|add:bulletin.name as bread_slug %} | |
| 22 | - {% breadcrumb bread_slug 'bulletin:update' topic.slug bulletin.slug %} | |
| 21 | + {% with bread|add:resource.name as bread_slug %} | |
| 22 | + {% breadcrumb bread_slug 'bulletin:update' topic.slug resource.slug %} | |
| 23 | 23 | {% endwith %} |
| 24 | 24 | {% endblock %} |
| 25 | 25 | ... | ... |
bulletin/views.py
| ... | ... | @@ -789,6 +789,7 @@ class UpdateView(LoginRequiredMixin, LogMixin, generic.UpdateView): |
| 789 | 789 | create_excel_file(alunos, itens_da_meta,meta_geral) |
| 790 | 790 | context['goal_file'] = str(meta_geral.slug) |
| 791 | 791 | context['mimeTypes'] = valid_formats |
| 792 | + context['resource'] = get_object_or_404(Bulletin, slug = self.kwargs.get('slug', '')) | |
| 792 | 793 | |
| 793 | 794 | return context |
| 794 | 795 | ... | ... |
file_link/templates/file_links/update.html
| ... | ... | @@ -18,8 +18,8 @@ |
| 18 | 18 | {% breadcrumb topic 'subjects:topic_view' topic.subject.slug topic.slug %} |
| 19 | 19 | |
| 20 | 20 | {% trans 'Edit: ' as bread %} |
| 21 | - {% with bread|add:file_link.name as bread_slug %} | |
| 22 | - {% breadcrumb bread_slug 'file_links:update' topic.slug file_link.slug %} | |
| 21 | + {% with bread|add:resource.name as bread_slug %} | |
| 22 | + {% breadcrumb bread_slug 'file_links:update' topic.slug resource.slug %} | |
| 23 | 23 | {% endwith %} |
| 24 | 24 | {% endblock %} |
| 25 | 25 | ... | ... |
file_link/views.py
| ... | ... | @@ -314,6 +314,7 @@ class UpdateView(LoginRequiredMixin, LogMixin, generic.UpdateView): |
| 314 | 314 | context['topic'] = topic |
| 315 | 315 | context['subject'] = topic.subject |
| 316 | 316 | context['mimeTypes'] = valid_formats |
| 317 | + context['resource'] = get_object_or_404(FileLink, slug = self.kwargs.get('slug', '')) | |
| 317 | 318 | |
| 318 | 319 | return context |
| 319 | 320 | ... | ... |
links/forms.py
| ... | ... | @@ -46,15 +46,7 @@ class LinkForm(forms.ModelForm): |
| 46 | 46 | 'students': forms.SelectMultiple, |
| 47 | 47 | 'groups': forms.SelectMultiple, |
| 48 | 48 | } |
| 49 | - | |
| 50 | - def clean(self): | |
| 51 | - | |
| 52 | - cleaned_data = self.cleaned_data | |
| 53 | - | |
| 54 | - | |
| 55 | - return cleaned_data | |
| 56 | - | |
| 57 | - | |
| 49 | + | |
| 58 | 50 | def clean_name(self): |
| 59 | 51 | name = self.cleaned_data.get('name', '') |
| 60 | 52 | ... | ... |
links/templates/links/_form.html
| ... | ... | @@ -4,19 +4,6 @@ |
| 4 | 4 | <form method="post" action="" enctype="multipart/form-data"> |
| 5 | 5 | {% csrf_token %} |
| 6 | 6 | |
| 7 | - {% if form.errors %} | |
| 8 | - <div class="alert alert-danger alert-dismissible" role="alert"> | |
| 9 | - <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
| 10 | - <span aria-hidden="true">×</span> | |
| 11 | - </button> | |
| 12 | - <ul> | |
| 13 | - {% for key, message in form.errors.items %} | |
| 14 | - <li>{{message}}</li> | |
| 15 | - {% endfor %} | |
| 16 | - </ul> | |
| 17 | - </div> | |
| 18 | - {% endif %} | |
| 19 | - | |
| 20 | 7 | {% render_field form.control_subject %} |
| 21 | 8 | |
| 22 | 9 | <div class="form-group{% if form.has_error %} has-error {% endif %} is-fileinput"> | ... | ... |
links/templates/links/update.html
| ... | ... | @@ -18,8 +18,8 @@ |
| 18 | 18 | {% breadcrumb topic 'subjects:topic_view' topic.subject.slug topic.slug %} |
| 19 | 19 | |
| 20 | 20 | {% trans 'Edit: ' as bread %} |
| 21 | - {% with bread|add:link.name as bread_slug %} | |
| 22 | - {% breadcrumb bread_slug 'links:update' topic.slug link.slug %} | |
| 21 | + {% with bread|add:resource.name as bread_slug %} | |
| 22 | + {% breadcrumb bread_slug 'links:update' topic.slug resource.slug %} | |
| 23 | 23 | {% endwith %} |
| 24 | 24 | {% endblock %} |
| 25 | 25 | ... | ... |
links/views.py
| ... | ... | @@ -334,6 +334,7 @@ class UpdateLinkView(LoginRequiredMixin, LogMixin, generic.edit.UpdateView): |
| 334 | 334 | |
| 335 | 335 | context['topic'] = topic |
| 336 | 336 | context['subject'] = topic.subject |
| 337 | + context['resource'] = get_object_or_404(Link, slug = self.kwargs.get('slug', '')) | |
| 337 | 338 | |
| 338 | 339 | return context |
| 339 | 340 | ... | ... |
pdf_file/templates/pdf_file/update.html
| ... | ... | @@ -18,8 +18,8 @@ |
| 18 | 18 | {% breadcrumb topic 'subjects:topic_view' topic.subject.slug topic.slug %} |
| 19 | 19 | |
| 20 | 20 | {% trans 'Edit: ' as bread %} |
| 21 | - {% with bread|add:pdf_file.name as bread_slug %} | |
| 22 | - {% breadcrumb bread_slug 'pdf_file:update' topic.slug pdf_file.slug %} | |
| 21 | + {% with bread|add:resource.name as bread_slug %} | |
| 22 | + {% breadcrumb bread_slug 'pdf_file:update' topic.slug resource.slug %} | |
| 23 | 23 | {% endwith %} |
| 24 | 24 | {% endblock %} |
| 25 | 25 | ... | ... |
pdf_file/views.py
| ... | ... | @@ -321,6 +321,7 @@ class UpdateView(LoginRequiredMixin, LogMixin, generic.UpdateView): |
| 321 | 321 | context['topic'] = topic |
| 322 | 322 | context['subject'] = topic.subject |
| 323 | 323 | context['mimeTypes'] = valid_formats |
| 324 | + context['resource'] = get_object_or_404(PDFFile, slug = self.kwargs.get('slug', '')) | |
| 324 | 325 | |
| 325 | 326 | return context |
| 326 | 327 | ... | ... |
subjects/templates/subjects/update.html
| ... | ... | @@ -16,11 +16,11 @@ |
| 16 | 16 | {% block breadcrumbs %} |
| 17 | 17 | {{ block.super }} |
| 18 | 18 | |
| 19 | - {% breadcrumb subject.category 'subjects:cat_view' subject.category.slug %} | |
| 20 | - {% breadcrumb subject 'subjects:view' subject.slug %} | |
| 19 | + {% breadcrumb subject_data.category 'subjects:cat_view' subject_data.category.slug %} | |
| 20 | + {% breadcrumb subject_data 'subjects:view' subject_data.slug %} | |
| 21 | 21 | |
| 22 | 22 | {% trans 'Update: ' as bread %} |
| 23 | - {% with bread|add:object.name as bread_slug %} | |
| 23 | + {% with bread|add:subject_data.name as bread_slug %} | |
| 24 | 24 | {% breadcrumb bread_slug 'subjects:update' %} |
| 25 | 25 | {% endwith %} |
| 26 | 26 | {% endblock %} | ... | ... |
subjects/views.py
| ... | ... | @@ -385,9 +385,9 @@ class SubjectUpdateView(LoginRequiredMixin, LogMixin, UpdateView): |
| 385 | 385 | redirect_field_name = 'next' |
| 386 | 386 | |
| 387 | 387 | def dispatch(self, request, *args, **kwargs): |
| 388 | - subject = get_object_or_404(Subject, slug = kwargs.get('slug', '')) | |
| 389 | - self.subject = subject | |
| 390 | - if not has_subject_permissions(request.user, subject): | |
| 388 | + self.subject = get_object_or_404(Subject, slug = kwargs.get('slug', '')) | |
| 389 | + | |
| 390 | + if not has_subject_permissions(request.user, self.subject): | |
| 391 | 391 | return redirect(reverse_lazy('subjects:home')) |
| 392 | 392 | |
| 393 | 393 | return super(SubjectUpdateView, self).dispatch(request, *args, **kwargs) |
| ... | ... | @@ -406,6 +406,7 @@ class SubjectUpdateView(LoginRequiredMixin, LogMixin, UpdateView): |
| 406 | 406 | context['title'] = _('Update Subject') |
| 407 | 407 | context['template_extends'] = 'categories/home.html' |
| 408 | 408 | context['subjects_menu_active'] = 'subjects_menu_active' |
| 409 | + context['subject_data'] = get_object_or_404(Subject, slug = self.kwargs.get('slug', '')) | |
| 409 | 410 | |
| 410 | 411 | return context |
| 411 | 412 | ... | ... |
topics/templates/topics/update.html
| ... | ... | @@ -3,10 +3,10 @@ |
| 3 | 3 | {% load i18n django_bootstrap_breadcrumbs %} |
| 4 | 4 | |
| 5 | 5 | {% block breadcrumbs %} |
| 6 | - {{ block.super }} | |
| 7 | - | |
| 8 | - {% trans 'Update Topic' as bread %} | |
| 9 | - {% breadcrumb bread 'topics:update' subject.slug topic.slug %} | |
| 6 | + {{ block.super }} | |
| 7 | + | |
| 8 | + {% trans 'Update Topic' as bread %} | |
| 9 | + {% breadcrumb bread 'topics:update' subject.slug topic.slug %} | |
| 10 | 10 | {% endblock %} |
| 11 | 11 | |
| 12 | 12 | {% block content %} |
| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | {% include 'topics/_form.html' %} |
| 17 | 17 | </div> |
| 18 | 18 | </div> |
| 19 | - </div> | |
| 20 | - <br clear="all" /> | |
| 21 | - <br clear="all" /> | |
| 19 | + </div> | |
| 20 | + <br clear="all" /> | |
| 21 | + <br clear="all" /> | |
| 22 | 22 | {% endblock %} | ... | ... |
webconference/templates/webconference/update.html
| ... | ... | @@ -19,8 +19,8 @@ |
| 19 | 19 | {% breadcrumb topic 'subjects:topic_view' topic.subject.slug topic.slug %} |
| 20 | 20 | |
| 21 | 21 | {% trans 'Edit: ' as bread %} |
| 22 | - {% with bread|add:webconference.name as bread_slug %} | |
| 23 | - {% breadcrumb bread_slug 'webconfrences:update' topic.slug webconference.slug %} | |
| 22 | + {% with bread|add:resource.name as bread_slug %} | |
| 23 | + {% breadcrumb bread_slug 'webconfrences:update' topic.slug resource.slug %} | |
| 24 | 24 | {% endwith %} |
| 25 | 25 | {% endblock %} |
| 26 | 26 | ... | ... |
webconference/views.py
| ... | ... | @@ -35,149 +35,149 @@ from .forms import WebconferenceForm, SettingsForm, InlinePendenciesFormset, Web |
| 35 | 35 | from .models import Webconference, ConferenceSettings as Settings |
| 36 | 36 | |
| 37 | 37 | class NewWindowView(LoginRequiredMixin,LogMixin, generic.DetailView): |
| 38 | - log_component = 'resources' | |
| 39 | - log_action = 'view' | |
| 40 | - log_resource = 'webconference' | |
| 41 | - log_context = {} | |
| 42 | - | |
| 43 | - login_url = reverse_lazy("users:login") | |
| 44 | - redirect_field_name = 'next' | |
| 45 | - | |
| 46 | - template_name = 'webconference/window_view.html' | |
| 47 | - model = Webconference | |
| 48 | - context_object_name = 'webconference' | |
| 49 | - | |
| 50 | - def dispatch(self, request, *args, **kwargs): | |
| 51 | - slug = self.kwargs.get('slug', '') | |
| 52 | - webconference = get_object_or_404(Webconference, slug = slug) | |
| 53 | - | |
| 54 | - if not has_resource_permissions(request.user, webconference): | |
| 55 | - return redirect(reverse_lazy('subjects:home')) | |
| 56 | - | |
| 57 | - return super(NewWindowView, self).dispatch(request, *args, **kwargs) | |
| 58 | - | |
| 59 | - def get_context_data(self, **kwargs): | |
| 60 | - context = super(NewWindowView, self).get_context_data(**kwargs) | |
| 61 | - context['title'] = _("%s - Web Conference")%(self.object.name) | |
| 62 | - self.log_context['category_id'] = self.object.topic.subject.category.id | |
| 63 | - self.log_context['category_name'] = self.object.topic.subject.category.name | |
| 64 | - self.log_context['category_slug'] = self.object.topic.subject.category.slug | |
| 65 | - self.log_context['subject_id'] = self.object.topic.subject.id | |
| 66 | - self.log_context['subject_name'] = self.object.topic.subject.name | |
| 67 | - self.log_context['subject_slug'] = self.object.topic.subject.slug | |
| 68 | - self.log_context['topic_id'] = self.object.topic.id | |
| 69 | - self.log_context['topic_name'] = self.object.topic.name | |
| 70 | - self.log_context['topic_slug'] = self.object.topic.slug | |
| 71 | - self.log_context['webconference_id'] = self.object.id | |
| 72 | - self.log_context['webconference_name'] = self.object.name | |
| 73 | - self.log_context['webconference_slug'] = self.object.slug | |
| 74 | - self.log_context['webconference_view'] = str(int(time.time())) | |
| 75 | - | |
| 76 | - super(NewWindowView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
| 77 | - | |
| 78 | - self.request.session['log_id'] = Log.objects.latest('id').id | |
| 79 | - | |
| 80 | - return context | |
| 38 | + log_component = 'resources' | |
| 39 | + log_action = 'view' | |
| 40 | + log_resource = 'webconference' | |
| 41 | + log_context = {} | |
| 42 | + | |
| 43 | + login_url = reverse_lazy("users:login") | |
| 44 | + redirect_field_name = 'next' | |
| 45 | + | |
| 46 | + template_name = 'webconference/window_view.html' | |
| 47 | + model = Webconference | |
| 48 | + context_object_name = 'webconference' | |
| 49 | + | |
| 50 | + def dispatch(self, request, *args, **kwargs): | |
| 51 | + slug = self.kwargs.get('slug', '') | |
| 52 | + webconference = get_object_or_404(Webconference, slug = slug) | |
| 53 | + | |
| 54 | + if not has_resource_permissions(request.user, webconference): | |
| 55 | + return redirect(reverse_lazy('subjects:home')) | |
| 56 | + | |
| 57 | + return super(NewWindowView, self).dispatch(request, *args, **kwargs) | |
| 58 | + | |
| 59 | + def get_context_data(self, **kwargs): | |
| 60 | + context = super(NewWindowView, self).get_context_data(**kwargs) | |
| 61 | + context['title'] = _("%s - Web Conference")%(self.object.name) | |
| 62 | + self.log_context['category_id'] = self.object.topic.subject.category.id | |
| 63 | + self.log_context['category_name'] = self.object.topic.subject.category.name | |
| 64 | + self.log_context['category_slug'] = self.object.topic.subject.category.slug | |
| 65 | + self.log_context['subject_id'] = self.object.topic.subject.id | |
| 66 | + self.log_context['subject_name'] = self.object.topic.subject.name | |
| 67 | + self.log_context['subject_slug'] = self.object.topic.subject.slug | |
| 68 | + self.log_context['topic_id'] = self.object.topic.id | |
| 69 | + self.log_context['topic_name'] = self.object.topic.name | |
| 70 | + self.log_context['topic_slug'] = self.object.topic.slug | |
| 71 | + self.log_context['webconference_id'] = self.object.id | |
| 72 | + self.log_context['webconference_name'] = self.object.name | |
| 73 | + self.log_context['webconference_slug'] = self.object.slug | |
| 74 | + self.log_context['webconference_view'] = str(int(time.time())) | |
| 75 | + | |
| 76 | + super(NewWindowView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
| 77 | + | |
| 78 | + self.request.session['log_id'] = Log.objects.latest('id').id | |
| 79 | + | |
| 80 | + return context | |
| 81 | 81 | |
| 82 | 82 | class Conference(LoginRequiredMixin,LogMixin,generic.TemplateView): |
| 83 | 83 | |
| 84 | - log_component = 'resources' | |
| 85 | - log_action = 'initwebconference' | |
| 86 | - log_resource = 'webconference' | |
| 87 | - log_context = {} | |
| 88 | - | |
| 89 | - login_url = reverse_lazy("users:login") | |
| 90 | - redirect_field_name = 'next' | |
| 91 | - | |
| 92 | - template_name = 'webconference/jitsi.html' | |
| 93 | - | |
| 94 | - def dispatch(self, request, *args, **kwargs): | |
| 95 | - slug = self.kwargs.get('slug', '') | |
| 96 | - conference = get_object_or_404(Webconference, slug = slug) | |
| 97 | - | |
| 98 | - if not has_resource_permissions(request.user, conference): | |
| 99 | - return redirect(reverse_lazy('subjects:home')) | |
| 100 | - | |
| 101 | - return super(Conference, self).dispatch(request, *args, **kwargs) | |
| 102 | - | |
| 103 | - def get_context_data(self, **kwargs): | |
| 104 | - context = super(Conference, self).get_context_data(**kwargs) | |
| 105 | - conference = get_object_or_404(Webconference, slug = kwargs.get('slug')) | |
| 106 | - context['title'] = _("%s - Web Conference")%(conference) | |
| 107 | - context['webconference'] = conference | |
| 108 | - context['topic'] = conference.topic | |
| 109 | - context['subject'] = conference.topic.subject | |
| 110 | - context['name_room'] = kwargs.get('slug') | |
| 111 | - context['user_image'] = 'http://localhost:8000'+str(self.request.user.image.url) | |
| 112 | - try: | |
| 113 | - context['domain'] = Settings.objects.last().domain | |
| 114 | - except AttributeError: | |
| 115 | - context['domain'] = 'meet.jit.si' | |
| 116 | - | |
| 117 | - | |
| 118 | - self.log_context['category_id'] = conference.topic.subject.category.id | |
| 119 | - self.log_context['category_name'] = conference.topic.subject.category.name | |
| 120 | - self.log_context['category_slug'] = conference.topic.subject.category.slug | |
| 121 | - self.log_context['subject_id'] = conference.topic.subject.id | |
| 122 | - self.log_context['subject_name'] = conference.topic.subject.name | |
| 123 | - self.log_context['subject_slug'] = conference.topic.subject.slug | |
| 124 | - self.log_context['topic_id'] = conference.topic.id | |
| 125 | - self.log_context['topic_name'] = conference.topic.name | |
| 126 | - self.log_context['topic_slug'] = conference.topic.slug | |
| 127 | - self.log_context['webconference_id'] = conference.id | |
| 128 | - self.log_context['webconference_name'] = conference.name | |
| 129 | - self.log_context['webconference_slug'] = conference.slug | |
| 130 | - self.log_context['webconference_init'] = str(int(time.time())) | |
| 131 | - | |
| 132 | - super(Conference, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
| 133 | - | |
| 134 | - return context | |
| 84 | + log_component = 'resources' | |
| 85 | + log_action = 'initwebconference' | |
| 86 | + log_resource = 'webconference' | |
| 87 | + log_context = {} | |
| 88 | + | |
| 89 | + login_url = reverse_lazy("users:login") | |
| 90 | + redirect_field_name = 'next' | |
| 91 | + | |
| 92 | + template_name = 'webconference/jitsi.html' | |
| 93 | + | |
| 94 | + def dispatch(self, request, *args, **kwargs): | |
| 95 | + slug = self.kwargs.get('slug', '') | |
| 96 | + conference = get_object_or_404(Webconference, slug = slug) | |
| 97 | + | |
| 98 | + if not has_resource_permissions(request.user, conference): | |
| 99 | + return redirect(reverse_lazy('subjects:home')) | |
| 100 | + | |
| 101 | + return super(Conference, self).dispatch(request, *args, **kwargs) | |
| 102 | + | |
| 103 | + def get_context_data(self, **kwargs): | |
| 104 | + context = super(Conference, self).get_context_data(**kwargs) | |
| 105 | + conference = get_object_or_404(Webconference, slug = kwargs.get('slug')) | |
| 106 | + context['title'] = _("%s - Web Conference")%(conference) | |
| 107 | + context['webconference'] = conference | |
| 108 | + context['topic'] = conference.topic | |
| 109 | + context['subject'] = conference.topic.subject | |
| 110 | + context['name_room'] = kwargs.get('slug') | |
| 111 | + context['user_image'] = 'http://localhost:8000'+str(self.request.user.image.url) | |
| 112 | + try: | |
| 113 | + context['domain'] = Settings.objects.last().domain | |
| 114 | + except AttributeError: | |
| 115 | + context['domain'] = 'meet.jit.si' | |
| 116 | + | |
| 117 | + | |
| 118 | + self.log_context['category_id'] = conference.topic.subject.category.id | |
| 119 | + self.log_context['category_name'] = conference.topic.subject.category.name | |
| 120 | + self.log_context['category_slug'] = conference.topic.subject.category.slug | |
| 121 | + self.log_context['subject_id'] = conference.topic.subject.id | |
| 122 | + self.log_context['subject_name'] = conference.topic.subject.name | |
| 123 | + self.log_context['subject_slug'] = conference.topic.subject.slug | |
| 124 | + self.log_context['topic_id'] = conference.topic.id | |
| 125 | + self.log_context['topic_name'] = conference.topic.name | |
| 126 | + self.log_context['topic_slug'] = conference.topic.slug | |
| 127 | + self.log_context['webconference_id'] = conference.id | |
| 128 | + self.log_context['webconference_name'] = conference.name | |
| 129 | + self.log_context['webconference_slug'] = conference.slug | |
| 130 | + self.log_context['webconference_init'] = str(int(time.time())) | |
| 131 | + | |
| 132 | + super(Conference, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
| 133 | + | |
| 134 | + return context | |
| 135 | 135 | |
| 136 | 136 | @log_decorator('resources', 'participating', 'webconference') |
| 137 | 137 | def participating(request): |
| 138 | - webconference = get_object_or_404(Webconference, slug = request.GET['slug']) | |
| 139 | - log_context = {} | |
| 140 | - log_context['category_id'] = webconference.topic.subject.category.id | |
| 141 | - log_context['category_name'] = webconference.topic.subject.category.name | |
| 142 | - log_context['category_slug'] = webconference.topic.subject.category.slug | |
| 143 | - log_context['subject_id'] = webconference.topic.subject.id | |
| 144 | - log_context['subject_name'] = webconference.topic.subject.name | |
| 145 | - log_context['subject_slug'] = webconference.topic.subject.slug | |
| 146 | - log_context['topic_id'] = webconference.topic.id | |
| 147 | - log_context['topic_name'] = webconference.topic.name | |
| 148 | - log_context['topic_slug'] = webconference.topic.slug | |
| 149 | - log_context['webconference_id'] = webconference.id | |
| 150 | - log_context['webconference_name'] = webconference.name | |
| 151 | - log_context['webconference_slug'] = webconference.slug | |
| 152 | - log_context['webconference_online'] = str(int(time.time())) | |
| 153 | - | |
| 154 | - request.log_context = log_context | |
| 155 | - | |
| 156 | - return JsonResponse({'message':'ok'}) | |
| 138 | + webconference = get_object_or_404(Webconference, slug = request.GET['slug']) | |
| 139 | + log_context = {} | |
| 140 | + log_context['category_id'] = webconference.topic.subject.category.id | |
| 141 | + log_context['category_name'] = webconference.topic.subject.category.name | |
| 142 | + log_context['category_slug'] = webconference.topic.subject.category.slug | |
| 143 | + log_context['subject_id'] = webconference.topic.subject.id | |
| 144 | + log_context['subject_name'] = webconference.topic.subject.name | |
| 145 | + log_context['subject_slug'] = webconference.topic.subject.slug | |
| 146 | + log_context['topic_id'] = webconference.topic.id | |
| 147 | + log_context['topic_name'] = webconference.topic.name | |
| 148 | + log_context['topic_slug'] = webconference.topic.slug | |
| 149 | + log_context['webconference_id'] = webconference.id | |
| 150 | + log_context['webconference_name'] = webconference.name | |
| 151 | + log_context['webconference_slug'] = webconference.slug | |
| 152 | + log_context['webconference_online'] = str(int(time.time())) | |
| 153 | + | |
| 154 | + request.log_context = log_context | |
| 155 | + | |
| 156 | + return JsonResponse({'message':'ok'}) | |
| 157 | 157 | |
| 158 | 158 | @log_decorator('resources', 'participate', 'webconference') |
| 159 | 159 | def finish(request): |
| 160 | 160 | |
| 161 | - webconference = get_object_or_404(Webconference, slug = request.GET['roomName']) | |
| 162 | - log_context = {} | |
| 163 | - log_context['category_id'] = webconference.topic.subject.category.id | |
| 164 | - log_context['category_name'] = webconference.topic.subject.category.name | |
| 165 | - log_context['category_slug'] = webconference.topic.subject.category.slug | |
| 166 | - log_context['subject_id'] = webconference.topic.subject.id | |
| 167 | - log_context['subject_name'] = webconference.topic.subject.name | |
| 168 | - log_context['subject_slug'] = webconference.topic.subject.slug | |
| 169 | - log_context['topic_id'] = webconference.topic.id | |
| 170 | - log_context['topic_name'] = webconference.topic.name | |
| 171 | - log_context['topic_slug'] = webconference.topic.slug | |
| 172 | - log_context['webconference_id'] = webconference.id | |
| 173 | - log_context['webconference_name'] = webconference.name | |
| 174 | - log_context['webconference_slug'] = webconference.slug | |
| 175 | - log_context['webconference_finish'] = str(int(time.time())) | |
| 176 | - | |
| 177 | - request.log_context = log_context | |
| 178 | - | |
| 179 | - url = {'url': str(reverse_lazy('webconferences:view', kwargs = {'slug': request.GET['roomName']}))} | |
| 180 | - return JsonResponse(url, safe=False) | |
| 161 | + webconference = get_object_or_404(Webconference, slug = request.GET['roomName']) | |
| 162 | + log_context = {} | |
| 163 | + log_context['category_id'] = webconference.topic.subject.category.id | |
| 164 | + log_context['category_name'] = webconference.topic.subject.category.name | |
| 165 | + log_context['category_slug'] = webconference.topic.subject.category.slug | |
| 166 | + log_context['subject_id'] = webconference.topic.subject.id | |
| 167 | + log_context['subject_name'] = webconference.topic.subject.name | |
| 168 | + log_context['subject_slug'] = webconference.topic.subject.slug | |
| 169 | + log_context['topic_id'] = webconference.topic.id | |
| 170 | + log_context['topic_name'] = webconference.topic.name | |
| 171 | + log_context['topic_slug'] = webconference.topic.slug | |
| 172 | + log_context['webconference_id'] = webconference.id | |
| 173 | + log_context['webconference_name'] = webconference.name | |
| 174 | + log_context['webconference_slug'] = webconference.slug | |
| 175 | + log_context['webconference_finish'] = str(int(time.time())) | |
| 176 | + | |
| 177 | + request.log_context = log_context | |
| 178 | + | |
| 179 | + url = {'url': str(reverse_lazy('webconferences:view', kwargs = {'slug': request.GET['roomName']}))} | |
| 180 | + return JsonResponse(url, safe=False) | |
| 181 | 181 | |
| 182 | 182 | |
| 183 | 183 | class InsideView(LoginRequiredMixin, LogMixin, generic.DetailView): |
| ... | ... | @@ -231,253 +231,254 @@ class InsideView(LoginRequiredMixin, LogMixin, generic.DetailView): |
| 231 | 231 | return context |
| 232 | 232 | |
| 233 | 233 | class CreateView(LoginRequiredMixin, LogMixin, generic.edit.CreateView): |
| 234 | - log_component = 'resources' | |
| 235 | - log_action = 'create' | |
| 236 | - log_resource = 'webconference' | |
| 237 | - log_context = {} | |
| 238 | - login_url = reverse_lazy("users:login") | |
| 239 | - redirect_field_name = 'next' | |
| 234 | + log_component = 'resources' | |
| 235 | + log_action = 'create' | |
| 236 | + log_resource = 'webconference' | |
| 237 | + log_context = {} | |
| 238 | + login_url = reverse_lazy("users:login") | |
| 239 | + redirect_field_name = 'next' | |
| 240 | 240 | |
| 241 | - template_name = 'webconference/create.html' | |
| 242 | - form_class = WebconferenceForm | |
| 241 | + template_name = 'webconference/create.html' | |
| 242 | + form_class = WebconferenceForm | |
| 243 | 243 | |
| 244 | - def dispatch(self, request, *args, **kwargs): | |
| 245 | - slug = self.kwargs.get('slug', '') | |
| 246 | - topic = get_object_or_404(Topic, slug = slug) | |
| 244 | + def dispatch(self, request, *args, **kwargs): | |
| 245 | + slug = self.kwargs.get('slug', '') | |
| 246 | + topic = get_object_or_404(Topic, slug = slug) | |
| 247 | 247 | |
| 248 | - if not has_subject_permissions(request.user, topic.subject): | |
| 249 | - return redirect(reverse_lazy('subjects:home')) | |
| 250 | - return super(CreateView, self).dispatch(request, *args, **kwargs) | |
| 248 | + if not has_subject_permissions(request.user, topic.subject): | |
| 249 | + return redirect(reverse_lazy('subjects:home')) | |
| 250 | + return super(CreateView, self).dispatch(request, *args, **kwargs) | |
| 251 | 251 | |
| 252 | - def get(self, request, *args, **kwargs): | |
| 253 | - self.object = None | |
| 252 | + def get(self, request, *args, **kwargs): | |
| 253 | + self.object = None | |
| 254 | 254 | |
| 255 | - form_class = self.get_form_class() | |
| 256 | - form = self.get_form(form_class) | |
| 255 | + form_class = self.get_form_class() | |
| 256 | + form = self.get_form(form_class) | |
| 257 | 257 | |
| 258 | - slug = self.kwargs.get('slug', '') | |
| 259 | - topic = get_object_or_404(Topic, slug = slug) | |
| 260 | - pendencies_form = InlinePendenciesFormset(initial = [{'subject': topic.subject.id, 'actions': [("", "-------"),("view", _("Visualize")), ("participate", _("Participate"))]}]) | |
| 261 | - print (pendencies_form) | |
| 262 | - return self.render_to_response(self.get_context_data(form = form, pendencies_form = pendencies_form)) | |
| 258 | + slug = self.kwargs.get('slug', '') | |
| 259 | + topic = get_object_or_404(Topic, slug = slug) | |
| 260 | + pendencies_form = InlinePendenciesFormset(initial = [{'subject': topic.subject.id, 'actions': [("", "-------"),("view", _("Visualize")), ("participate", _("Participate"))]}]) | |
| 261 | + print (pendencies_form) | |
| 262 | + return self.render_to_response(self.get_context_data(form = form, pendencies_form = pendencies_form)) | |
| 263 | 263 | |
| 264 | - def post(self, request, *args, **kwargs): | |
| 265 | - self.object = None | |
| 264 | + def post(self, request, *args, **kwargs): | |
| 265 | + self.object = None | |
| 266 | 266 | |
| 267 | - form_class = self.get_form_class() | |
| 268 | - form = self.get_form(form_class) | |
| 267 | + form_class = self.get_form_class() | |
| 268 | + form = self.get_form(form_class) | |
| 269 | 269 | |
| 270 | - slug = self.kwargs.get('slug', '') | |
| 271 | - topic = get_object_or_404(Topic, slug = slug) | |
| 270 | + slug = self.kwargs.get('slug', '') | |
| 271 | + topic = get_object_or_404(Topic, slug = slug) | |
| 272 | 272 | |
| 273 | - pendencies_form = InlinePendenciesFormset(self.request.POST, initial = [{'subject': topic.subject.id, 'actions': [("", "-------"),("view", _("Visualize")), ("participate", _("Participate"))]}]) | |
| 273 | + pendencies_form = InlinePendenciesFormset(self.request.POST, initial = [{'subject': topic.subject.id, 'actions': [("", "-------"),("view", _("Visualize")), ("participate", _("Participate"))]}]) | |
| 274 | 274 | |
| 275 | - if (form.is_valid() and pendencies_form.is_valid()): | |
| 276 | - return self.form_valid(form, pendencies_form) | |
| 277 | - else: | |
| 278 | - return self.form_invalid(form, pendencies_form) | |
| 275 | + if (form.is_valid() and pendencies_form.is_valid()): | |
| 276 | + return self.form_valid(form, pendencies_form) | |
| 277 | + else: | |
| 278 | + return self.form_invalid(form, pendencies_form) | |
| 279 | 279 | |
| 280 | - def get_initial(self): | |
| 281 | - initial = super(CreateView, self).get_initial() | |
| 280 | + def get_initial(self): | |
| 281 | + initial = super(CreateView, self).get_initial() | |
| 282 | 282 | |
| 283 | - slug = self.kwargs.get('slug', '') | |
| 283 | + slug = self.kwargs.get('slug', '') | |
| 284 | 284 | |
| 285 | - topic = get_object_or_404(Topic, slug = slug) | |
| 286 | - initial['subject'] = topic.subject | |
| 285 | + topic = get_object_or_404(Topic, slug = slug) | |
| 286 | + initial['subject'] = topic.subject | |
| 287 | 287 | |
| 288 | - return initial | |
| 288 | + return initial | |
| 289 | 289 | |
| 290 | - def form_invalid(self, form, pendencies_form): | |
| 291 | - # print (form," Form") | |
| 292 | - # print (pendencies_form, " Penden") | |
| 293 | - for p_form in pendencies_form.forms: | |
| 294 | - p_form.fields['action'].choices = [("", "-------"),("view", _("Visualize")), ("participate", _("Participate"))] | |
| 295 | - print ("Invalid") | |
| 296 | - return self.render_to_response(self.get_context_data(form = form, pendencies_form = pendencies_form)) | |
| 290 | + def form_invalid(self, form, pendencies_form): | |
| 291 | + # print (form," Form") | |
| 292 | + # print (pendencies_form, " Penden") | |
| 293 | + for p_form in pendencies_form.forms: | |
| 294 | + p_form.fields['action'].choices = [("", "-------"),("view", _("Visualize")), ("participate", _("Participate"))] | |
| 295 | + print ("Invalid") | |
| 296 | + return self.render_to_response(self.get_context_data(form = form, pendencies_form = pendencies_form)) | |
| 297 | 297 | |
| 298 | - def form_valid(self, form, pendencies_form): | |
| 298 | + def form_valid(self, form, pendencies_form): | |
| 299 | 299 | |
| 300 | - self.object = form.save(commit = False) | |
| 301 | - slug = self.kwargs.get('slug', '') | |
| 302 | - topic = get_object_or_404(Topic, slug = slug) | |
| 300 | + self.object = form.save(commit = False) | |
| 301 | + slug = self.kwargs.get('slug', '') | |
| 302 | + topic = get_object_or_404(Topic, slug = slug) | |
| 303 | 303 | |
| 304 | - self.object.topic = topic | |
| 305 | - self.object.order = topic.resource_topic.count() + 1 | |
| 304 | + self.object.topic = topic | |
| 305 | + self.object.order = topic.resource_topic.count() + 1 | |
| 306 | 306 | |
| 307 | - if not self.object.topic.visible and not self.object.topic.repository: | |
| 308 | - self.object.visible = False | |
| 307 | + if not self.object.topic.visible and not self.object.topic.repository: | |
| 308 | + self.object.visible = False | |
| 309 | 309 | |
| 310 | - self.object.save() | |
| 311 | - pendencies_form.instance = self.object | |
| 312 | - pendencies_form.save(commit = False) | |
| 310 | + self.object.save() | |
| 311 | + pendencies_form.instance = self.object | |
| 312 | + pendencies_form.save(commit = False) | |
| 313 | 313 | |
| 314 | - for pform in pendencies_form.forms: | |
| 315 | - pend_form = pform.save(commit = False) | |
| 314 | + for pform in pendencies_form.forms: | |
| 315 | + pend_form = pform.save(commit = False) | |
| 316 | 316 | |
| 317 | - if not pend_form.action == "": | |
| 318 | - pend_form.save() | |
| 319 | - print ("Valid") | |
| 320 | - self.log_context['category_id'] = self.object.topic.subject.category.id | |
| 321 | - self.log_context['category_name'] = self.object.topic.subject.category.name | |
| 322 | - self.log_context['category_slug'] = self.object.topic.subject.category.slug | |
| 323 | - self.log_context['subject_id'] = self.object.topic.subject.id | |
| 324 | - self.log_context['subject_name'] = self.object.topic.subject.name | |
| 325 | - self.log_context['subject_slug'] = self.object.topic.subject.slug | |
| 326 | - self.log_context['topic_id'] = self.object.topic.id | |
| 327 | - self.log_context['topic_name'] = self.object.topic.name | |
| 328 | - self.log_context['topic_slug'] = self.object.topic.slug | |
| 329 | - self.log_context['webconference_id'] = self.object.id | |
| 330 | - self.log_context['webconference_name'] = self.object.name | |
| 331 | - self.log_context['webconference_slug'] = self.object.slug | |
| 317 | + if not pend_form.action == "": | |
| 318 | + pend_form.save() | |
| 319 | + print ("Valid") | |
| 320 | + self.log_context['category_id'] = self.object.topic.subject.category.id | |
| 321 | + self.log_context['category_name'] = self.object.topic.subject.category.name | |
| 322 | + self.log_context['category_slug'] = self.object.topic.subject.category.slug | |
| 323 | + self.log_context['subject_id'] = self.object.topic.subject.id | |
| 324 | + self.log_context['subject_name'] = self.object.topic.subject.name | |
| 325 | + self.log_context['subject_slug'] = self.object.topic.subject.slug | |
| 326 | + self.log_context['topic_id'] = self.object.topic.id | |
| 327 | + self.log_context['topic_name'] = self.object.topic.name | |
| 328 | + self.log_context['topic_slug'] = self.object.topic.slug | |
| 329 | + self.log_context['webconference_id'] = self.object.id | |
| 330 | + self.log_context['webconference_name'] = self.object.name | |
| 331 | + self.log_context['webconference_slug'] = self.object.slug | |
| 332 | 332 | |
| 333 | - super(CreateView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
| 333 | + super(CreateView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
| 334 | 334 | |
| 335 | - return redirect(self.get_success_url()) | |
| 335 | + return redirect(self.get_success_url()) | |
| 336 | 336 | |
| 337 | - def get_context_data(self, **kwargs): | |
| 338 | - context = super(CreateView, self).get_context_data(**kwargs) | |
| 337 | + def get_context_data(self, **kwargs): | |
| 338 | + context = super(CreateView, self).get_context_data(**kwargs) | |
| 339 | 339 | |
| 340 | - context['title'] = _('Create Web Conference') | |
| 340 | + context['title'] = _('Create Web Conference') | |
| 341 | 341 | |
| 342 | - slug = self.kwargs.get('slug', '') | |
| 343 | - topic = get_object_or_404(Topic, slug = slug) | |
| 342 | + slug = self.kwargs.get('slug', '') | |
| 343 | + topic = get_object_or_404(Topic, slug = slug) | |
| 344 | 344 | |
| 345 | - context['topic'] = topic | |
| 346 | - context['subject'] = topic.subject | |
| 345 | + context['topic'] = topic | |
| 346 | + context['subject'] = topic.subject | |
| 347 | 347 | |
| 348 | - return context | |
| 348 | + return context | |
| 349 | 349 | |
| 350 | - def get_success_url(self): | |
| 351 | - messages.success(self.request, _('The Web conference "%s" was added to the Topic "%s" of the virtual environment "%s" successfully!')%(self.object.name, self.object.topic.name, self.object.topic.subject.name)) | |
| 350 | + def get_success_url(self): | |
| 351 | + messages.success(self.request, _('The Web conference "%s" was added to the Topic "%s" of the virtual environment "%s" successfully!')%(self.object.name, self.object.topic.name, self.object.topic.subject.name)) | |
| 352 | 352 | |
| 353 | - success_url = reverse_lazy('webconferences:view', kwargs = {'slug': self.object.slug}) | |
| 353 | + success_url = reverse_lazy('webconferences:view', kwargs = {'slug': self.object.slug}) | |
| 354 | 354 | |
| 355 | - if self.object.show_window: | |
| 356 | - self.request.session['resources'] = {} | |
| 357 | - self.request.session['resources']['new_page'] = True | |
| 358 | - self.request.session['resources']['new_page_url'] = reverse('webconferences:window_view', kwargs = {'slug': self.object.slug}) | |
| 355 | + if self.object.show_window: | |
| 356 | + self.request.session['resources'] = {} | |
| 357 | + self.request.session['resources']['new_page'] = True | |
| 358 | + self.request.session['resources']['new_page_url'] = reverse('webconferences:window_view', kwargs = {'slug': self.object.slug}) | |
| 359 | 359 | |
| 360 | - success_url = reverse_lazy('subjects:view', kwargs = {'slug': self.object.topic.subject.slug}) | |
| 360 | + success_url = reverse_lazy('subjects:view', kwargs = {'slug': self.object.topic.subject.slug}) | |
| 361 | 361 | |
| 362 | - return success_url | |
| 362 | + return success_url | |
| 363 | 363 | |
| 364 | 364 | class UpdateView(LoginRequiredMixin, LogMixin, generic.UpdateView): |
| 365 | - log_component = 'resources' | |
| 366 | - log_action = 'update' | |
| 367 | - log_resource = 'webconference' | |
| 368 | - log_context = {} | |
| 365 | + log_component = 'resources' | |
| 366 | + log_action = 'update' | |
| 367 | + log_resource = 'webconference' | |
| 368 | + log_context = {} | |
| 369 | 369 | |
| 370 | - login_url = reverse_lazy("users:login") | |
| 371 | - redirect_field_name = 'next' | |
| 370 | + login_url = reverse_lazy("users:login") | |
| 371 | + redirect_field_name = 'next' | |
| 372 | 372 | |
| 373 | - template_name = 'webconference/update.html' | |
| 374 | - model = Webconference | |
| 375 | - form_class = WebConferenceUpdateForm | |
| 373 | + template_name = 'webconference/update.html' | |
| 374 | + model = Webconference | |
| 375 | + form_class = WebConferenceUpdateForm | |
| 376 | 376 | |
| 377 | - def dispatch(self, request, *args, **kwargs): | |
| 378 | - slug = self.kwargs.get('topic_slug', '') | |
| 379 | - topic = get_object_or_404(Topic, slug = slug) | |
| 377 | + def dispatch(self, request, *args, **kwargs): | |
| 378 | + slug = self.kwargs.get('topic_slug', '') | |
| 379 | + topic = get_object_or_404(Topic, slug = slug) | |
| 380 | 380 | |
| 381 | - if not has_subject_permissions(request.user, topic.subject): | |
| 382 | - return redirect(reverse_lazy('subjects:home')) | |
| 381 | + if not has_subject_permissions(request.user, topic.subject): | |
| 382 | + return redirect(reverse_lazy('subjects:home')) | |
| 383 | 383 | |
| 384 | - return super(UpdateView, self).dispatch(request, *args, **kwargs) | |
| 384 | + return super(UpdateView, self).dispatch(request, *args, **kwargs) | |
| 385 | 385 | |
| 386 | - def get(self, request, *args, **kwargs): | |
| 387 | - self.object = self.get_object() | |
| 386 | + def get(self, request, *args, **kwargs): | |
| 387 | + self.object = self.get_object() | |
| 388 | 388 | |
| 389 | - form_class = self.get_form_class() | |
| 390 | - form = self.get_form(form_class) | |
| 389 | + form_class = self.get_form_class() | |
| 390 | + form = self.get_form(form_class) | |
| 391 | 391 | |
| 392 | - slug = self.kwargs.get('topic_slug', '') | |
| 393 | - topic = get_object_or_404(Topic, slug = slug) | |
| 392 | + slug = self.kwargs.get('topic_slug', '') | |
| 393 | + topic = get_object_or_404(Topic, slug = slug) | |
| 394 | 394 | |
| 395 | - pendencies_form = InlinePendenciesFormset(instance=self.object, initial = [{'subject': topic.subject.id, 'actions': [("", "-------"),("view", _("Visualize")), ("participate", _("Participate"))]}]) | |
| 395 | + pendencies_form = InlinePendenciesFormset(instance=self.object, initial = [{'subject': topic.subject.id, 'actions': [("", "-------"),("view", _("Visualize")), ("participate", _("Participate"))]}]) | |
| 396 | 396 | |
| 397 | - return self.render_to_response(self.get_context_data(form = form, pendencies_form = pendencies_form)) | |
| 397 | + return self.render_to_response(self.get_context_data(form = form, pendencies_form = pendencies_form)) | |
| 398 | 398 | |
| 399 | - def post(self, request, *args, **kwargs): | |
| 400 | - self.object = self.get_object() | |
| 399 | + def post(self, request, *args, **kwargs): | |
| 400 | + self.object = self.get_object() | |
| 401 | 401 | |
| 402 | - form_class = self.get_form_class() | |
| 403 | - form = self.get_form(form_class) | |
| 402 | + form_class = self.get_form_class() | |
| 403 | + form = self.get_form(form_class) | |
| 404 | 404 | |
| 405 | - slug = self.kwargs.get('topic_slug', '') | |
| 406 | - topic = get_object_or_404(Topic, slug = slug) | |
| 405 | + slug = self.kwargs.get('topic_slug', '') | |
| 406 | + topic = get_object_or_404(Topic, slug = slug) | |
| 407 | 407 | |
| 408 | - pendencies_form = InlinePendenciesFormset(self.request.POST, instance = self.object, initial = [{'subject': topic.subject.id, 'actions': [("", "-------"),("view", _("Visualize")), ("participate", _("Participate"))]}]) | |
| 408 | + pendencies_form = InlinePendenciesFormset(self.request.POST, instance = self.object, initial = [{'subject': topic.subject.id, 'actions': [("", "-------"),("view", _("Visualize")), ("participate", _("Participate"))]}]) | |
| 409 | 409 | |
| 410 | - if (form.is_valid() and pendencies_form.is_valid()): | |
| 411 | - return self.form_valid(form, pendencies_form) | |
| 412 | - else: | |
| 413 | - return self.form_invalid(form, pendencies_form) | |
| 410 | + if (form.is_valid() and pendencies_form.is_valid()): | |
| 411 | + return self.form_valid(form, pendencies_form) | |
| 412 | + else: | |
| 413 | + return self.form_invalid(form, pendencies_form) | |
| 414 | 414 | |
| 415 | - def form_invalid(self, form, pendencies_form): | |
| 416 | - for p_form in pendencies_form.forms: | |
| 417 | - p_form.fields['action'].choices = [("", "-------"),("view", _("Visualize")), ("participate", _("Participate"))] | |
| 415 | + def form_invalid(self, form, pendencies_form): | |
| 416 | + for p_form in pendencies_form.forms: | |
| 417 | + p_form.fields['action'].choices = [("", "-------"),("view", _("Visualize")), ("participate", _("Participate"))] | |
| 418 | 418 | |
| 419 | - return self.render_to_response(self.get_context_data(form = form, pendencies_form = pendencies_form)) | |
| 419 | + return self.render_to_response(self.get_context_data(form = form, pendencies_form = pendencies_form)) | |
| 420 | 420 | |
| 421 | - def form_valid(self, form, pendencies_form): | |
| 422 | - self.object = form.save(commit = False) | |
| 421 | + def form_valid(self, form, pendencies_form): | |
| 422 | + self.object = form.save(commit = False) | |
| 423 | 423 | |
| 424 | - if not self.object.topic.visible and not self.object.topic.repository: | |
| 425 | - self.object.visible = False | |
| 424 | + if not self.object.topic.visible and not self.object.topic.repository: | |
| 425 | + self.object.visible = False | |
| 426 | 426 | |
| 427 | - self.object.save() | |
| 427 | + self.object.save() | |
| 428 | 428 | |
| 429 | - pendencies_form.instance = self.object | |
| 430 | - pendencies_form.save(commit = False) | |
| 429 | + pendencies_form.instance = self.object | |
| 430 | + pendencies_form.save(commit = False) | |
| 431 | 431 | |
| 432 | - for form in pendencies_form.forms: | |
| 433 | - pend_form = form.save(commit = False) | |
| 432 | + for form in pendencies_form.forms: | |
| 433 | + pend_form = form.save(commit = False) | |
| 434 | 434 | |
| 435 | - if not pend_form.action == "": | |
| 436 | - pend_form.save() | |
| 435 | + if not pend_form.action == "": | |
| 436 | + pend_form.save() | |
| 437 | 437 | |
| 438 | - self.log_context['category_id'] = self.object.topic.subject.category.id | |
| 439 | - self.log_context['category_name'] = self.object.topic.subject.category.name | |
| 440 | - self.log_context['category_slug'] = self.object.topic.subject.category.slug | |
| 441 | - self.log_context['subject_id'] = self.object.topic.subject.id | |
| 442 | - self.log_context['subject_name'] = self.object.topic.subject.name | |
| 443 | - self.log_context['subject_slug'] = self.object.topic.subject.slug | |
| 444 | - self.log_context['topic_id'] = self.object.topic.id | |
| 445 | - self.log_context['topic_name'] = self.object.topic.name | |
| 446 | - self.log_context['topic_slug'] = self.object.topic.slug | |
| 447 | - self.log_context['webconference_id'] = self.object.id | |
| 448 | - self.log_context['webconference_name'] = self.object.name | |
| 449 | - self.log_context['webconference_slug'] = self.object.slug | |
| 438 | + self.log_context['category_id'] = self.object.topic.subject.category.id | |
| 439 | + self.log_context['category_name'] = self.object.topic.subject.category.name | |
| 440 | + self.log_context['category_slug'] = self.object.topic.subject.category.slug | |
| 441 | + self.log_context['subject_id'] = self.object.topic.subject.id | |
| 442 | + self.log_context['subject_name'] = self.object.topic.subject.name | |
| 443 | + self.log_context['subject_slug'] = self.object.topic.subject.slug | |
| 444 | + self.log_context['topic_id'] = self.object.topic.id | |
| 445 | + self.log_context['topic_name'] = self.object.topic.name | |
| 446 | + self.log_context['topic_slug'] = self.object.topic.slug | |
| 447 | + self.log_context['webconference_id'] = self.object.id | |
| 448 | + self.log_context['webconference_name'] = self.object.name | |
| 449 | + self.log_context['webconference_slug'] = self.object.slug | |
| 450 | 450 | |
| 451 | - super(UpdateView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
| 451 | + super(UpdateView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
| 452 | 452 | |
| 453 | - return redirect(self.get_success_url()) | |
| 453 | + return redirect(self.get_success_url()) | |
| 454 | 454 | |
| 455 | - def get_context_data(self, **kwargs): | |
| 456 | - context = super(UpdateView, self).get_context_data(**kwargs) | |
| 455 | + def get_context_data(self, **kwargs): | |
| 456 | + context = super(UpdateView, self).get_context_data(**kwargs) | |
| 457 | 457 | |
| 458 | - context['title'] = _('Update Web Conference') | |
| 458 | + context['title'] = _('Update Web Conference') | |
| 459 | 459 | |
| 460 | - slug = self.kwargs.get('topic_slug', '') | |
| 461 | - topic = get_object_or_404(Topic, slug = slug) | |
| 460 | + slug = self.kwargs.get('topic_slug', '') | |
| 461 | + topic = get_object_or_404(Topic, slug = slug) | |
| 462 | 462 | |
| 463 | - context['topic'] = topic | |
| 464 | - context['subject'] = topic.subject | |
| 463 | + context['topic'] = topic | |
| 464 | + context['subject'] = topic.subject | |
| 465 | + context['resource'] = get_object_or_404(Webconference, slug = self.kwargs.get('slug', '')) | |
| 465 | 466 | |
| 466 | - return context | |
| 467 | + return context | |
| 467 | 468 | |
| 468 | - def get_success_url(self): | |
| 469 | - messages.success(self.request, _('The Web conference "%s" was updated successfully!')%(self.object.name)) | |
| 469 | + def get_success_url(self): | |
| 470 | + messages.success(self.request, _('The Web conference "%s" was updated successfully!')%(self.object.name)) | |
| 470 | 471 | |
| 471 | - success_url = reverse_lazy('webconferences:view', kwargs = {'slug': self.object.slug}) | |
| 472 | + success_url = reverse_lazy('webconferences:view', kwargs = {'slug': self.object.slug}) | |
| 472 | 473 | |
| 473 | - if self.object.show_window: | |
| 474 | - self.request.session['resources'] = {} | |
| 475 | - self.request.session['resources']['new_page'] = True | |
| 476 | - self.request.session['resources']['new_page_url'] = reverse('webconferences:window_view', kwargs = {'slug': self.object.slug}) | |
| 474 | + if self.object.show_window: | |
| 475 | + self.request.session['resources'] = {} | |
| 476 | + self.request.session['resources']['new_page'] = True | |
| 477 | + self.request.session['resources']['new_page_url'] = reverse('webconferences:window_view', kwargs = {'slug': self.object.slug}) | |
| 477 | 478 | |
| 478 | - success_url = reverse_lazy('subjects:view', kwargs = {'slug': self.object.topic.subject.slug}) | |
| 479 | + success_url = reverse_lazy('subjects:view', kwargs = {'slug': self.object.topic.subject.slug}) | |
| 479 | 480 | |
| 480 | - return success_url | |
| 481 | + return success_url | |
| 481 | 482 | |
| 482 | 483 | class DeleteView(LoginRequiredMixin, LogMixin, generic.DeleteView): |
| 483 | 484 | log_component = 'resources' |
| ... | ... | @@ -522,216 +523,216 @@ class DeleteView(LoginRequiredMixin, LogMixin, generic.DeleteView): |
| 522 | 523 | return reverse_lazy('subjects:view', kwargs = {'slug': self.object.topic.subject.slug}) |
| 523 | 524 | |
| 524 | 525 | class ConferenceSettings(braces_mixins.LoginRequiredMixin, braces_mixins.StaffuserRequiredMixin, generic.UpdateView): |
| 525 | - login_url = reverse_lazy("users:login") | |
| 526 | - redirect_field_name = 'next' | |
| 526 | + login_url = reverse_lazy("users:login") | |
| 527 | + redirect_field_name = 'next' | |
| 527 | 528 | |
| 528 | - template_name = 'webconference/config.html' | |
| 529 | - model = Settings | |
| 530 | - form_class = SettingsForm | |
| 531 | - success_url = reverse_lazy("subjects:home") | |
| 529 | + template_name = 'webconference/config.html' | |
| 530 | + model = Settings | |
| 531 | + form_class = SettingsForm | |
| 532 | + success_url = reverse_lazy("subjects:home") | |
| 532 | 533 | |
| 533 | - def get_object(self, queryset = None): | |
| 534 | - return Settings.objects.last() | |
| 534 | + def get_object(self, queryset = None): | |
| 535 | + return Settings.objects.last() | |
| 535 | 536 | |
| 536 | - def form_valid(self, form): | |
| 537 | - form.save() | |
| 537 | + def form_valid(self, form): | |
| 538 | + form.save() | |
| 538 | 539 | |
| 539 | - messages.success(self.request, _("Conference settings updated successfully!")) | |
| 540 | + messages.success(self.request, _("Conference settings updated successfully!")) | |
| 540 | 541 | |
| 541 | - return super(ConferenceSettings, self).form_valid(form) | |
| 542 | + return super(ConferenceSettings, self).form_valid(form) | |
| 542 | 543 | |
| 543 | - def get_context_data(self, **kwargs): | |
| 544 | - context = super(ConferenceSettings, self).get_context_data(**kwargs) | |
| 544 | + def get_context_data(self, **kwargs): | |
| 545 | + context = super(ConferenceSettings, self).get_context_data(**kwargs) | |
| 545 | 546 | |
| 546 | - context['title'] = _('Web Conference Settings') | |
| 547 | + context['title'] = _('Web Conference Settings') | |
| 547 | 548 | |
| 548 | - return context | |
| 549 | + return context | |
| 549 | 550 | |
| 550 | 551 | class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView): |
| 551 | - log_component = 'resources' | |
| 552 | - log_action = 'view_statistics' | |
| 553 | - log_resource = 'webconference' | |
| 554 | - log_context = {} | |
| 555 | - | |
| 556 | - login_url = reverse_lazy("users:login") | |
| 557 | - redirect_field_name = 'next' | |
| 558 | - model = Webconference | |
| 559 | - template_name = 'webconference/relatorios.html' | |
| 560 | - | |
| 561 | - def dispatch(self, request, *args, **kwargs): | |
| 562 | - slug = self.kwargs.get('slug', '') | |
| 563 | - webconference = get_object_or_404(Webconference, slug = slug) | |
| 564 | - | |
| 565 | - if not has_subject_permissions(request.user, webconference.topic.subject): | |
| 566 | - return redirect(reverse_lazy('subjects:home')) | |
| 567 | - | |
| 568 | - return super(StatisticsView, self).dispatch(request, *args, **kwargs) | |
| 569 | - | |
| 570 | - def get_context_data(self, **kwargs): | |
| 571 | - context = super(StatisticsView, self).get_context_data(**kwargs) | |
| 572 | - | |
| 573 | - self.log_context['category_id'] = self.object.topic.subject.category.id | |
| 574 | - self.log_context['category_name'] = self.object.topic.subject.category.name | |
| 575 | - self.log_context['category_slug'] = self.object.topic.subject.category.slug | |
| 576 | - self.log_context['subject_id'] = self.object.topic.subject.id | |
| 577 | - self.log_context['subject_name'] = self.object.topic.subject.name | |
| 578 | - self.log_context['subject_slug'] = self.object.topic.subject.slug | |
| 579 | - self.log_context['topic_id'] = self.object.topic.id | |
| 580 | - self.log_context['topic_name'] = self.object.topic.name | |
| 581 | - self.log_context['topic_slug'] = self.object.topic.slug | |
| 582 | - self.log_context['webconference_id'] = self.object.id | |
| 583 | - self.log_context['webconference_name'] = self.object.name | |
| 584 | - self.log_context['webconference_slug'] = self.object.slug | |
| 585 | - | |
| 586 | - super(StatisticsView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
| 587 | - | |
| 588 | - | |
| 589 | - context['title'] = _('Youtube Video Reports') | |
| 590 | - | |
| 591 | - slug = self.kwargs.get('slug') | |
| 592 | - webconference = get_object_or_404(Webconference, slug = slug) | |
| 593 | - | |
| 594 | - date_format = "%d/%m/%Y %H:%M" if self.request.GET.get('language','') == 'pt-br' else "%m/%d/%Y %I:%M %p" | |
| 595 | - if self.request.GET.get('language','') == "": | |
| 596 | - start_date = datetime.datetime.now() - datetime.timedelta(30) | |
| 597 | - end_date = datetime.datetime.now() | |
| 598 | - else : | |
| 599 | - start_date = datetime.datetime.strptime(self.request.GET.get('init_date',''),date_format) | |
| 600 | - end_date = datetime.datetime.strptime(self.request.GET.get('end_date',''),date_format) | |
| 601 | - context["init_date"] = start_date | |
| 602 | - context["end_date"] = end_date | |
| 603 | - alunos = webconference.students.all() | |
| 604 | - if webconference.all_students : | |
| 605 | - alunos = webconference.topic.subject.students.all() | |
| 606 | - | |
| 607 | - vis_ou = Log.objects.filter(context__contains={'webconference_id':webconference.id},resource="webconference",user_email__in=(aluno.email for aluno in alunos), datetime__range=(start_date,end_date + datetime.timedelta(minutes = 1))).filter(Q(action="view") | Q(action="initwebconference") | Q(action="participating")) | |
| 608 | - did,n_did,history = str(_("Realized")),str(_("Unrealized")),str(_("Historic")) | |
| 609 | - re = [] | |
| 610 | - data_n_did,data_history = [],[] | |
| 611 | - json_n_did, json_history = {},{} | |
| 612 | - | |
| 613 | - for log_al in vis_ou.order_by("datetime"): | |
| 614 | - data_history.append([str(alunos.get(email=log_al.user_email)), | |
| 615 | - ", ".join([str(x) for x in webconference.topic.subject.group_subject.filter(participants__email=log_al.user_email)]), | |
| 616 | - log_al.action,log_al.datetime]) | |
| 617 | - | |
| 618 | - json_history["data"] = data_history | |
| 619 | - | |
| 620 | - column_view,column_initwebconference,column_participate = str(_('View')),str(_('Enter')),str(_('Participate')) | |
| 621 | - | |
| 622 | - not_view = alunos.exclude(email__in=[log.user_email for log in vis_ou.filter(action="view").distinct("user_email")]) | |
| 623 | - index = 0 | |
| 624 | - for alun in not_view: | |
| 625 | - data_n_did.append([index,str(alun),", ".join([str(x) for x in webconference.topic.subject.group_subject.filter(participants__email=alun.email)]),column_view, str(alun.email)]) | |
| 626 | - index += 1 | |
| 627 | - | |
| 628 | - not_initwebconference = alunos.exclude(email__in=[log.user_email for log in vis_ou.filter(action="initwebconference").distinct("user_email")]) | |
| 629 | - for alun in not_initwebconference: | |
| 630 | - data_n_did.append([index,str(alun),", ".join([str(x) for x in webconference.topic.subject.group_subject.filter(participants__email=alun.email)]),column_initwebconference, str(alun.email)]) | |
| 631 | - index += 1 | |
| 632 | - | |
| 633 | - not_participate = alunos.exclude(email__in=[log.user_email for log in vis_ou.filter(action="participating").distinct("user_email")]) | |
| 634 | - for alun in not_participate: | |
| 635 | - data_n_did.append([index,str(alun),", ".join([str(x) for x in webconference.topic.subject.group_subject.filter(participants__email=alun.email)]),column_participate, str(alun.email)]) | |
| 636 | - index += 1 | |
| 637 | - | |
| 638 | - json_n_did["data"] = data_n_did | |
| 639 | - | |
| 640 | - | |
| 641 | - context["json_n_did"] = json_n_did | |
| 642 | - context["json_history"] = json_history | |
| 643 | - c_visualizou = vis_ou.filter(action="view").distinct("user_email").count() | |
| 644 | - c_initwebconference = vis_ou.filter(action="initwebconference").distinct("user_email").count() | |
| 645 | - c_participate = vis_ou.filter(action="participating").distinct("user_email").count() | |
| 646 | - re.append([str(_('Webconference')),did,n_did]) | |
| 647 | - | |
| 648 | - re.append([column_view,c_visualizou, alunos.count() - c_visualizou]) | |
| 649 | - re.append([column_initwebconference,c_initwebconference, alunos.count() - c_initwebconference]) | |
| 650 | - re.append([column_participate,c_participate, alunos.count() - c_participate]) | |
| 651 | - | |
| 652 | - context['view'] = column_view | |
| 653 | - context['initwebconference'] = column_initwebconference | |
| 654 | - context['participate'] = column_participate | |
| 655 | - context['topic'] = webconference.topic | |
| 656 | - context['subject'] = webconference.topic.subject | |
| 657 | - context['webconference'] = webconference | |
| 658 | - context['db_data'] = re | |
| 659 | - context['title_chart'] = _('Actions about resource') | |
| 660 | - context['title_vAxis'] = _('Quantity') | |
| 661 | - | |
| 662 | - context["n_did_table"] = n_did | |
| 663 | - context["did_table"] = did | |
| 664 | - context["history_table"] = history | |
| 665 | - return context | |
| 552 | + log_component = 'resources' | |
| 553 | + log_action = 'view_statistics' | |
| 554 | + log_resource = 'webconference' | |
| 555 | + log_context = {} | |
| 556 | + | |
| 557 | + login_url = reverse_lazy("users:login") | |
| 558 | + redirect_field_name = 'next' | |
| 559 | + model = Webconference | |
| 560 | + template_name = 'webconference/relatorios.html' | |
| 561 | + | |
| 562 | + def dispatch(self, request, *args, **kwargs): | |
| 563 | + slug = self.kwargs.get('slug', '') | |
| 564 | + webconference = get_object_or_404(Webconference, slug = slug) | |
| 565 | + | |
| 566 | + if not has_subject_permissions(request.user, webconference.topic.subject): | |
| 567 | + return redirect(reverse_lazy('subjects:home')) | |
| 568 | + | |
| 569 | + return super(StatisticsView, self).dispatch(request, *args, **kwargs) | |
| 570 | + | |
| 571 | + def get_context_data(self, **kwargs): | |
| 572 | + context = super(StatisticsView, self).get_context_data(**kwargs) | |
| 573 | + | |
| 574 | + self.log_context['category_id'] = self.object.topic.subject.category.id | |
| 575 | + self.log_context['category_name'] = self.object.topic.subject.category.name | |
| 576 | + self.log_context['category_slug'] = self.object.topic.subject.category.slug | |
| 577 | + self.log_context['subject_id'] = self.object.topic.subject.id | |
| 578 | + self.log_context['subject_name'] = self.object.topic.subject.name | |
| 579 | + self.log_context['subject_slug'] = self.object.topic.subject.slug | |
| 580 | + self.log_context['topic_id'] = self.object.topic.id | |
| 581 | + self.log_context['topic_name'] = self.object.topic.name | |
| 582 | + self.log_context['topic_slug'] = self.object.topic.slug | |
| 583 | + self.log_context['webconference_id'] = self.object.id | |
| 584 | + self.log_context['webconference_name'] = self.object.name | |
| 585 | + self.log_context['webconference_slug'] = self.object.slug | |
| 586 | + | |
| 587 | + super(StatisticsView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
| 588 | + | |
| 589 | + | |
| 590 | + context['title'] = _('Youtube Video Reports') | |
| 591 | + | |
| 592 | + slug = self.kwargs.get('slug') | |
| 593 | + webconference = get_object_or_404(Webconference, slug = slug) | |
| 594 | + | |
| 595 | + date_format = "%d/%m/%Y %H:%M" if self.request.GET.get('language','') == 'pt-br' else "%m/%d/%Y %I:%M %p" | |
| 596 | + if self.request.GET.get('language','') == "": | |
| 597 | + start_date = datetime.datetime.now() - datetime.timedelta(30) | |
| 598 | + end_date = datetime.datetime.now() | |
| 599 | + else : | |
| 600 | + start_date = datetime.datetime.strptime(self.request.GET.get('init_date',''),date_format) | |
| 601 | + end_date = datetime.datetime.strptime(self.request.GET.get('end_date',''),date_format) | |
| 602 | + context["init_date"] = start_date | |
| 603 | + context["end_date"] = end_date | |
| 604 | + alunos = webconference.students.all() | |
| 605 | + if webconference.all_students : | |
| 606 | + alunos = webconference.topic.subject.students.all() | |
| 607 | + | |
| 608 | + vis_ou = Log.objects.filter(context__contains={'webconference_id':webconference.id},resource="webconference",user_email__in=(aluno.email for aluno in alunos), datetime__range=(start_date,end_date + datetime.timedelta(minutes = 1))).filter(Q(action="view") | Q(action="initwebconference") | Q(action="participating")) | |
| 609 | + did,n_did,history = str(_("Realized")),str(_("Unrealized")),str(_("Historic")) | |
| 610 | + re = [] | |
| 611 | + data_n_did,data_history = [],[] | |
| 612 | + json_n_did, json_history = {},{} | |
| 613 | + | |
| 614 | + for log_al in vis_ou.order_by("datetime"): | |
| 615 | + data_history.append([str(alunos.get(email=log_al.user_email)), | |
| 616 | + ", ".join([str(x) for x in webconference.topic.subject.group_subject.filter(participants__email=log_al.user_email)]), | |
| 617 | + log_al.action,log_al.datetime]) | |
| 618 | + | |
| 619 | + json_history["data"] = data_history | |
| 620 | + | |
| 621 | + column_view,column_initwebconference,column_participate = str(_('View')),str(_('Enter')),str(_('Participate')) | |
| 622 | + | |
| 623 | + not_view = alunos.exclude(email__in=[log.user_email for log in vis_ou.filter(action="view").distinct("user_email")]) | |
| 624 | + index = 0 | |
| 625 | + for alun in not_view: | |
| 626 | + data_n_did.append([index,str(alun),", ".join([str(x) for x in webconference.topic.subject.group_subject.filter(participants__email=alun.email)]),column_view, str(alun.email)]) | |
| 627 | + index += 1 | |
| 628 | + | |
| 629 | + not_initwebconference = alunos.exclude(email__in=[log.user_email for log in vis_ou.filter(action="initwebconference").distinct("user_email")]) | |
| 630 | + for alun in not_initwebconference: | |
| 631 | + data_n_did.append([index,str(alun),", ".join([str(x) for x in webconference.topic.subject.group_subject.filter(participants__email=alun.email)]),column_initwebconference, str(alun.email)]) | |
| 632 | + index += 1 | |
| 633 | + | |
| 634 | + not_participate = alunos.exclude(email__in=[log.user_email for log in vis_ou.filter(action="participating").distinct("user_email")]) | |
| 635 | + for alun in not_participate: | |
| 636 | + data_n_did.append([index,str(alun),", ".join([str(x) for x in webconference.topic.subject.group_subject.filter(participants__email=alun.email)]),column_participate, str(alun.email)]) | |
| 637 | + index += 1 | |
| 638 | + | |
| 639 | + json_n_did["data"] = data_n_did | |
| 640 | + | |
| 641 | + | |
| 642 | + context["json_n_did"] = json_n_did | |
| 643 | + context["json_history"] = json_history | |
| 644 | + c_visualizou = vis_ou.filter(action="view").distinct("user_email").count() | |
| 645 | + c_initwebconference = vis_ou.filter(action="initwebconference").distinct("user_email").count() | |
| 646 | + c_participate = vis_ou.filter(action="participating").distinct("user_email").count() | |
| 647 | + re.append([str(_('Webconference')),did,n_did]) | |
| 648 | + | |
| 649 | + re.append([column_view,c_visualizou, alunos.count() - c_visualizou]) | |
| 650 | + re.append([column_initwebconference,c_initwebconference, alunos.count() - c_initwebconference]) | |
| 651 | + re.append([column_participate,c_participate, alunos.count() - c_participate]) | |
| 652 | + | |
| 653 | + context['view'] = column_view | |
| 654 | + context['initwebconference'] = column_initwebconference | |
| 655 | + context['participate'] = column_participate | |
| 656 | + context['topic'] = webconference.topic | |
| 657 | + context['subject'] = webconference.topic.subject | |
| 658 | + context['webconference'] = webconference | |
| 659 | + context['db_data'] = re | |
| 660 | + context['title_chart'] = _('Actions about resource') | |
| 661 | + context['title_vAxis'] = _('Quantity') | |
| 662 | + | |
| 663 | + context["n_did_table"] = n_did | |
| 664 | + context["did_table"] = did | |
| 665 | + context["history_table"] = history | |
| 666 | + return context | |
| 666 | 667 | |
| 667 | 668 | from django.http import HttpResponse #used to send HTTP 404 error to ajax |
| 668 | 669 | |
| 669 | 670 | class SendMessage(LoginRequiredMixin, LogMixin, generic.edit.FormView): |
| 670 | - log_component = 'resources' | |
| 671 | - log_action = 'send' | |
| 672 | - log_resource = 'webconference' | |
| 673 | - log_context = {} | |
| 674 | - | |
| 675 | - login_url = reverse_lazy("users:login") | |
| 676 | - redirect_field_name = 'next' | |
| 677 | - | |
| 678 | - template_name = 'webconference/send_message.html' | |
| 679 | - form_class = FormModalMessage | |
| 680 | - | |
| 681 | - def dispatch(self, request, *args, **kwargs): | |
| 682 | - slug = self.kwargs.get('slug', '') | |
| 683 | - webconference = get_object_or_404(Webconference, slug = slug) | |
| 684 | - self.webconference = webconference | |
| 685 | - | |
| 686 | - if not has_subject_permissions(request.user, webconference.topic.subject): | |
| 687 | - return redirect(reverse_lazy('subjects:home')) | |
| 688 | - | |
| 689 | - return super(SendMessage, self).dispatch(request, *args, **kwargs) | |
| 690 | - | |
| 691 | - def form_valid(self, form): | |
| 692 | - message = form.cleaned_data.get('comment') | |
| 693 | - image = form.cleaned_data.get("image") | |
| 694 | - users = (self.request.POST.get('users[]','')).split(",") | |
| 695 | - user = self.request.user | |
| 696 | - subject = self.webconference.topic.subject | |
| 697 | - | |
| 698 | - if (users[0] is not ''): | |
| 699 | - for u in users: | |
| 700 | - to_user = User.objects.get(email=u) | |
| 701 | - talk, create = Conversation.objects.get_or_create(user_one=user,user_two=to_user) | |
| 702 | - created = TalkMessages.objects.create(text=message,talk=talk,user=user,subject=subject,image=image) | |
| 703 | - | |
| 704 | - simple_notify = textwrap.shorten(strip_tags(message), width = 30, placeholder = "...") | |
| 705 | - | |
| 706 | - if image is not '': | |
| 707 | - simple_notify += " ".join(_("[Photo]")) | |
| 708 | - | |
| 709 | - notification = { | |
| 710 | - "type": "chat", | |
| 711 | - "subtype": "subject", | |
| 712 | - "space": subject.slug, | |
| 713 | - "user_icon": created.user.image_url, | |
| 714 | - "notify_title": str(created.user), | |
| 715 | - "simple_notify": simple_notify, | |
| 716 | - "view_url": reverse("chat:view_message", args = (created.id, ), kwargs = {}), | |
| 717 | - "complete": render_to_string("chat/_message.html", {"talk_msg": created}, self.request), | |
| 718 | - "container": "chat-" + str(created.user.id), | |
| 719 | - "last_date": _("Last message in %s")%(formats.date_format(created.create_date, "SHORT_DATETIME_FORMAT")) | |
| 720 | - } | |
| 721 | - | |
| 722 | - notification = json.dumps(notification) | |
| 723 | - | |
| 724 | - Group("user-%s" % to_user.id).send({'text': notification}) | |
| 725 | - | |
| 726 | - ChatVisualizations.objects.create(viewed = False, message = created, user = to_user) | |
| 727 | - | |
| 728 | - success = str(_('The message was successfull sent!')) | |
| 729 | - return JsonResponse({"message":success}) | |
| 730 | - erro = HttpResponse(str(_("No user selected!"))) | |
| 731 | - erro.status_code = 404 | |
| 732 | - return erro | |
| 733 | - | |
| 734 | - def get_context_data(self, **kwargs): | |
| 735 | - context = super(SendMessage,self).get_context_data() | |
| 736 | - context["webconference"] = get_object_or_404(Webconference, slug=self.kwargs.get('slug', '')) | |
| 737 | - return context | |
| 671 | + log_component = 'resources' | |
| 672 | + log_action = 'send' | |
| 673 | + log_resource = 'webconference' | |
| 674 | + log_context = {} | |
| 675 | + | |
| 676 | + login_url = reverse_lazy("users:login") | |
| 677 | + redirect_field_name = 'next' | |
| 678 | + | |
| 679 | + template_name = 'webconference/send_message.html' | |
| 680 | + form_class = FormModalMessage | |
| 681 | + | |
| 682 | + def dispatch(self, request, *args, **kwargs): | |
| 683 | + slug = self.kwargs.get('slug', '') | |
| 684 | + webconference = get_object_or_404(Webconference, slug = slug) | |
| 685 | + self.webconference = webconference | |
| 686 | + | |
| 687 | + if not has_subject_permissions(request.user, webconference.topic.subject): | |
| 688 | + return redirect(reverse_lazy('subjects:home')) | |
| 689 | + | |
| 690 | + return super(SendMessage, self).dispatch(request, *args, **kwargs) | |
| 691 | + | |
| 692 | + def form_valid(self, form): | |
| 693 | + message = form.cleaned_data.get('comment') | |
| 694 | + image = form.cleaned_data.get("image") | |
| 695 | + users = (self.request.POST.get('users[]','')).split(",") | |
| 696 | + user = self.request.user | |
| 697 | + subject = self.webconference.topic.subject | |
| 698 | + | |
| 699 | + if (users[0] is not ''): | |
| 700 | + for u in users: | |
| 701 | + to_user = User.objects.get(email=u) | |
| 702 | + talk, create = Conversation.objects.get_or_create(user_one=user,user_two=to_user) | |
| 703 | + created = TalkMessages.objects.create(text=message,talk=talk,user=user,subject=subject,image=image) | |
| 704 | + | |
| 705 | + simple_notify = textwrap.shorten(strip_tags(message), width = 30, placeholder = "...") | |
| 706 | + | |
| 707 | + if image is not '': | |
| 708 | + simple_notify += " ".join(_("[Photo]")) | |
| 709 | + | |
| 710 | + notification = { | |
| 711 | + "type": "chat", | |
| 712 | + "subtype": "subject", | |
| 713 | + "space": subject.slug, | |
| 714 | + "user_icon": created.user.image_url, | |
| 715 | + "notify_title": str(created.user), | |
| 716 | + "simple_notify": simple_notify, | |
| 717 | + "view_url": reverse("chat:view_message", args = (created.id, ), kwargs = {}), | |
| 718 | + "complete": render_to_string("chat/_message.html", {"talk_msg": created}, self.request), | |
| 719 | + "container": "chat-" + str(created.user.id), | |
| 720 | + "last_date": _("Last message in %s")%(formats.date_format(created.create_date, "SHORT_DATETIME_FORMAT")) | |
| 721 | + } | |
| 722 | + | |
| 723 | + notification = json.dumps(notification) | |
| 724 | + | |
| 725 | + Group("user-%s" % to_user.id).send({'text': notification}) | |
| 726 | + | |
| 727 | + ChatVisualizations.objects.create(viewed = False, message = created, user = to_user) | |
| 728 | + | |
| 729 | + success = str(_('The message was successfull sent!')) | |
| 730 | + return JsonResponse({"message":success}) | |
| 731 | + erro = HttpResponse(str(_("No user selected!"))) | |
| 732 | + erro.status_code = 404 | |
| 733 | + return erro | |
| 734 | + | |
| 735 | + def get_context_data(self, **kwargs): | |
| 736 | + context = super(SendMessage,self).get_context_data() | |
| 737 | + context["webconference"] = get_object_or_404(Webconference, slug=self.kwargs.get('slug', '')) | |
| 738 | + return context | ... | ... |
webpage/templates/webpages/update.html
| ... | ... | @@ -18,8 +18,8 @@ |
| 18 | 18 | {% breadcrumb topic 'subjects:topic_view' topic.subject.slug topic.slug %} |
| 19 | 19 | |
| 20 | 20 | {% trans 'Edit: ' as bread %} |
| 21 | - {% with bread|add:webpage.name as bread_slug %} | |
| 22 | - {% breadcrumb bread_slug 'webpages:update' topic.slug webpage.slug %} | |
| 21 | + {% with bread|add:resource.name as bread_slug %} | |
| 22 | + {% breadcrumb bread_slug 'webpages:update' topic.slug resource.slug %} | |
| 23 | 23 | {% endwith %} |
| 24 | 24 | {% endblock %} |
| 25 | 25 | ... | ... |
webpage/views.py
| ... | ... | @@ -360,6 +360,7 @@ class UpdateView(LoginRequiredMixin, LogMixin, generic.UpdateView): |
| 360 | 360 | |
| 361 | 361 | context['topic'] = topic |
| 362 | 362 | context['subject'] = topic.subject |
| 363 | + context['resource'] = get_object_or_404(Webpage, slug = self.kwargs.get('slug', '')) | |
| 363 | 364 | |
| 364 | 365 | return context |
| 365 | 366 | ... | ... |
youtube_video/templates/youtube/update.html
| ... | ... | @@ -19,8 +19,8 @@ |
| 19 | 19 | {% breadcrumb topic 'subjects:topic_view' topic.subject.slug topic.slug %} |
| 20 | 20 | |
| 21 | 21 | {% trans 'Edit: ' as bread %} |
| 22 | - {% with bread|add:youtube.name as bread_slug %} | |
| 23 | - {% breadcrumb bread_slug 'youtube:update' topic.slug youtube.slug %} | |
| 22 | + {% with bread|add:resource.name as bread_slug %} | |
| 23 | + {% breadcrumb bread_slug 'youtube:update' topic.slug resource.slug %} | |
| 24 | 24 | {% endwith %} |
| 25 | 25 | {% endblock %} |
| 26 | 26 | ... | ... |
youtube_video/views.py
| ... | ... | @@ -366,6 +366,7 @@ class UpdateView(LoginRequiredMixin, LogMixin, generic.UpdateView): |
| 366 | 366 | |
| 367 | 367 | context['topic'] = topic |
| 368 | 368 | context['subject'] = topic.subject |
| 369 | + context['resource'] = get_object_or_404(YTVideo, slug = self.kwargs.get('slug', '')) | |
| 369 | 370 | |
| 370 | 371 | return context |
| 371 | 372 | ... | ... |