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 %} -
+ {% csrf_token %} {{ form.as_table() }}
diff --git a/templates/organization/home.html b/templates/organization/home.html index 40839fa..0a5c31e 100644 --- a/templates/organization/home.html +++ b/templates/organization/home.html @@ -1,17 +1,38 @@ {% extends "base.html" %} -{% block title_row %}{% endblock %} -{% block title_ruler %}{% endblock %} - +{% endblock %} {% block js_media %} {% endblock %} +{% block title_row %} +
+
+

{{title}}

+ + + {% if request.user.is_authenticated %} + {% if is_member or can_edit %} + + {% elif organization.is_open or can_edit %} + + {% csrf_token %} + + + {% else %} + {{ _('Request membership') }} + {% endif %} + {% endif %} + +
+
+{% endblock %} +{% block title_ruler %} {% endblock %} {% block body %} {% block before_posts %}{% endblock %}
@@ -59,7 +109,7 @@
{% endif %} diff --git a/templates/organization/requests/log.html b/templates/organization/requests/log.html index c05651b..73a7b8c 100644 --- a/templates/organization/requests/log.html +++ b/templates/organization/requests/log.html @@ -4,7 +4,7 @@ {% include "organization/requests/tabs.html" %} {% if requests %} - +
diff --git a/templates/organization/requests/pending.html b/templates/organization/requests/pending.html index 302ba62..3d300a4 100644 --- a/templates/organization/requests/pending.html +++ b/templates/organization/requests/pending.html @@ -7,7 +7,7 @@ {% csrf_token %} {{ formset.management_form }} -
{{ _('User') }} {{ _('Time') }}
+
{{ _('User') }} {{ _('Time') }}