diff --git a/judge/views/organization.py b/judge/views/organization.py index 96a98fd..057e617 100644 --- a/judge/views/organization.py +++ b/judge/views/organization.py @@ -11,6 +11,7 @@ from django.forms import Form, modelformset_factory from django.http import Http404, HttpResponsePermanentRedirect, HttpResponseRedirect from django.urls import reverse from django.utils import timezone +from django.utils.safestring import mark_safe from django.utils.translation import gettext as _, gettext_lazy, ungettext from django.views.generic import DetailView, FormView, ListView, UpdateView, View from django.views.generic.detail import SingleObjectMixin, SingleObjectTemplateResponseMixin @@ -114,6 +115,7 @@ class OrganizationHome(OrganizationDetailView): Comment.objects.filter(page__in=['b:%d' % post.id for post in context['posts']], hidden=False) .values_list('page').annotate(count=Count('page')).order_by() } + context['pending_count'] = OrganizationRequest.objects.filter(state='P', organization=self.object).count() return context @@ -230,7 +232,7 @@ class OrganizationRequestDetail(LoginRequiredMixin, TitleMixin, DetailView): OrganizationRequestFormSet = modelformset_factory(OrganizationRequest, extra=0, fields=('state',), can_delete=True) -class OrganizationRequestBaseView(LoginRequiredMixin, SingleObjectTemplateResponseMixin, SingleObjectMixin, View): +class OrganizationRequestBaseView(TitleMixin, LoginRequiredMixin, SingleObjectTemplateResponseMixin, SingleObjectMixin, View): model = Organization slug_field = 'key' slug_url_kwarg = 'key' @@ -243,6 +245,10 @@ class OrganizationRequestBaseView(LoginRequiredMixin, SingleObjectTemplateRespon raise PermissionDenied() return organization + def get_content_title(self): + href = reverse('organization_home', args=[self.object.id, self.object.slug]) + return mark_safe(f'Manage join requests for {self.object.name}') + def get_context_data(self, **kwargs): context = super(OrganizationRequestBaseView, self).get_context_data(**kwargs) context['title'] = _('Managing join requests for %s') % self.object.name diff --git a/templates/organization/edit.html b/templates/organization/edit.html index 5336f73..996c2b9 100644 --- a/templates/organization/edit.html +++ b/templates/organization/edit.html @@ -40,7 +40,7 @@ {% endblock %} {% block body %} -