fix published draft posts in calendar
This commit is contained in:
@@ -7,12 +7,25 @@ from datetime import timedelta
|
||||
|
||||
class PublishedManager(Manager):
|
||||
def published(self, public=True):
|
||||
"""
|
||||
publish all posts with status 'PUBLIC'
|
||||
"""
|
||||
if public:
|
||||
qs = self.get_queryset().filter(status="20")
|
||||
else:
|
||||
qs = self.get_queryset()
|
||||
return qs
|
||||
|
||||
def published_all(self, public=True):
|
||||
"""
|
||||
publish all posts with status 'PUBLIC' and 'ONLY_INTERN'
|
||||
"""
|
||||
if public:
|
||||
qs = self.get_queryset().filter(~Q(status="10"))
|
||||
else:
|
||||
qs = self.get_queryset()
|
||||
return qs
|
||||
|
||||
|
||||
class PostManager(PublishedManager, Manager):
|
||||
def get_queryset(self):
|
||||
@@ -83,7 +96,6 @@ class ArticleManager(PublishedManager, Manager):
|
||||
Provide a query set only for "Article"
|
||||
regular fet meetings should not be contained in the news stream
|
||||
"""
|
||||
|
||||
def get_queryset(self):
|
||||
qs = super().get_queryset().filter(Q(post_type="E") | Q(post_type="N"))
|
||||
return qs.order_by("-public_date")
|
||||
@@ -109,7 +121,6 @@ class NewsManager(PublishedManager, Manager):
|
||||
"""
|
||||
Provide a query set only for "News"
|
||||
"""
|
||||
|
||||
def get_queryset(self):
|
||||
return super().get_queryset().filter(post_type="N").order_by("-public_date")
|
||||
|
||||
@@ -118,7 +129,6 @@ class AllEventManager(PublishedManager, Manager):
|
||||
"""
|
||||
Provide a query set for all events ("Event" and "Fet Meeting")
|
||||
"""
|
||||
|
||||
def get_queryset(self):
|
||||
return (
|
||||
super()
|
||||
@@ -138,7 +148,6 @@ class EventManager(PublishedManager, Manager):
|
||||
Provide a query set only for "Events"
|
||||
regular fet meetings should not be contained in the news stream
|
||||
"""
|
||||
|
||||
def get_queryset(self):
|
||||
return super().get_queryset().filter(post_type="E").order_by("-event_start")
|
||||
|
||||
@@ -157,7 +166,6 @@ class FetMeetingManager(PublishedManager, Manager):
|
||||
"""
|
||||
Provide a query set only for "Fet Meeting"
|
||||
"""
|
||||
|
||||
def get_queryset(self):
|
||||
return super().get_queryset().filter(post_type="F").order_by("-event_start")
|
||||
|
||||
|
||||
@@ -83,8 +83,8 @@ def calendar(request):
|
||||
"""
|
||||
ICS-calendar for outlook, google calender,...
|
||||
"""
|
||||
# publish all events independent of authenticated user
|
||||
events = Event.all_events.published(False)
|
||||
# publish all events with status 'PUBLIC' and 'ONLY_INTERN' independent of authenticated user
|
||||
events = Event.all_events.published_all(True)
|
||||
|
||||
context = {
|
||||
"events": events,
|
||||
|
||||
Reference in New Issue
Block a user