Commit 6f468f3b2a473ee454cb55e9b55bbb69d516bdc2
1 parent
477f37d2
Exists in
master
and in
39 other branches
Adding new chart on user profile
Showing
2 changed files
with
8 additions
and
2 deletions
Show diff stats
src/accounts/templates/accounts/user_detail.html
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | |
4 | 4 | {% block head_js %} |
5 | 5 | {% include "pizza-chart.html" with chart_data=type_count chart_div="collabs" chart_height=300 %} |
6 | - {% include "pizza-chart.html" with chart_div="collabs2" chart_height=300 %} | |
6 | + {% include "pizza-chart.html" with chart_data=list_activity chart_div="collabs2" chart_height=300 %} | |
7 | 7 | {% endblock %} |
8 | 8 | |
9 | 9 | {% block main-content %} | ... | ... |
src/accounts/views.py
... | ... | @@ -6,7 +6,7 @@ import datetime |
6 | 6 | from collections import OrderedDict |
7 | 7 | |
8 | 8 | from django.contrib import messages |
9 | - | |
9 | +from django.db.models import Count | |
10 | 10 | from django.contrib.auth import get_user_model |
11 | 11 | from django.views.generic import DetailView, UpdateView |
12 | 12 | from django.utils import timezone |
... | ... | @@ -83,6 +83,12 @@ class UserProfileDetailView(UserProfileBaseMixin, DetailView): |
83 | 83 | query = query.order_by('-received_time') |
84 | 84 | context['emails'] = query[:10] |
85 | 85 | |
86 | + count_by = 'thread__mailinglist__name' | |
87 | + messages = Message.objects.filter(from_address__user__pk=user.pk) | |
88 | + context['list_activity'] = dict(messages.values_list(count_by)\ | |
89 | + .annotate(Count(count_by))\ | |
90 | + .order_by(count_by)) | |
91 | + | |
86 | 92 | context.update(kwargs) |
87 | 93 | return super(UserProfileDetailView, self).get_context_data(**context) |
88 | 94 | ... | ... |