Implement bulletin more view

This commit is contained in:
Yingtong Li 2019-02-13 15:17:43 +11:00
parent e19e191a77
commit 229b193b25
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 30 additions and 10 deletions

View File

@ -90,15 +90,18 @@
<p>More from MUMUS:</p>
</th></tr>
{{ gap }}
<tr> <!-- Digest Content 2 columns-->
<tr> <!-- Digest Content 3 columns-->
<table class="row"><tbody><tr>
{% for item in more %}
<th class="small-12 large-4 columns{% if loop.first %} first{% endif %}{% if loop.last %} last{% endif %}">
{% if item.image %}{% if item.link %}<a href="{{ item.link }}">{% endif %}<img src="{{ MEDIA_URL }}{{ item.image }}" alt="{{ item.title }}">{% if item.link %}</a>{% endif %}<br>{% endif %}
<b><h5>{{ item.title }}</h5></b>
<p>{{ item.content }}</p>
<p>{{ item.content|striptags|truncate(100) }}</p>
{% if item.link %}<p><a href="{{ item.link }}">Read more &#x203A;</a></p>{% endif %}
<p style="font-size: 8pt;"><a href="https://{{ settings.ALLOWED_HOSTS[0] }}{{ url('membership') }}">Subscribe to {{ item.group.name }}</a></p>
</th>
{% endfor %}
</tr></tbody></table>
</tr>
{% endif %}
{% endblock content %}

View File

@ -64,11 +64,28 @@ def bulletin_args(member, groups, events, bulbegin, bulend):
'bulletin_items': items
})
more = []
all_groups = models.Group.objects.all()
for group in all_groups:
if group in groups:
continue
if not group.subscribable:
continue
for item in group.bulletinitem_set.filter(date__gte=bulbegin).filter(date__lt=bulend).all():
# Check also_limit
# Allow matching across all groups, but only subscribable ones
if member is None or len(item.also_limit) == 0 or any(any(g.id == x and g.subscribable for g in all_groups) for x in item.also_limit):
more.append(item)
if len(more) >= 3:
break
return {
'member': member,
'events': events,
'groups': groups_data,
'more': [], # TODO
'more': more,
'bulbegin': bulbegin,
'bulend': bulend
}