update meeting show at home (shows last and next one), update clean function of meeting

This commit is contained in:
2020-09-03 13:58:39 +00:00
parent 05aa3ddf5d
commit 992ddcced1
6 changed files with 54 additions and 26 deletions

View File

@@ -22,7 +22,7 @@ def index(request):
'posts': posts, 'posts': posts,
'events': Event.objects.get_five_events(), 'events': Event.objects.get_five_events(),
'featured_post': featured_post, 'featured_post': featured_post,
'featured_post2': FetMeeting.objects.first(), 'featured_meeting': deque(FetMeeting.objects.get_meetings()),
'tags_list': ", ".join(t) 'tags_list': ", ".join(t)
} }

View File

@@ -76,6 +76,24 @@ class FetMeetingManager(models.Manager):
def get_queryset(self): def get_queryset(self):
return super().get_queryset().filter(Q(post_type='F')) return super().get_queryset().filter(Q(post_type='F'))
def _get_last_meeting(self):
date_today = timezone.now()
return self.get_queryset().filter(
Q(event_start__lt=date_today)
).order_by('-event_start').first()
def _get_next_meeting(self):
date_today = timezone.now()
return self.get_queryset().filter(
Q(event_start__gt=date_today)
).order_by('event_start').first()
def get_meetings(self):
meetings = []
meetings.append(self._get_next_meeting())
meetings.append(self._get_last_meeting())
return meetings
########## ##########
# MODELS # # MODELS #
@@ -297,7 +315,8 @@ class FetMeeting(Event):
slug = slugify(self.event_start.date()) + "-" + slugify("Fachschaftssitzung") slug = slugify(self.event_start.date()) + "-" + slugify("Fachschaftssitzung")
if Post.objects.filter(slug=slug).count() != 0: if Post.objects.filter(slug=slug).exists():
if Post.objects.get(slug=slug).id != self.id:
raise ValidationError(_('Es existiert bereits eine Sitzung mit demselben Datum.')) raise ValidationError(_('Es existiert bereits eine Sitzung mit demselben Datum.'))
def save(self, *args, **kwargs): def save(self, *args, **kwargs):

View File

@@ -34,9 +34,9 @@
{% with post=featured_post %} {% with post=featured_post %}
{% include 'posts/partials/_article_row.html' %} {% include 'posts/partials/_article_row.html' %}
{% endwith %} {% endwith %}
{% with post=featured_post2 %} {% for post in featured_meeting %}
{% include 'posts/partials/_article_row.html' %} {% include 'posts/partials/_meeting_row.html' %}
{% endwith %} {% endfor %}
</div> </div>
</div> </div>

View File

@@ -1,15 +1,12 @@
<a href="{{post.url}}"> <a href="{{post.url}}">
<article class="article-row"> <article class="article-row">
<div class="article-row-content"> <div class="article-row-content">
<h1 class="article-row-content-header">{{post.title}}</h1> <h1 class="article-row-content-header">{{post.title}}</h1>
{% if post.subtitle is not None %}
<p class="article-row-content-description">{{post.subtitle}}</p> <p class="article-row-content-description">{{post.subtitle}}</p>
{% endif %}
<p class="article-row-content-author">{{post.author}}</p> <p class="article-row-content-author">{{post.author}}</p>
<time class="article-row-content-time" datetime="2008-02-14 20:00">{{post.public_date}}</time> <time class="article-row-content-time" datetime="2008-02-14 20:00">{{post.public_date}}</time>
</div> </div>
</article> </article>
</a> </a>

View File

@@ -4,7 +4,8 @@
<span class="date-badge badge primary" style=""> <span class="date-badge badge primary" style="">
<span class="date-badge-day">{{post.event_start_day}}</span> <span class="date-badge-day">{{post.event_start_day}}</span>
<span class="date-badge-month">{{post.event_start_month}}</span> <span class="date-badge-month">{{post.event_start_month}}</span>
</span></span> </span>
</span>
<span class="date-text"><strong>{{post.title}}</strong></span> <span class="date-text"><strong>{{post.title}}</strong></span>
</div>
</div></a> </a>

View File

@@ -0,0 +1,11 @@
<a href="{{post.url}}">
<article class="article-row">
<div class="article-row-content">
<h1 class="article-row-content-header">{{post.title}}</h1>
{% if post.subtitle is not None %}
<p class="article-row-content-description">{{post.subtitle}}</p>
{% endif %}
<time class="article-row-content-time" datetime="2008-02-14 20:00">{{post.event_start}}</time>
</div>
</article>
</a>