Commit a9afab646ebd9ce4ff655ea523b582bb7483bc00
1 parent
7dc16619
Exists in
master
and in
3 other branches
Criando logs de criar, editar e deletar uma webconferencia
Showing
1 changed file
with
58 additions
and
63 deletions
Show diff stats
webconference/views.py
| @@ -143,13 +143,11 @@ generic.DetailView): | @@ -143,13 +143,11 @@ generic.DetailView): | ||
| 143 | 143 | ||
| 144 | return context | 144 | return context |
| 145 | 145 | ||
| 146 | -class CreateView(LoginRequiredMixin, | ||
| 147 | - # '''LogMixin,''' | ||
| 148 | - generic.edit.CreateView): | ||
| 149 | - # log_component = 'resources' | ||
| 150 | - # log_action = 'create' | ||
| 151 | - # log_resource = 'webpage' | ||
| 152 | - # log_context = {} | 146 | +class CreateView(LoginRequiredMixin, LogMixin, generic.edit.CreateView): |
| 147 | + log_component = 'resources' | ||
| 148 | + log_action = 'create' | ||
| 149 | + log_resource = 'webconference' | ||
| 150 | + log_context = {} | ||
| 153 | login_url = reverse_lazy("users:login") | 151 | login_url = reverse_lazy("users:login") |
| 154 | redirect_field_name = 'next' | 152 | redirect_field_name = 'next' |
| 155 | 153 | ||
| @@ -223,20 +221,21 @@ class CreateView(LoginRequiredMixin, | @@ -223,20 +221,21 @@ class CreateView(LoginRequiredMixin, | ||
| 223 | if not pend_form.action == "": | 221 | if not pend_form.action == "": |
| 224 | pend_form.save() | 222 | pend_form.save() |
| 225 | 223 | ||
| 226 | - # self.log_context['category_id'] = self.object.topic.subject.category.id | ||
| 227 | - # self.log_context['category_name'] = self.object.topic.subject.category.name | ||
| 228 | - # self.log_context['category_slug'] = self.object.topic.subject.category.slug | ||
| 229 | - # self.log_context['subject_id'] = self.object.topic.subject.id | ||
| 230 | - # self.log_context['subject_name'] = self.object.topic.subject.name | ||
| 231 | - # self.log_context['subject_slug'] = self.object.topic.subject.slug | ||
| 232 | - # self.log_context['topic_id'] = self.object.topic.id | ||
| 233 | - # self.log_context['topic_name'] = self.object.topic.name | ||
| 234 | - # self.log_context['topic_slug'] = self.object.topic.slug | ||
| 235 | - # self.log_context['webpage_id'] = self.object.id | ||
| 236 | - # self.log_context['webpage_name'] = self.object.name | ||
| 237 | - # self.log_context['webpage_slug'] = self.object.slug | ||
| 238 | - # | ||
| 239 | - # super(CreateView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | 224 | + |
| 225 | + self.log_context['category_id'] = self.object.topic.subject.category.id | ||
| 226 | + self.log_context['category_name'] = self.object.topic.subject.category.name | ||
| 227 | + self.log_context['category_slug'] = self.object.topic.subject.category.slug | ||
| 228 | + self.log_context['subject_id'] = self.object.topic.subject.id | ||
| 229 | + self.log_context['subject_name'] = self.object.topic.subject.name | ||
| 230 | + self.log_context['subject_slug'] = self.object.topic.subject.slug | ||
| 231 | + self.log_context['topic_id'] = self.object.topic.id | ||
| 232 | + self.log_context['topic_name'] = self.object.topic.name | ||
| 233 | + self.log_context['topic_slug'] = self.object.topic.slug | ||
| 234 | + self.log_context['webconference_id'] = self.object.id | ||
| 235 | + self.log_context['webconference_name'] = self.object.name | ||
| 236 | + self.log_context['webconference_slug'] = self.object.slug | ||
| 237 | + | ||
| 238 | + super(CreateView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | ||
| 240 | 239 | ||
| 241 | return redirect(self.get_success_url()) | 240 | return redirect(self.get_success_url()) |
| 242 | 241 | ||
| @@ -267,13 +266,11 @@ class CreateView(LoginRequiredMixin, | @@ -267,13 +266,11 @@ class CreateView(LoginRequiredMixin, | ||
| 267 | 266 | ||
| 268 | return success_url | 267 | return success_url |
| 269 | 268 | ||
| 270 | -class UpdateView(LoginRequiredMixin, | ||
| 271 | -# ''' LogMixin,''' | ||
| 272 | -generic.UpdateView): | ||
| 273 | - # log_component = 'resources' | ||
| 274 | - # log_action = 'update' | ||
| 275 | - # log_resource = 'webpage' | ||
| 276 | - # log_context = {} | 269 | +class UpdateView(LoginRequiredMixin, LogMixin, generic.UpdateView): |
| 270 | + log_component = 'resources' | ||
| 271 | + log_action = 'update' | ||
| 272 | + log_resource = 'webconference' | ||
| 273 | + log_context = {} | ||
| 277 | 274 | ||
| 278 | login_url = reverse_lazy("users:login") | 275 | login_url = reverse_lazy("users:login") |
| 279 | redirect_field_name = 'next' | 276 | redirect_field_name = 'next' |
| @@ -347,20 +344,20 @@ generic.UpdateView): | @@ -347,20 +344,20 @@ generic.UpdateView): | ||
| 347 | if not pend_form.action == "": | 344 | if not pend_form.action == "": |
| 348 | pend_form.save() | 345 | pend_form.save() |
| 349 | 346 | ||
| 350 | - # self.log_context['category_id'] = self.object.topic.subject.category.id | ||
| 351 | - # self.log_context['category_name'] = self.object.topic.subject.category.name | ||
| 352 | - # self.log_context['category_slug'] = self.object.topic.subject.category.slug | ||
| 353 | - # self.log_context['subject_id'] = self.object.topic.subject.id | ||
| 354 | - # self.log_context['subject_name'] = self.object.topic.subject.name | ||
| 355 | - # self.log_context['subject_slug'] = self.object.topic.subject.slug | ||
| 356 | - # self.log_context['topic_id'] = self.object.topic.id | ||
| 357 | - # self.log_context['topic_name'] = self.object.topic.name | ||
| 358 | - # self.log_context['topic_slug'] = self.object.topic.slug | ||
| 359 | - # self.log_context['webpage_id'] = self.object.id | ||
| 360 | - # self.log_context['webpage_name'] = self.object.name | ||
| 361 | - # self.log_context['webpage_slug'] = self.object.slug | ||
| 362 | - # | ||
| 363 | - # super(UpdateView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | 347 | + self.log_context['category_id'] = self.object.topic.subject.category.id |
| 348 | + self.log_context['category_name'] = self.object.topic.subject.category.name | ||
| 349 | + self.log_context['category_slug'] = self.object.topic.subject.category.slug | ||
| 350 | + self.log_context['subject_id'] = self.object.topic.subject.id | ||
| 351 | + self.log_context['subject_name'] = self.object.topic.subject.name | ||
| 352 | + self.log_context['subject_slug'] = self.object.topic.subject.slug | ||
| 353 | + self.log_context['topic_id'] = self.object.topic.id | ||
| 354 | + self.log_context['topic_name'] = self.object.topic.name | ||
| 355 | + self.log_context['topic_slug'] = self.object.topic.slug | ||
| 356 | + self.log_context['webconference_id'] = self.object.id | ||
| 357 | + self.log_context['webconference_name'] = self.object.name | ||
| 358 | + self.log_context['webconference_slug'] = self.object.slug | ||
| 359 | + | ||
| 360 | + super(UpdateView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | ||
| 364 | 361 | ||
| 365 | return redirect(self.get_success_url()) | 362 | return redirect(self.get_success_url()) |
| 366 | 363 | ||
| @@ -391,13 +388,11 @@ generic.UpdateView): | @@ -391,13 +388,11 @@ generic.UpdateView): | ||
| 391 | 388 | ||
| 392 | return success_url | 389 | return success_url |
| 393 | 390 | ||
| 394 | -class DeleteView(LoginRequiredMixin, | ||
| 395 | -# ''' LogMixin,''' | ||
| 396 | -generic.DeleteView): | ||
| 397 | - # log_component = 'resources' | ||
| 398 | - # log_action = 'delete' | ||
| 399 | - # log_resource = 'webpage' | ||
| 400 | - # log_context = {} | 391 | +class DeleteView(LoginRequiredMixin, LogMixin, generic.DeleteView): |
| 392 | + log_component = 'resources' | ||
| 393 | + log_action = 'delete' | ||
| 394 | + log_resource = 'webconference' | ||
| 395 | + log_context = {} | ||
| 401 | 396 | ||
| 402 | login_url = reverse_lazy("users:login") | 397 | login_url = reverse_lazy("users:login") |
| 403 | redirect_field_name = 'next' | 398 | redirect_field_name = 'next' |
| @@ -418,20 +413,20 @@ generic.DeleteView): | @@ -418,20 +413,20 @@ generic.DeleteView): | ||
| 418 | def get_success_url(self): | 413 | def get_success_url(self): |
| 419 | messages.success(self.request, _('The web conference "%s" was removed successfully from virtual environment "%s"!')%(self.object.name, self.object.topic.subject.name)) | 414 | messages.success(self.request, _('The web conference "%s" was removed successfully from virtual environment "%s"!')%(self.object.name, self.object.topic.subject.name)) |
| 420 | 415 | ||
| 421 | - # self.log_context['category_id'] = self.object.topic.subject.category.id | ||
| 422 | - # self.log_context['category_name'] = self.object.topic.subject.category.name | ||
| 423 | - # self.log_context['category_slug'] = self.object.topic.subject.category.slug | ||
| 424 | - # self.log_context['subject_id'] = self.object.topic.subject.id | ||
| 425 | - # self.log_context['subject_name'] = self.object.topic.subject.name | ||
| 426 | - # self.log_context['subject_slug'] = self.object.topic.subject.slug | ||
| 427 | - # self.log_context['topic_id'] = self.object.topic.id | ||
| 428 | - # self.log_context['topic_name'] = self.object.topic.name | ||
| 429 | - # self.log_context['topic_slug'] = self.object.topic.slug | ||
| 430 | - # self.log_context['webpage_id'] = self.object.id | ||
| 431 | - # self.log_context['webpage_name'] = self.object.name | ||
| 432 | - # self.log_context['webpage_slug'] = self.object.slug | ||
| 433 | - # | ||
| 434 | - # super(DeleteView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | 416 | + self.log_context['category_id'] = self.object.topic.subject.category.id |
| 417 | + self.log_context['category_name'] = self.object.topic.subject.category.name | ||
| 418 | + self.log_context['category_slug'] = self.object.topic.subject.category.slug | ||
| 419 | + self.log_context['subject_id'] = self.object.topic.subject.id | ||
| 420 | + self.log_context['subject_name'] = self.object.topic.subject.name | ||
| 421 | + self.log_context['subject_slug'] = self.object.topic.subject.slug | ||
| 422 | + self.log_context['topic_id'] = self.object.topic.id | ||
| 423 | + self.log_context['topic_name'] = self.object.topic.name | ||
| 424 | + self.log_context['topic_slug'] = self.object.topic.slug | ||
| 425 | + self.log_context['webconference_id'] = self.object.id | ||
| 426 | + self.log_context['webconference_name'] = self.object.name | ||
| 427 | + self.log_context['webconference_slug'] = self.object.slug | ||
| 428 | + | ||
| 429 | + super(DeleteView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | ||
| 435 | 430 | ||
| 436 | return reverse_lazy('subjects:view', kwargs = {'slug': self.object.topic.subject.slug}) | 431 | return reverse_lazy('subjects:view', kwargs = {'slug': self.object.topic.subject.slug}) |
| 437 | 432 |