Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd0407c9

Browse files
committed
fix: display active events, fix time not displaying for some events
1 parentee0a7da commitd0407c9

File tree

3 files changed

+107
-50
lines changed

3 files changed

+107
-50
lines changed

‎events/models.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,15 @@ def previous_time(self):
211211
returnNone
212212

213213
@property
214-
defnext_or_previous_time(self):
215-
returnself.next_timeorself.previous_time
214+
defnext_or_previous_time(self)->models.Model:
215+
"""Return the next or previous time of the event OR the occurring rule."""
216+
ifnext_time:=self.next_time:
217+
returnnext_time
218+
219+
ifprevious_time:=self.previous_time:
220+
returnprevious_time
221+
222+
returnself.occurring_ruleifhasattr(self,"occurring_rule")elseNone
216223

217224
@property
218225
defis_past(self):

‎events/views.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,21 @@ def get_context_data(self, **kwargs):
4040

4141
classEventHomepage(ListView):
4242
""" Main Event Landing Page """
43-
template_name='events/event_list.html'
43+
template_name="events/event_list.html"
4444

45-
defget_queryset(self):
46-
returnEvent.objects.for_datetime(timezone.now()).order_by('occurring_rule__dt_start')
45+
defget_queryset(self)->Event:
46+
"""Queryset to return all events, ordered by START date."""
47+
returnEvent.objects.all().order_by("-occurring_rule__dt_start")
48+
49+
defget_context_data(self,**kwargs:dict)->dict:
50+
"""Add more ctx, specifically events that are happening now, just misse, and upcoming."""
51+
context=super().get_context_data(**kwargs)
52+
context["events_just_missed"]=Event.objects.until_datetime(timezone.now())[:2]
53+
context["upcoming_events"]=Event.objects.for_datetime(timezone.now())
54+
context["events_now"]=Event.objects.filter(
55+
occurring_rule__dt_start__lte=timezone.now(),
56+
occurring_rule__dt_end__gte=timezone.now())[:2]
57+
returncontext
4758

4859

4960
classEventDetail(DetailView):
@@ -68,11 +79,13 @@ def get_context_data(self, **kwargs):
6879
classEventList(EventListBase):
6980

7081
defget_queryset(self):
71-
returnEvent.objects.for_datetime(timezone.now()).filter(calendar__slug=self.kwargs['calendar_slug']).order_by('occurring_rule__dt_start')
82+
returnEvent.objects.for_datetime(timezone.now()).filter(calendar__slug=self.kwargs['calendar_slug']).order_by(
83+
'occurring_rule__dt_start')
7284

7385
defget_context_data(self,**kwargs):
7486
context=super().get_context_data(**kwargs)
75-
context['events_today']=Event.objects.until_datetime(timezone.now()).filter(calendar__slug=self.kwargs['calendar_slug'])[:2]
87+
context['events_today']=Event.objects.until_datetime(timezone.now()).filter(
88+
calendar__slug=self.kwargs['calendar_slug'])[:2]
7689
context['calendar']=get_object_or_404(Calendar,slug=self.kwargs['calendar_slug'])
7790
returncontext
7891

‎templates/events/event_list.html

Lines changed: 80 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,73 +8,110 @@
88

99
{% block header_content %}
1010
{% if featured %}
11-
<divclass="featured-event">
11+
<divclass="featured-event">
1212

13-
<h2class="welcome-message">Featured Python Event</h2>
13+
<h2class="welcome-message">Featured Python Event</h2>
1414

15-
<h1class="call-to-action">{{ featured.title|striptags }}</h1>
15+
<h1class="call-to-action">{{ featured.title|striptags }}</h1>
1616

17-
<pclass="event-date"><timedatetime="{{ featured.next_datetime.dt_start|date:'c' }}">
18-
{{ featured.next_datetime.dt_start|date:"l, F d, Y" }}
19-
</time></p>
20-
<pclass="excerpt">{{ featured.description.rendered|striptags|truncatewords:"60" }}<aclass="readmore"href="{{ featured.get_absolute_url }}">Read more</a></p>
21-
</div>
17+
<pclass="event-date">
18+
<timedatetime="{{ featured.next_datetime.dt_start|date:'c' }}">
19+
{{ featured.next_datetime.dt_start|date:"l, F d, Y" }}
20+
</time>
21+
</p>
22+
<pclass="excerpt">{{ featured.description.rendered|striptags|truncatewords:"60" }}<aclass="readmore"
23+
href="{{ featured.get_absolute_url }}">Read
24+
more</a></p>
25+
</div>
2226
{% endif %}
2327
{% endblock header_content %}
2428

25-
26-
{# Based on python/events.html #}
27-
2829
{% block content %}
2930

30-
{% if calendar %}
31+
{% if calendar %}
3132
<headerclass="article-header">
3233
<h3>from the {{ calendar.name }}</h3>
3334
</header>
34-
{% endif %}
35+
{% endif %}
3536

36-
<divclass="most-recent-events">
37+
<divclass="most-recent-events">
38+
{% if events_now %}
3739
<divclass="shrubbery">
38-
<h2class="widget-title"><spanaria-hidden="true"class="icon-calendar"></span>Upcoming Events</h2>
39-
{% if page_obj.has_next %}
40-
<pclass="give-me-more"><ahref="?page={{ page_obj.next_page_number }}"title="More Events">More</a></p>
41-
{% endif %}
40+
<h2class="widget-title"><spanaria-hidden="true"class="icon-calendar"></span>Happening Now</h2>
4241
<ulclass="list-recent-events menu">
43-
{% for object in object_list %}
42+
{% for object in events_now %}
43+
<li>
44+
<h3class="event-title"><a
45+
href="{{ object.get_absolute_url }}">{{ object.title|striptags }}</a></h3>
46+
<p>
47+
{% with object.occurring_rule as next_time %}
48+
{% include "events/includes/time_tag.html" %}
49+
{% endwith %}
50+
51+
{% if object.venue %}
52+
<spanclass="event-location">{% if object.venue.url %}
53+
<ahref="{{ object.venue.url }}">{% endif %}{{ object.venue.name }}
54+
{% if object.venue.url %}</a>{% endif %}{% if object.venue.address %},
55+
{{ object.venue.address }}{% endif %}</span>
56+
{% endif %}
57+
</p>
58+
</li>
59+
{% endfor %}
60+
</ul>
61+
</div>
62+
{% endif %}
63+
64+
<divclass="shrubbery">
65+
<h2class="widget-title"><spanaria-hidden="true"class="icon-calendar"></span>Upcoming Events</h2>
66+
{% if page_obj.has_next %}
67+
<pclass="give-me-more"><ahref="?page={{ page_obj.next_page_number }}"title="More Events">More</a></p>
68+
{% endif %}
69+
<ulclass="list-recent-events menu">
70+
{% for object in upcoming_events %}
4471
<li>
45-
<h3class="event-title"><ahref="{{ object.get_absolute_url }}">{{ object.title|striptags }}</a></h3>
72+
<h3class="event-title"><ahref="{{ object.get_absolute_url }}">{{ object.title|striptags }}</a>
73+
</h3>
4674
<p>
4775
{% with object.next_time as next_time %}
48-
{% include "events/includes/time_tag.html" %}
76+
{% include "events/includes/time_tag.html" %}
4977
{% endwith %}
5078

5179
{% if object.venue %}
52-
<spanclass="event-location">{% if object.venue.url %}<ahref="{{ object.venue.url }}">{% endif %}{{ object.venue.name }}{% if object.venue.url %}</a>{% endif %}{% if object.venue.address %}, {{ object.venue.address }}{% endif %}</span>
80+
<spanclass="event-location">{% if object.venue.url %}
81+
<ahref="{{ object.venue.url }}">{% endif %}{{ object.venue.name }}
82+
{% if object.venue.url %}</a>{% endif %}{% if object.venue.address %},
83+
{{ object.venue.address }}{% endif %}</span>
5384
{% endif %}
5485
</p>
5586
</li>
5687
{% endfor %}
57-
</ul>
58-
</div>
59-
60-
{% if events_today %}
61-
<h3class="widget-title just-missed">You just missed...</h3>
62-
<ulclass="list-recent-events menu">
63-
{% for object in events_today %}
64-
<li>
65-
<h3class="event-title"><ahref="{{ object.get_absolute_url }}">{{ object.title|striptags }}</a></h3>
66-
<p>
67-
{% with object.previous_time as next_time %}
68-
{% include "events/includes/time_tag.html" %}
69-
{% endwith %}
70-
71-
{% if object.venue %}
72-
<spanclass="event-location">{% if object.venue.url %}<ahref="{{ object.venue.url }}">{% endif %}{{ object.venue.name }}{% if object.venue.url %}</a>{% endif %}{% if object.venue.address %}, {{ object.venue.address }}{% endif %}</span>
73-
{% endif %}
74-
</p>
75-
</li>
76-
{% endfor %}
7788
</ul>
78-
{% endif %}
7989
</div>
90+
91+
{% if events_just_missed %}
92+
<divclass="shrubbery">
93+
<h3class="widget-title just-missed">You just missed...</h3>
94+
<ulclass="list-recent-events menu">
95+
{% for object in events_just_missed %}
96+
<li>
97+
<h3class="event-title"><a
98+
href="{{ object.get_absolute_url }}">{{ object.title|striptags }}</a></h3>
99+
<p>
100+
{% with object.previous_time as next_time %}
101+
{% include "events/includes/time_tag.html" %}
102+
{% endwith %}
103+
104+
{% if object.venue %}
105+
<spanclass="event-location">{% if object.venue.url %}
106+
<ahref="{{ object.venue.url }}">{% endif %}{{ object.venue.name }}
107+
{% if object.venue.url %}</a>{% endif %}{% if object.venue.address %},
108+
{{ object.venue.address }}{% endif %}</span>
109+
{% endif %}
110+
</p>
111+
</li>
112+
{% endfor %}
113+
</ul>
114+
</div>
115+
{% endif %}
116+
</div>
80117
{% endblock content %}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp