Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

671 filtering activities by label #849

Merged
merged 7 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions amelie/activities/templates/activity_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ <h2>{% trans "Activities you don't want to miss" %}</h2>
{% if not only_open_enrollments or activity.enrollment_open %}
<tr{% if activity.dutch_activity %} class="dutch-only"{% endif %}>
<td class="activity-list-date">

<a href="{{ activity.get_calendar_url }}">
<span class="icon icon-calendar"
title="{% trans 'iCal document with activity' %}"></span>
Expand All @@ -50,15 +49,21 @@ <h2>{% trans "Activities you don't want to miss" %}</h2>
{{ activity.begin|date:"d-b (D)" }}
</td>
<td>
<div class="activity-list-label"
style="background: #{{ activity.activity_label.color }};">
<span class="activity-list-label-name">
{{ activity.activity_label.name }}
</span>
</div>
<div class="activity-list-label-icon">
<img src="{{STATIC_URL}}img/icons/{{ activity.activity_label.icon }}.png" alt="{{ activity.activity_label.name }}">
</div>
<a
{% if activity.activity_label.name %}
href="{% url 'activities:activities_type' act_type=activity.activity_label.name %}"
{% endif %}
style="padding: 0px; margin: 0px;"
>
<div class="activity-list-label" style="background: #{{ activity.activity_label.color }};">
<span class="activity-list-label-name">
{{ activity.activity_label.name }}
</span>
</div>
<div class="activity-list-label-icon">
<img src="{{STATIC_URL}}img/icons/{{ activity.activity_label.icon }}.png" alt="{{ activity.activity_label.name }}">
</div>
</a>
</td>
<td>
<img class="dutch-indicator" src="{{ STATIC_URL }}img/layout/flag_nl.png"
Expand All @@ -79,7 +84,11 @@ <h2>{% trans "Activities you don't want to miss" %}</h2>
</table>
</div>
{% else %}
<p class="icon warning">{% trans 'There are no planned events. Maybe because it is holiday?' %}</p>
{% if act_type %}
<p class="icon warning">{% blocktrans with type=act_type %}It looks like there are no events with label {{ type }}{% endblocktrans %}</p>
{% else %}
<p class="icon warning">{% trans 'There are no planned events. Maybe because it is holiday?' %}</p>
{% endif %}
{% endif %}

{% if request.person.current_committees|length > 0 or request.person.is_board %}
Expand Down
1 change: 1 addition & 0 deletions amelie/activities/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
urlpatterns = [
# URLs that are not about a specific activity
path('', views.activities, name='activities'),
path('<str:act_type>', views.activities, name='activities_type'),
path('old/', views.activities_old, name='activities_old'),
# URLs about the photo gallery
path('photos/', views.photos, name='photos'),
Expand Down
6 changes: 5 additions & 1 deletion amelie/activities/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,15 @@ def activity_ics(request, pk):
return resp


def activities(request):
def activities(request, act_type=None):
"""
Gives an overview of all upcoming activities and recent past activities.
"""
activities = Event.objects.filter_public(request)

if act_type:
activities = activities.filter(Q(activity__activity_label__name_en=act_type) | Q(activity__activity_label__name_nl=act_type))

old_activities = list(activities.filter(end__lt=timezone.now()))[-10:]
new_activities = list(activities.filter(end__gte=timezone.now()))

Expand Down
4 changes: 3 additions & 1 deletion amelie/calendar/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ def save(self, *args, **kwargs):

def description_short(self):
char_limit = 150
total_string = f"{self.begin.strftime('%d/%m/%Y, %H:%M')} @{self.location} {self.promo_en}"
location_prefix = " @" if self.location is not "" else ""
activity_prefix = (self.as_leaf_class().activity_label.name_en + " - ") if self.as_leaf_class().activity_label else ""
total_string = f"{activity_prefix}{self.begin.strftime('%d/%m/%Y, %H:%M')}{location_prefix}{self.location} {self.promo_en}"

if len(total_string) > char_limit:
total_string = total_string[:char_limit] + '...'
Expand Down
2 changes: 1 addition & 1 deletion amelie/weekmail/templates/weekmail/weekmail_mail_html.mail
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,4 @@


</div>
</body>
</body>
Binary file removed locale/nl/LC_MESSAGES/django.mo
Binary file not shown.
Loading
Loading