Browse Source

Update bulk delete project to avoid the constraint error

pull/1230/head
Hironsan 4 years ago
parent
commit
df6720d646
2 changed files with 8 additions and 2 deletions
  1. 9
      app/api/views/project.py
  2. 1
      frontend/components/project/FormCreate.vue

9
app/api/views/project.py

@ -21,11 +21,16 @@ class ProjectList(generics.ListCreateAPIView):
def delete(self, request, *args, **kwargs):
delete_ids = request.data['ids']
Project.objects.filter(
projects = Project.objects.filter(
role_mappings__user=self.request.user,
role_mappings__role__name=settings.ROLE_PROJECT_ADMIN,
pk__in=delete_ids
).delete()
)
# Todo: I want to use bulk delete.
# But it causes the constraint error.
# See https://github.com/django-polymorphic/django-polymorphic/issues/229
for project in projects:
project.delete()
return Response(status=status.HTTP_204_NO_CONTENT)

1
frontend/components/project/FormCreate.vue

@ -97,6 +97,7 @@ export default Vue.extend({
methods: {
translateTypeName(type: string, types: string[]): string {
// @ts-ignore
const index = this.projectTypes.indexOf(type)
return types[index]
}

Loading…
Cancel
Save