Make admin a little smarter
This commit is contained in:
parent
1b3b27f1d9
commit
a78f1db5e6
4 changed files with 10 additions and 5 deletions
|
@ -288,6 +288,10 @@ class ContestAdmin(CompareVersionAdmin):
|
|||
# Only rescored if we did not already do so in `save_model`
|
||||
if not self._rescored and any(formset.has_changed() for formset in formsets):
|
||||
self._rescore(form.cleaned_data["key"])
|
||||
obj = form.instance
|
||||
obj.is_organization_private = obj.organizations.count() > 0
|
||||
obj.is_private = obj.private_contestants.count() > 0
|
||||
obj.save()
|
||||
|
||||
def has_change_permission(self, request, obj=None):
|
||||
if not request.user.has_perm("judge.edit_own_contest"):
|
||||
|
|
|
@ -81,6 +81,11 @@ class OrganizationAdmin(VersionAdmin):
|
|||
return True
|
||||
return obj.admins.filter(id=request.profile.id).exists()
|
||||
|
||||
def save_related(self, request, form, formsets, change):
|
||||
super().save_related(request, form, formsets, change)
|
||||
obj = form.instance
|
||||
obj.members.add(*obj.admins.all())
|
||||
|
||||
|
||||
class OrganizationRequestAdmin(admin.ModelAdmin):
|
||||
list_display = ("username", "organization", "state", "time")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue