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")
|
||||
|
|
|
@ -112,10 +112,6 @@ class Organization(models.Model):
|
|||
def get_contests_url(self):
|
||||
return reverse("organization_contests", args=(self.id, self.slug))
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
self.members.add(*self.admins.all())
|
||||
super(Organization, self).save(*args, **kwargs)
|
||||
|
||||
class Meta:
|
||||
ordering = ["name"]
|
||||
permissions = (
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<tr>
|
||||
<td style="padding: 7px 2px"><b>{{loop.index}}</b></td>
|
||||
<td style="line-break: anywhere">{{link_user(user)}}</td>
|
||||
<td>{{user.rating}}</td>
|
||||
<td>{{user.rating or '_'}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
Loading…
Reference in a new issue