update meeting show at home (shows last and next one), update clean function of meeting
This commit is contained in:
@@ -22,7 +22,7 @@ def index(request):
|
||||
'posts': posts,
|
||||
'events': Event.objects.get_five_events(),
|
||||
'featured_post': featured_post,
|
||||
'featured_post2': FetMeeting.objects.first(),
|
||||
'featured_meeting': deque(FetMeeting.objects.get_meetings()),
|
||||
'tags_list': ", ".join(t)
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,24 @@ class FetMeetingManager(models.Manager):
|
||||
def get_queryset(self):
|
||||
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 #
|
||||
@@ -297,7 +315,8 @@ class FetMeeting(Event):
|
||||
|
||||
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.'))
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
|
||||
@@ -34,9 +34,9 @@
|
||||
{% with post=featured_post %}
|
||||
{% include 'posts/partials/_article_row.html' %}
|
||||
{% endwith %}
|
||||
{% with post=featured_post2 %}
|
||||
{% include 'posts/partials/_article_row.html' %}
|
||||
{% endwith %}
|
||||
{% for post in featured_meeting %}
|
||||
{% include 'posts/partials/_meeting_row.html' %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
<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 %}
|
||||
<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>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
</a>
|
||||
@@ -4,7 +4,8 @@
|
||||
<span class="date-badge badge primary" style="">
|
||||
<span class="date-badge-day">{{post.event_start_day}}</span>
|
||||
<span class="date-badge-month">{{post.event_start_month}}</span>
|
||||
</span></span>
|
||||
</span>
|
||||
</span>
|
||||
<span class="date-text"><strong>{{post.title}}</strong></span>
|
||||
|
||||
</div></a>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
11
fet2020/templates/posts/partials/_meeting_row.html
Normal file
11
fet2020/templates/posts/partials/_meeting_row.html
Normal 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>
|
||||
Reference in New Issue
Block a user