Skip to content
Snippets Groups Projects
Commit 5d359d05 authored by Erin Mullaney's avatar Erin Mullaney Committed by Todd Dembrey
Browse files

810 filter rounds for leads/staff only, adjust round block title

parent 13eca901
No related branches found
No related tags found
No related merge requests found
......@@ -345,6 +345,9 @@ class RoundsAndLabsQueryset(PageQuerySet):
def closed(self):
return self.filter(end_date__lt=date.today())
def by_lead(self, user):
return self.filter(lead_pk=user.pk)
class RoundsAndLabsProgressQueryset(RoundsAndLabsQueryset):
def active(self):
......@@ -367,6 +370,10 @@ class RoundsAndLabsManager(PageManager):
end_date=F('roundbase__end_date'),
parent_path=Left(F('path'), Length('path') - ApplicationBase.steplen, output_field=CharField()),
fund=Subquery(funds.values('title')[:1]),
lead_pk=Coalesce(
F('roundbase__lead__pk'),
F('labbase__lead__pk'),
),
)
def with_progress(self):
......@@ -406,6 +413,9 @@ class RoundsAndLabsManager(PageManager):
def new(self):
return self.get_queryset().new()
def by_lead(self, user):
return self.get_queryset().by_lead(user)
class RoundsAndLabs(Page):
"""
......
<div class="wrapper wrapper--bottom-space">
<section class="section section--with-options">
<h4 class="heading heading--normal heading--no-margin">All Rounds and Labs</h4>
<h4 class="heading heading--normal heading--no-margin">Your Rounds and Labs</h4>
<div class="js-tabs">
<a class="tab__item tab__item--alt" href="#closed-rounds" data-tab="tab-1">Closed</a>
<a class="tab__item tab__item--alt" href="#open-rounds" data-tab="tab-2">Open</a>
......
......@@ -14,6 +14,11 @@
</div>
<div class="wrapper wrapper--large wrapper--inner-space-medium">
{% if closed_rounds or open_rounds %}
{% include "funds/includes/round-block.html" with closed_rounds=closed_rounds open_rounds=open_rounds %}
{% endif %}
{% block table %}
{{ block.super }}
{% endblock %}
......
......@@ -89,19 +89,24 @@ class SubmissionOverviewView(AllActivityContextMixin, BaseAdminSubmissionsTable)
return super().get_table_data().order_by(F('last_update').desc(nulls_last=True))[:5]
def get_context_data(self, **kwargs):
base_query = RoundsAndLabs.objects.with_progress().order_by('end_date')
open_rounds = base_query.open()[:6]
open_query = '?round_state=open'
closed_rounds = base_query.closed()[:6]
closed_query = '?round_state=closed'
return super().get_context_data(
open_rounds=open_rounds,
open_query=open_query,
closed_rounds=closed_rounds,
closed_query=closed_query,
**kwargs,
)
# For OTF staff, display rounds/labs where user is the lead
if self.request.user.is_staff:
base_query = RoundsAndLabs.objects.with_progress().active().order_by('-end_date')
base_query = base_query.by_lead(self.request.user)
open_rounds = base_query.open()[:6]
open_query = '?round_state=open'
closed_rounds = base_query.closed()[:6]
closed_query = '?round_state=closed'
return super().get_context_data(
open_rounds=open_rounds,
open_query=open_query,
closed_rounds=closed_rounds,
closed_query=closed_query,
**kwargs,
)
else:
return super().get_context_data(**kwargs)
class SubmissionListView(AllActivityContextMixin, BaseAdminSubmissionsTable):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment