summaryrefslogtreecommitdiff
path: root/frontend/views.py
diff options
context:
space:
mode:
authorroot <root@lalalizard.com>2012-12-12 12:20:16 -0500
committerroot <root@lalalizard.com>2012-12-12 12:20:16 -0500
commit6e7e656d0fc14e41fe106c5a97e9d8a8392b3e5c (patch)
tree2a95c41d5752dedc48dcbcf3490b0e7013b3d11e /frontend/views.py
parent8d1b1d491beb6a4d1ce642eed451e713a701aff3 (diff)
Profile handler
Diffstat (limited to 'frontend/views.py')
-rw-r--r--frontend/views.py59
1 files changed, 58 insertions, 1 deletions
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