From 06e586f7b429eb5c4271e5d5e9f4c7e1914f4527 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 24 Dec 2012 07:15:33 -0500 Subject: profile_img handler --- backend/views.py | 18 +++++ frontend/templates/profile_img.html | 152 ++++++++++++++++++++++++++++++++++++ frontend/views.py | 30 +++++++ scannerjammer/urls.py | 1 + 4 files changed, 201 insertions(+) create mode 100644 frontend/templates/profile_img.html diff --git a/backend/views.py b/backend/views.py index 7cfbe98..4ea7b2d 100644 --- a/backend/views.py +++ b/backend/views.py @@ -167,6 +167,24 @@ def videos_response_list(videos): ] retval.append(l) return retval +def text_response_list(videos): + """ Return list of videos + """ + retval = [] + for v in videos: + s = v.settings + if s.get('removed', 0): + continue + l = [ + v.id, + datetime_to_timestamp(v.datetime), + v.user.id, + v.user.username, + s['text'], + v.sjlike_set.count() + ] + retval.append(l) + return retval def settings_response_str(label, settings): """ Return string of settings diff --git a/frontend/templates/profile_img.html b/frontend/templates/profile_img.html new file mode 100644 index 0000000..4b2feb3 --- /dev/null +++ b/frontend/templates/profile_img.html @@ -0,0 +1,152 @@ +{% 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
+ + +{{LIKEZ|safe}} + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/views.py b/frontend/views.py index f9dd1bf..763253e 100644 --- a/frontend/views.py +++ b/frontend/views.py @@ -19,6 +19,7 @@ from backend.models import SJUserProfile from backend.views import is_number from backend.views import is_image from backend.views import videos_response_list +from backend.views import text_response_list from backend.views import ROOM_VIDEO_LOG_SIZE from django.db.models import Q, Count @@ -173,6 +174,35 @@ def profile(request, username): response['Pragma'] = 'no-cache' return response +def profile_img(request, username): + """ Directory view + """ + + userprofile = SJUserProfile.objects.filter(user__username=username)[0]; + thumbnail = get_thumbnail(userprofile) + + likez = SJContent.objects.filter(content_type='text', sjlike__user_id = userprofile.user.id ).order_by('-datetime')[:50] + profile = [ userprofile.id, userprofile.nickname, userprofile.score, 3, 4, 5, userprofile.bio, json.loads(userprofile.settings_text) ] + + response = render_to_response( + 'profile_img.html', + { + 'SERVER_HOST': request.get_host(), + 'SERVER_PORT': settings.SERVER_PORT, + 'NAME': userprofile.nickname, + 'UCNAME': userprofile.nickname.upper(), + 'SCORE': userprofile.score, + 'THUMBNAIL': thumbnail, + + 'LIKEZ': json.dumps(text_response_list(likez)), + 'PROFILE': json.dumps(profile), + + 'NOW': str(int(time.time())), + } + ) + response['Pragma'] = 'no-cache' + return response + def profile_own(request): return profile(request, request.user.username) diff --git a/scannerjammer/urls.py b/scannerjammer/urls.py index e1b3450..c3c08c3 100644 --- a/scannerjammer/urls.py +++ b/scannerjammer/urls.py @@ -29,6 +29,7 @@ urlpatterns = patterns('', url(r'^register/?$', 'frontend.views.register', name='register'), url(r'^(?P[a-z0-9_]+)/admin/?$', 'frontend.views.admin', name='admin'), url(r'^profile/(?P[a-z0-9_]+)$', 'frontend.views.profile', name='profile'), + url(r'^profile_img/(?P[a-z0-9_]+)$', 'frontend.views.profile_img', name='profile_img'), url(r'^profile/?$', 'frontend.views.profile_own', name='profile_own'), url(r'^(?Pavatar)/$', 'frontend.views.room', name='room'), url(r'^(?P[a-z0-9_]+)$', 'frontend.views.room', name='room'), -- cgit v1.2.3-70-g09d2