我们从Python开源项目中,提取了以下21个代码示例,用于说明如何使用django.views.generic.DeleteView()。
def query_set(self): queryset = super().get_queryset() return queryset.filter(recipient = self.request.user) # class DeletePrivateMessage(LoginRequiredMixin,SelectRelatedMixin,generic.DeleteView): # model = PrivateMessage # select_related = ('sender','recipient') # success_url = reverse_lazy('private_messages:list') # # def get_queryset(self): # queryset = super().get_queryset() # return queryset.filter(recipient = self.request.user) # # def delete(self,*args,**kwargs): # messages.success(self.request,'Message Deleted') # return super().delete(*args,**kwargs)
def get_success_url(self): messages.success(self.request, _('The PDF File "%s" was removed successfully from virtual environment "%s"!')%(self.object.name, self.object.topic.subject.name)) self.log_context['category_id'] = self.object.topic.subject.category.id self.log_context['category_name'] = self.object.topic.subject.category.name self.log_context['category_slug'] = self.object.topic.subject.category.slug self.log_context['subject_id'] = self.object.topic.subject.id self.log_context['subject_name'] = self.object.topic.subject.name self.log_context['subject_slug'] = self.object.topic.subject.slug self.log_context['topic_id'] = self.object.topic.id self.log_context['topic_name'] = self.object.topic.name self.log_context['topic_slug'] = self.object.topic.slug self.log_context['pdffile_id'] = self.object.id self.log_context['pdffile_name'] = self.object.name self.log_context['pdffile_slug'] = self.object.slug super(DeleteView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) return reverse_lazy('subjects:view', kwargs = {'slug': self.object.topic.subject.slug})
def get_success_url(self): messages.success(self.request, _('The group "%s" was removed successfully!')%(self.object.name)) self.log_context['category_id'] = self.object.subject.category.id self.log_context['category_name'] = self.object.subject.category.name self.log_context['category_slug'] = self.object.subject.category.slug self.log_context['subject_id'] = self.object.subject.id self.log_context['subject_name'] = self.object.subject.name self.log_context['subject_slug'] = self.object.subject.slug self.log_context['group_id'] = self.object.id self.log_context['group_name'] = self.object.name self.log_context['group_slug'] = self.object.slug super(DeleteView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) return reverse_lazy('groups:index', kwargs = {'slug': self.object.subject.slug})
def get_success_url(self): messages.success(self.request, _('The bulletin "%s" was removed successfully from virtual environment "%s"!')%(self.object.name, self.object.topic.subject.name)) self.log_context['category_id'] = self.object.topic.subject.category.id self.log_context['category_name'] = self.object.topic.subject.category.name self.log_context['category_slug'] = self.object.topic.subject.category.slug self.log_context['subject_id'] = self.object.topic.subject.id self.log_context['subject_name'] = self.object.topic.subject.name self.log_context['subject_slug'] = self.object.topic.subject.slug self.log_context['topic_id'] = self.object.topic.id self.log_context['topic_name'] = self.object.topic.name self.log_context['topic_slug'] = self.object.topic.slug self.log_context['bulletin_id'] = self.object.id self.log_context['bulletin_name'] = self.object.name self.log_context['bulletin_slug'] = self.object.slug super(DeleteView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) return reverse_lazy('subjects:view', kwargs = {'slug': self.object.topic.subject.slug})
def get_success_url(self): messages.success(self.request, _('The YouTube Video "%s" was removed successfully from virtual environment "%s"!')%(self.object.name, self.object.topic.subject.name)) self.log_context['category_id'] = self.object.topic.subject.category.id self.log_context['category_name'] = self.object.topic.subject.category.name self.log_context['category_slug'] = self.object.topic.subject.category.slug self.log_context['subject_id'] = self.object.topic.subject.id self.log_context['subject_name'] = self.object.topic.subject.name self.log_context['subject_slug'] = self.object.topic.subject.slug self.log_context['topic_id'] = self.object.topic.id self.log_context['topic_name'] = self.object.topic.name self.log_context['topic_slug'] = self.object.topic.slug self.log_context['ytvideo_id'] = self.object.id self.log_context['ytvideo_name'] = self.object.name self.log_context['ytvideo_slug'] = self.object.slug super(DeleteView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) return reverse_lazy('subjects:view', kwargs = {'slug': self.object.topic.subject.slug})
def get_success_url(self): messages.success(self.request, _('The File Link "%s" was removed successfully from virtual environment "%s"!')%(self.object.name, self.object.topic.subject.name)) self.log_context['category_id'] = self.object.topic.subject.category.id self.log_context['category_name'] = self.object.topic.subject.category.name self.log_context['category_slug'] = self.object.topic.subject.category.slug self.log_context['subject_id'] = self.object.topic.subject.id self.log_context['subject_name'] = self.object.topic.subject.name self.log_context['subject_slug'] = self.object.topic.subject.slug self.log_context['topic_id'] = self.object.topic.id self.log_context['topic_name'] = self.object.topic.name self.log_context['topic_slug'] = self.object.topic.slug self.log_context['filelink_id'] = self.object.id self.log_context['filelink_name'] = self.object.name self.log_context['filelink_slug'] = self.object.slug super(DeleteView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) return reverse_lazy('subjects:view', kwargs = {'slug': self.object.topic.subject.slug})
def get_success_url(self): messages.success(self.request, _('Topic "%s" was removed from virtual enviroment "%s" successfully!')%(self.object.name, self.object.subject.name)) self.log_context['category_id'] = self.object.subject.category.id self.log_context['category_name'] = self.object.subject.category.name self.log_context['category_slug'] = self.object.subject.category.slug self.log_context['subject_id'] = self.object.subject.id self.log_context['subject_name'] = self.object.subject.name self.log_context['subject_slug'] = self.object.subject.slug self.log_context['topic_id'] = self.object.id self.log_context['topic_name'] = self.object.name self.log_context['topic_slug'] = self.object.slug super(DeleteView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) return reverse_lazy('subjects:view', kwargs = {'slug': self.object.subject.slug})
def get_success_url(self): messages.success(self.request, _('The Goals specification of the topic %s was removed successfully!')%(self.object.topic.name)) self.log_context['category_id'] = self.object.topic.subject.category.id self.log_context['category_name'] = self.object.topic.subject.category.name self.log_context['category_slug'] = self.object.topic.subject.category.slug self.log_context['subject_id'] = self.object.topic.subject.id self.log_context['subject_name'] = self.object.topic.subject.name self.log_context['subject_slug'] = self.object.topic.subject.slug self.log_context['topic_id'] = self.object.topic.id self.log_context['topic_name'] = self.object.topic.name self.log_context['topic_slug'] = self.object.topic.slug self.log_context['goals_id'] = self.object.id self.log_context['goals_name'] = self.object.name self.log_context['goals_slug'] = self.object.slug super(DeleteView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) return reverse_lazy('subjects:view', kwargs = {'slug': self.object.topic.subject.slug})
def get_success_url(self): return self._plugin.get_success_url() # class PreviewDeleteView(BaseFormView, DeleteView): # plugin = ViewFactory('delete', 'preview')
def dispatch(self, request, *args, **kwargs): """Overriding dispatch on DeleteView""" self.model = get_model(**kwargs) instance = get_model_instance(**kwargs) app_title = get_app_name(**kwargs) self.success_url = reverse_lazy( 'index', args=(app_title, instance.title,)) return super(EntityDelete, self).dispatch( request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): slug = self.kwargs.get('slug', '') pdf_file = get_object_or_404(PDFFile, slug = slug) if not has_subject_permissions(request.user, pdf_file.topic.subject): return redirect(reverse_lazy('subjects:home')) return super(DeleteView, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): slug = self.kwargs.get('slug', '') group = get_object_or_404(StudentsGroup, slug = slug) if not has_subject_permissions(request.user, group.subject): return redirect(reverse_lazy('subjects:home')) return super(DeleteView, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): slug = self.kwargs.get('slug', '') webconference = get_object_or_404(Webconference, slug = slug) if not has_subject_permissions(request.user, webconference.topic.subject): return redirect(reverse_lazy('subjects:home')) return super(DeleteView, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): slug = self.kwargs.get('slug', '') bulletin = get_object_or_404(Bulletin, slug = slug) if not has_subject_permissions(request.user, bulletin.topic.subject): return redirect(reverse_lazy('subjects:home')) return super(DeleteView, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): slug = self.kwargs.get('slug', '') youtube = get_object_or_404(YTVideo, slug = slug) if not has_subject_permissions(request.user, youtube.topic.subject): return redirect(reverse_lazy('subjects:home')) return super(DeleteView, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): slug = self.kwargs.get('slug', '') webpage = get_object_or_404(Webpage, slug = slug) if not has_subject_permissions(request.user, webpage.topic.subject): return redirect(reverse_lazy('subjects:home')) return super(DeleteView, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): slug = self.kwargs.get('slug', '') file_link = get_object_or_404(FileLink, slug = slug) if not has_subject_permissions(request.user, file_link.topic.subject): return redirect(reverse_lazy('subjects:home')) return super(DeleteView, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): slug = self.kwargs.get('slug', '') topic = get_object_or_404(Topic, slug = slug) if not has_subject_permissions(request.user, topic.subject): return redirect(reverse_lazy('subjects:home')) return super(DeleteView, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): email = self.kwargs.get('email', None) if not email is None: if not request.user.is_staff: return redirect(reverse_lazy('subjects:home')) return super(DeleteView, self).dispatch(request, *args, **kwargs)
def get_context_data(self, **kwargs): context = super(DeleteView, self).get_context_data(**kwargs) context['title'] = _('Delete Account') context['email'] = self.kwargs.get('email', None) return context
def dispatch(self, request, *args, **kwargs): slug = self.kwargs.get('slug', '') goals = get_object_or_404(Goals, slug = slug) if not has_subject_permissions(request.user, goals.topic.subject): return redirect(reverse_lazy('subjects:home')) return super(DeleteView, self).dispatch(request, *args, **kwargs)