Add total member and event counts on org pages

This commit is contained in:
Michael Hall 2018-09-07 12:35:09 -04:00
parent 6179f5240d
commit 2d06dde5b7
2 changed files with 9 additions and 2 deletions

View file

@ -24,7 +24,7 @@
{% if can_edit_org %}
<div id="admin_buttons" class="mb-2">
<a href="{% url 'edit-org' org.slug %}" class="btn btn-secondary btn-sm"><i class="fa fa-pencil"></i> Edit Org</a>
<a href="#" class="btn btn-secondary btn-sm disabled"><i class="fa fa-users"></i> Manage Members</a>
<a href="#" class="btn btn-secondary btn-sm disabled"><i class="fa fa-users"></i> Manage Teams</a>
</div>
{% endif %}
{% if org.banner_img %}
@ -85,7 +85,9 @@
<div class="col-sm-3">
<div class="container container-secondary">
<h4>Member Teams</h4><hr/>
<h4>Teams</h4>
<small class="text-muted">{{member_count}} Members, {{event_count}} Events</small>
<hr/>
{% for member in member_list %}
<div class="row mb-3">
<div class="col media gt-profile">

View file

@ -28,6 +28,9 @@ def show_org(request, org_slug):
org = get_object_or_404(Organization, slug=org_slug)
upcoming_events = CommonEvent.objects.filter(organization=org, end_time__gt=datetime.datetime.now()).order_by('start_time')
recent_events = CommonEvent.objects.filter(organization=org, end_time__lte=datetime.datetime.now()).order_by('-start_time')[:5]
total_members = UserProfile.objects.filter(member__team__organization=org).distinct().count()
total_events= Event.objects.filter(team__organization=org).distinct().count()
context = {
'org': org,
'upcoming_events': upcoming_events,
@ -35,6 +38,8 @@ def show_org(request, org_slug):
'member_list': Team.objects.filter(organization=org).order_by('name'),
'can_create_event': request.user.profile.can_create_common_event(org),
'can_edit_org': request.user.profile.can_edit_org(org),
'member_count': total_members,
'event_count': total_events,
}
return render(request, 'get_together/orgs/show_org.html', context)