コード例 #1
0
 def delete(self, request, *args, **kwargs):
     self.object = self.get_object()
     success_url = reverse('index')
     if self.request.GET.get('next'):
         success_url = self.request.GET.get('next')
     log_delete(self)
     self.object.delete()
     messages.success(self.request, 'Item Deleted!')
     return redirect(success_url)
コード例 #2
0
 def delete(self, request, *args, **kwargs):
     self.object = self.get_object()
     success_url = self.object.store.get_absolute_url()
     for tobuy in self.object.content.all():
         tobuy.delete()
     log_delete(self)
     self.object.delete()
     messages.success(self.request, 'List Deleted!')
     return redirect(success_url)
コード例 #3
0
ファイル: delete.py プロジェクト: nullpass/grocerylist
 def delete(self, request, *args, **kwargs):
     self.object = self.get_object()
     success_url = self.object.store.get_absolute_url()
     #
     if Item.objects.filter(user=self.request.user).filter(isle=self.object.id).count() == 0 \
             and self.object.content.all().count() == 0:
         log_delete(self)
         self.object.delete()
         messages.success(self.request, 'Isle Deleted!')
     else:
         messages.error(self.request,
                        'Unable to delete! There are still items linked to this isle.',
                        extra_tags='danger')
     #
     return redirect(success_url)
コード例 #4
0
ファイル: delete.py プロジェクト: nullpass/grocerylist
    def delete(self, request, *args, **kwargs):
        self.object = self.get_object()
        success_url = reverse('index')

        if Item.objects.filter(user=self.request.user).filter(store=self.object.id).count() == 0 \
                and Isle.objects.filter(user=self.request.user).filter(store=self.object.id).count() == 0 \
                and List.objects.filter(user=self.request.user).filter(store=self.object.id).count() == 0:
            log_delete(self)
            self.object.delete()
            messages.success(self.request, 'Store Deleted!')
            return redirect(success_url)
        # all-else
        messages.error(self.request,
                       'Unable to delete! There are still items, isles or grocery lists associated with this store.',
                       extra_tags='danger')
        return redirect(self.object.get_absolute_url())
コード例 #5
0
 def delete(self, request, *args, **kwargs):
     self.object = self.get_object()
     success_url = self.object.store.get_absolute_url()
     #
     if Item.objects.filter(user=self.request.user).filter(isle=self.object.id).count() == 0 \
             and self.object.content.all().count() == 0:
         log_delete(self)
         self.object.delete()
         messages.success(self.request, 'Isle Deleted!')
     else:
         messages.error(
             self.request,
             'Unable to delete! There are still items linked to this isle.',
             extra_tags='danger')
     #
     return redirect(success_url)
コード例 #6
0
ファイル: delete.py プロジェクト: somair/grocerylist
    def delete(self, request, *args, **kwargs):
        self.object = self.get_object()
        success_url = reverse('index')

        if Item.objects.filter(user=self.request.user).filter(store=self.object.id).count() == 0 \
                and Isle.objects.filter(user=self.request.user).filter(store=self.object.id).count() == 0 \
                and List.objects.filter(user=self.request.user).filter(store=self.object.id).count() == 0:
            log_delete(self)
            self.object.delete()
            messages.success(self.request, 'Store Deleted!')
            return redirect(success_url)
        # all-else
        messages.error(
            self.request,
            'Unable to delete! There are still items, isles or grocery lists associated with this store.',
            extra_tags='danger')
        return redirect(self.object.get_absolute_url())