add a delete button to the backups table

This commit is contained in:
Andreas Zweili 2020-08-03 16:49:45 +02:00
parent 0bcb74a397
commit b06f7e961b
3 changed files with 17 additions and 0 deletions

View File

@ -1,4 +1,5 @@
import django_tables2 as tables
from django_tables2.utils import A
from core.tables import CoreTable
@ -10,6 +11,11 @@ class BackupsTable(CoreTable):
name = tables.Column('Backup', linkify=True)
computer = tables.Column('Computer', linkify=True)
target_device = tables.ManyToManyColumn(linkify_item=True)
delete = tables.LinkColumn('backup_delete_from-table',
text='delete',
args=[A('pk')], attrs={
'a': {'class': 'delete material-icons', }
})
class Meta(CoreTable.Meta):
model = Backup

View File

@ -10,4 +10,7 @@ urlpatterns = [
views.BackupCreateView.as_view(), name='backup_create'),
path('delete/backup/<int:pk>/',
views.BackupDeleteView.as_view(), name='backup_delete'),
path('delete/backup/from-table/<int:pk>/',
views.BackupDeleteFromTableView.as_view(),
name='backup_delete_from-table'),
]

View File

@ -64,3 +64,11 @@ class BackupDeleteView(LoginRequiredMixin, DeleteView):
def get_success_url(self):
return reverse('computer', args=(self.object.computer.pk,))
class BackupDeleteFromTableView(LoginRequiredMixin, DeleteView):
model = Backup
template_name = 'backups/backup_confirm_delete.html'
def get_success_url(self):
return reverse('backups', args=(self.object.customer.pk,))