From 6e7e656d0fc14e41fe106c5a97e9d8a8392b3e5c Mon Sep 17 00:00:00 2001 From: root Date: Wed, 12 Dec 2012 12:20:16 -0500 Subject: Profile handler --- frontend/templates/profile.html | 155 ++++++++++++++++++++++++++++++++++++++++ frontend/views.py | 59 ++++++++++++++- 2 files changed, 213 insertions(+), 1 deletion(-) create mode 100644 frontend/templates/profile.html (limited to 'frontend') diff --git a/frontend/templates/profile.html b/frontend/templates/profile.html new file mode 100644 index 0000000..c277207 --- /dev/null +++ b/frontend/templates/profile.html @@ -0,0 +1,155 @@ +{% load static %} +{% get_static_prefix as STATIC_PREFIX %} + + + +scanners jammed by {{NAME}} + + + + + + + + + + + + + + + + +
+ +
+ +
+
+
+
+
+
+ +
+ +
+
+ + +
+ +
+ +

+ +
+ +
+ +
+ +
+
EDIT YOUR PROFILE
+
+ Top Videos . + Directory +
+
+ + +
+
+ +
+
X
+
EDITING {{UCNAME}}
+
+ + +
+ + +
+
+ + +
+
+ +
+
+
+
+ +
+
+
+ +
+
+ please enable javascript +
+ +
Hit Escape to exit fullscreen mode
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/views.py b/frontend/views.py index e2354fe..a391c0a 100644 --- a/frontend/views.py +++ b/frontend/views.py @@ -21,7 +21,7 @@ from backend.views import is_image from backend.views import videos_response_list from backend.views import ROOM_VIDEO_LOG_SIZE -from django.db.models import Q +from django.db.models import Q, Count LIMIT = 40 @@ -115,3 +115,60 @@ def directory(request): response['Pragma'] = 'no-cache' return response +def get_thumbnail(user): + STOCK_THUMBNAIL = 'http://scannerjammer.fm/img/runner.gif' + """ + FIXME + if user.access and 'http' in user.access: # what was those fields? + linez = user.access.split("\n") + for l in linez: + if "avatar" in l: + pair = l.split("\t") + if pair[1] is not None and "http" in pair[1]: + if db.is_image(pair[1]): + return pair[1] + if user[8] and 'http' in user[8]: + linez = user[8].split("\n") + for l in linez: + if "http" in l: + wordz = l.split(" ") + for word in wordz: + if "http" in word: + if db.is_image(word): + return word + """ + return STOCK_THUMBNAIL + + +def profile(request, username): + """ Directory view + """ + + userprofile = SJUserProfile.objects.filter(user__username=username)[0]; + thumbnail = get_thumbnail(userprofile) + + topz = SJContent.objects.filter(user__id=userprofile.user.id, content_type='video').annotate(likes=Count('sjlike')).order_by('-likes')[:50] + likez = SJContent.objects.filter(user__id=userprofile.user.id, content_type='video', sjlike__isnull = False ).order_by('-datetime')[:50] + vidz = SJContent.objects.filter(user__id=userprofile.user.id, content_type='video').order_by('-datetime')[:50] + profile = [ userprofile.id, userprofile.nickname, userprofile.score, 3, 4, 5, userprofile.bio, 7 ] + + response = render_to_response( + 'profile.html', + { + 'SERVER_HOST': settings.SERVER_HOST, + 'SERVER_PORT': settings.SERVER_PORT, + 'NAME': userprofile.nickname, + 'UCNAME': userprofile.nickname.upper(), + 'SCORE': userprofile.score, + 'THUMBNAIL': thumbnail, + + 'VIDZ': json.dumps(videos_response_list(vidz)), + 'TOPZ': json.dumps(videos_response_list(topz)), + 'LIKEZ': json.dumps(videos_response_list(likez)), + 'PROFILE': json.dumps(profile), + + 'NOW': str(int(time.time())), + } + ) + response['Pragma'] = 'no-cache' + return response -- cgit v1.2.3-70-g09d2