-
+
+
+
@@ -91,7 +93,9 @@
-
+
+
+
diff --git a/src/accounts/views.py b/src/accounts/views.py
index e298cbdb..8b17f0de 100644
--- a/src/accounts/views.py
+++ b/src/accounts/views.py
@@ -2,6 +2,7 @@
# encoding: utf-8
import datetime
+import pygal
from collections import OrderedDict
@@ -20,6 +21,7 @@
from conversejs.models import XMPPAccount
from haystack.query import SearchQuerySet
+from colab.utils.pygal_render import render_pie_chart
from super_archives.models import EmailAddress, Message
from super_archives.utils.email import send_email_lists
from search.utils import trans
@@ -89,7 +91,14 @@ def get_context_data(self, **kwargs):
sqs = sqs.filter_or(type=type, **filter_or)
count_types[trans(type)] = sqs.count()
- context['type_count'] = count_types
+ PIE_WIDTH = 350
+ PIE_HEIGHT = 300
+ NO_DATA_TEXT = _(u'No data found')
+
+ context['contributions_chart'] = render_pie_chart(
+ count_types, width=PIE_WIDTH, height=PIE_HEIGHT,
+ no_data_text=NO_DATA_TEXT
+ )
sqs = SearchQuerySet()
for filter_or in fields_or_lookup:
@@ -103,10 +112,15 @@ def get_context_data(self, **kwargs):
context['emails'] = query[:10]
count_by = 'thread__mailinglist__name'
- context['list_activity'] = dict(messages.values_list(count_by)\
+ list_activity_count = dict(messages.values_list(count_by)\
.annotate(Count(count_by))\
.order_by(count_by))
+ context['list_activity_chart'] = render_pie_chart(
+ list_activity_count, width=PIE_WIDTH, height=PIE_HEIGHT,
+ no_data_text=NO_DATA_TEXT
+ )
+
context.update(kwargs)
return super(UserProfileDetailView, self).get_context_data(**context)
diff --git a/src/colab/utils/pygal_render.py b/src/colab/utils/pygal_render.py
new file mode 100644
index 00000000..ae55584b
--- /dev/null
+++ b/src/colab/utils/pygal_render.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+
+import pygal
+
+from colab.utils.pygal_style import CustomLightStyle
+
+
+def render_pie_chart(count_dict, style=CustomLightStyle, width=None,
+ height=None, no_data_text='', value_font_size=15,
+ explicit_size=True):
+
+ pie_chart = pygal.Pie(style=style, width=width, height=height,
+ no_data_text=no_data_text,
+ value_font_size=value_font_size,
+ explicit_size=explicit_size)
+
+ for count in tuple(count_dict.items()):
+ pie_chart.add(count[0], count[1])
+
+ return pie_chart.make_instance(
+ overrides={'disable_xml_declaration': True}
+ ).render(is_unicode=True)
diff --git a/src/colab/utils/pygal_style.py b/src/colab/utils/pygal_style.py
new file mode 100644
index 00000000..ab26d136
--- /dev/null
+++ b/src/colab/utils/pygal_style.py
@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+
+from pygal.style import Style
+
+
+CustomLightStyle = Style(
+ background = 'transparent',
+ plot_background = 'transparent',
+ foreground='rgba(0, 0, 0, 0.7)',
+ foreground_light='rgba(0, 0, 0, 0.9)',
+ foreground_dark='rgba(0, 0, 0, 0.5)',
+ colors=('#0f9517', '#3366cc', '#dc3912',
+ '#ff9900', '#990099', '#22aa99',
+ '#aaaa11', '#dd4477', '#316395',
+ '#7A2F16', '#4A0149', '#cccccc')
+)
diff --git a/src/home/views.py b/src/home/views.py
index 404e23f2..e05c7ec5 100644
--- a/src/home/views.py
+++ b/src/home/views.py
@@ -1,14 +1,19 @@
+# -*- coding: utf-8 -*-
+
+import pygal
from collections import OrderedDict
from django.core.cache import cache
from django.shortcuts import render
+from django.utils.translation import ugettext as _
from search.utils import trans
from haystack.query import SearchQuerySet
from proxy.models import WikiCollabCount, TicketCollabCount
from super_archives.models import Thread
+from colab.utils.pygal_render import render_pie_chart
def index(request):
@@ -18,8 +23,8 @@ def index(request):
latest_threads = Thread.objects.all()[:6]
hottest_threads = Thread.highest_score.from_haystack()[:6]
- count_types = cache.get('home_chart')
- if count_types is None:
+ home_chart = cache.get('home_chart')
+ if home_chart is None:
count_types = OrderedDict()
for type in ['thread', 'changeset', 'attachment']:
count_types[trans(type)] = SearchQuerySet().filter(
@@ -33,12 +38,16 @@ def index(request):
count_types[trans('wiki')] = sum([
wiki.count for wiki in WikiCollabCount.objects.all()
])
- cache.set('home_chart', count_types)
+
+ home_chart = render_pie_chart(count_types, width=500, height=350,
+ no_data_text=_(u'No data found')
+ )
+ cache.set('home_chart', home_chart)
context = {
'hottest_threads': hottest_threads[:6],
'latest_threads': latest_threads,
- 'type_count': count_types,
+ 'home_chart': home_chart,
'latest_results': SearchQuerySet().all().order_by(
'-modified', '-created'
)[:6],
diff --git a/src/locale/pt_BR/LC_MESSAGES/django.mo b/src/locale/pt_BR/LC_MESSAGES/django.mo
index 6a357a77..b4b18fa0 100644
Binary files a/src/locale/pt_BR/LC_MESSAGES/django.mo and b/src/locale/pt_BR/LC_MESSAGES/django.mo differ
diff --git a/src/locale/pt_BR/LC_MESSAGES/django.po b/src/locale/pt_BR/LC_MESSAGES/django.po
index a9895b6e..4154f563 100644
--- a/src/locale/pt_BR/LC_MESSAGES/django.po
+++ b/src/locale/pt_BR/LC_MESSAGES/django.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-12-10 16:24+0000\n"
+"POT-Creation-Date: 2013-12-13 17:48+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME