diff options
author | Johan Lundberg <lundberg@nordu.net> | 2014-04-01 17:35:51 +0200 |
---|---|---|
committer | Johan Lundberg <lundberg@nordu.net> | 2014-04-01 17:35:51 +0200 |
commit | 76d1f7cd5458feb42cd3e6cde27dbce56a2db41b (patch) | |
tree | 52b6ba341bc55f8faf91933e92f517bd0cac2cba /meetingtools/apps | |
parent | 14d29c5afc776fd1ab468b821b4818df08890cfc (diff) |
Content user view created
Diffstat (limited to 'meetingtools/apps')
-rw-r--r-- | meetingtools/apps/content/templatetags/__init__.py | 2 | ||||
-rw-r--r-- | meetingtools/apps/content/templatetags/content_tags.py | 21 | ||||
-rw-r--r-- | meetingtools/apps/content/views.py | 24 |
3 files changed, 47 insertions, 0 deletions
diff --git a/meetingtools/apps/content/templatetags/__init__.py b/meetingtools/apps/content/templatetags/__init__.py new file mode 100644 index 0000000..3250cb8 --- /dev/null +++ b/meetingtools/apps/content/templatetags/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +__author__ = 'lundberg' diff --git a/meetingtools/apps/content/templatetags/content_tags.py b/meetingtools/apps/content/templatetags/content_tags.py new file mode 100644 index 0000000..29cb98e --- /dev/null +++ b/meetingtools/apps/content/templatetags/content_tags.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +__author__ = 'lundberg' + +from django import template +import math + +register = template.Library() + + +def humanize_bytes(b): + try: + size_name = ('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB') + i = int(math.floor(math.log(b, 1024))) + p = math.pow(1024, i) + s = round(b / p, 2) + if s > 0: + return '%s %s' % (s, size_name[i]) + except TypeError: + return 'TypeError' + +register.filter('humanize_bytes', humanize_bytes)
\ No newline at end of file diff --git a/meetingtools/apps/content/views.py b/meetingtools/apps/content/views.py new file mode 100644 index 0000000..c830af0 --- /dev/null +++ b/meetingtools/apps/content/views.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +__author__ = 'lundberg' + +from django.contrib.auth.decorators import login_required +from django.db.models import Sum +from django.contrib.humanize.templatetags.humanize import naturalday +from django.http import HttpResponseForbidden, HttpResponseBadRequest +from meetingtools.apps.stats.models import UserMeetingTransaction +from iso8601 import iso8601 +from time import mktime +from meetingtools.multiresponse import json_response, respond_to +from meetingtools.apps.stats.forms import StatCaledarForm +from django.shortcuts import get_object_or_404 +from meetingtools.apps.content.models import Content + + +@login_required +def user(request, username=None): + if username is None: + username = request.user.username + content = Content.objects.filter(creator__username=username) + total_bytecount = content.aggregate(Sum('bytecount')) + return respond_to(request,{'text/html': 'apps/content/user.html'}, + {'username': username, 'content': content, 'total_bytecount': total_bytecount})
\ No newline at end of file |