Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Repo Deletion to Django Admin #1137

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from codecov.admin import AdminMixin
from codecov_auth.models import RepositoryToken
from core.models import Pull, Repository
from services.task.task import TaskService


class RepositoryTokenInline(admin.TabularInline):
Expand Down Expand Up @@ -90,12 +91,19 @@
"webhook_secret",
)

def has_delete_permission(self, request, obj=None):
return False

def has_add_permission(self, _, obj=None):
return False

def has_delete_permission(self, request, obj=None):
return bool(request.user and request.user.is_superuser)

def delete_queryset(self, request, queryset) -> None:
for repo in queryset:
TaskService().flush_repo(repository_id=repo.repoid)

Check warning on line 102 in core/admin.py

View check run for this annotation

Codecov Notifications / codecov/patch

core/admin.py#L101-L102

Added lines #L101 - L102 were not covered by tests

def delete_model(self, request, obj) -> None:
TaskService().flush_repo(repository_id=obj.repoid)

Check warning on line 105 in core/admin.py

View check run for this annotation

Codecov Notifications / codecov/patch

core/admin.py#L105

Added line #L105 was not covered by tests


@admin.register(Pull)
class PullsAdmin(AdminMixin, admin.ModelAdmin):
Expand Down
Loading