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> <p>More from MUMUS:</p>
</th></tr> </th></tr>
{{ gap }} {{ gap }}
<tr> <!-- Digest Content 2 columns--> <tr> <!-- Digest Content 3 columns-->
{% for item in more %} <table class="row"><tbody><tr>
<th class="small-12 large-4 columns{% if loop.first %} first{% endif %}{% if loop.last %} last{% endif %}"> {% for item in more %}
{% 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 %} <th class="small-12 large-4 columns{% if loop.first %} first{% endif %}{% if loop.last %} last{% endif %}">
<b><h5>{{ item.title }}</h5></b> {% 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 %}
<p>{{ item.content }}</p> <b><h5>{{ item.title }}</h5></b>
{% if item.link %}<p><a href="{{ item.link }}">Read more &#x203A;</a></p>{% endif %} <p>{{ item.content|striptags|truncate(100) }}</p>
</th> {% if item.link %}<p><a href="{{ item.link }}">Read more &#x203A;</a></p>{% endif %}
{% endfor %} <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> </tr>
{% endif %} {% endif %}
{% endblock content %} {% endblock content %}

View File

@ -64,11 +64,28 @@ def bulletin_args(member, groups, events, bulbegin, bulend):
'bulletin_items': items '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 { return {
'member': member, 'member': member,
'events': events, 'events': events,
'groups': groups_data, 'groups': groups_data,
'more': [], # TODO 'more': more,
'bulbegin': bulbegin, 'bulbegin': bulbegin,
'bulend': bulend 'bulend': bulend
} }