Fix admin bugs

This commit is contained in:
cuom1999 2024-06-01 01:37:29 -05:00
parent bb891e5b49
commit 570c3071ee
5 changed files with 7 additions and 13 deletions

View file

@ -77,7 +77,6 @@ from judge.views.register import ActivationView, RegistrationView
from judge.views.select2 import (
AssigneeSelect2View,
ChatUserSearchSelect2View,
CommentSelect2View,
ContestSelect2View,
ContestUserSearchSelect2View,
OrganizationSelect2View,
@ -1066,9 +1065,6 @@ urlpatterns = [
url(
r"^contest/$", ContestSelect2View.as_view(), name="contest_select2"
),
url(
r"^comment/$", CommentSelect2View.as_view(), name="comment_select2"
),
]
),
),

View file

@ -12,7 +12,6 @@ class CommentForm(ModelForm):
class Meta:
widgets = {
"author": AdminHeavySelect2Widget(data_view="profile_select2"),
"parent": AdminHeavySelect2Widget(data_view="comment_select2"),
}
if HeavyPreviewAdminPageDownWidget is not None:
widgets["body"] = HeavyPreviewAdminPageDownWidget(
@ -39,7 +38,7 @@ class CommentAdmin(VersionAdmin):
)
list_display = ["author", "linked_object", "time"]
search_fields = ["author__user__username", "body"]
readonly_fields = ["score"]
readonly_fields = ["score", "parent"]
actions = ["hide_comment", "unhide_comment"]
list_filter = ["hidden"]
actions_on_top = True

View file

@ -53,6 +53,7 @@ class NavigationBarAdmin(DraggableMPTTAdmin):
class BlogPostForm(ModelForm):
def __init__(self, *args, **kwargs):
super(BlogPostForm, self).__init__(*args, **kwargs)
if "authors" in self.fields:
self.fields["authors"].widget.can_add_related = False
class Meta:

View file

@ -51,7 +51,10 @@ class ProblemDataStorage(FileSystemStorage):
def delete_directory(self, name):
directory_path = self.path(name)
try:
shutil.rmtree(directory_path)
except FileNotFoundError:
pass
class ProblemDataError(Exception):

View file

@ -98,11 +98,6 @@ class ContestSelect2View(Select2View):
return q
class CommentSelect2View(Select2View):
def get_queryset(self):
return Comment.objects.filter(page__icontains=self.term)
class UserSearchSelect2View(BaseListView):
paginate_by = 20