Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def pie_view(request, what, choice_dict, page_title):
- numbers = SortedDict()
- year, month = request.GET.get('year'), request.GET.get('month')
- numbers['all'] = _make_numbers(
- what, year=year, month=month)
- for group in _office_groups():
- numbers[group] = _make_numbers(
- what, office_title=group, year=year, month=month)
- json_data = []
- for office_title, amount in numbers.items():
- amount_items = sorted(
- amount.items(), key=lambda l: -l[1]) # sort by no of clients
- info = {}
- data = []
- info['store'] = dict(
- fields=['category', 'total'],
- data=data)
- office_title = office_title == u'all' and u'Gesamt' or office_title
- info['title'] = u'Kontaktaufnahme: %s' % office_title
- for key, value in amount_items:
- data.append(dict(
- category=choice_dict[key],
- total=value
- ))
- json_data.append(info)
- return render_to_response(
- 'lotsen/pie.html', template_variables(
- request,
- page_title=page_title,
- numbers=numbers,
- json_data=json.dumps(json_data),
- ))
- @user_passes_test(is_teamleader_or_superuser)
- def contacted_through(request):
- return pie_view(
- request,
- 'issue__client__contacted_through',
- choices.CONTACTED_THROUGH_DICT,
- 'Kontaktaufnahme',
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement