mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-06 09:57:57 +00:00
Updated event display algorithm on home page.
The homepage will now display seven events, allowing up to two events that are not community badged to be present.
This commit is contained in:
@ -41,13 +41,18 @@ from forms import OrganisationForm, MergeOrgsForm
|
||||
@cache(minutes=10)
|
||||
def home(request):
|
||||
news = NewsArticle.objects.filter(approved=True)[:5]
|
||||
# get the first five community events
|
||||
events = Event.objects.select_related('country').filter(
|
||||
# get up to seven events to display on the homepage
|
||||
event_base_queryset = Event.objects.select_related('country').filter(
|
||||
approved=True,
|
||||
training=False,
|
||||
enddate__gte=date.today(),
|
||||
badged=True,
|
||||
).order_by('enddate', 'startdate')[:5]
|
||||
)
|
||||
# first, see if there are up to do non-badged events
|
||||
other_events = event_base_queryset.filter(badged=False)[:2]
|
||||
# based on that, get 7 - |other_events| community events to display
|
||||
community_event_queryset = event_base_queryset.filter(badged=True)[:(7 - other_events.count())]
|
||||
# now, return all the events in one unioned array!
|
||||
events = community_event_queryset.union(other_events).order_by('enddate', 'startdate').all()
|
||||
versions = Version.objects.filter(supported=True)
|
||||
planet = ImportedRSSItem.objects.filter(feed__internalname="planet").order_by("-posttime")[:9]
|
||||
|
||||
|
Reference in New Issue
Block a user