From a5796265013443c349797508ef8066541c1a3a02 Mon Sep 17 00:00:00 2001 From: Dhiru Date: Fri, 3 Aug 2012 13:41:57 +0530 Subject: Changes done in image,video&document library --- gstudio/models.py | 2 +- gstudio/templates/gstudio/docu.html | 101 +++++++++-- gstudio/templates/gstudio/fullscreen.html | 127 +++++++++++++- gstudio/templates/gstudio/home.html | 10 +- gstudio/templates/gstudio/image.html | 189 ++++++++++++++------- gstudio/templates/gstudio/transcript.html | 118 ++++++++++++- gstudio/templates/gstudio/video.html | 270 ++++++++++++++++-------------- gstudio/views/docu.py | 16 +- gstudio/views/image.py | 43 +++-- gstudio/views/video.py | 110 +++++++++--- 10 files changed, 728 insertions(+), 258 deletions(-) (limited to 'gstudio') diff --git a/gstudio/models.py b/gstudio/models.py index 1e5ec0c..e708538 100644 --- a/gstudio/models.py +++ b/gstudio/models.py @@ -855,7 +855,7 @@ class Nodetype(Node): fl=1 """ fl=0 means, Attribute for AT is not added, now show it as to be added - " " " + """ if fl==0: retats[each.title]=aturl diff --git a/gstudio/templates/gstudio/docu.html b/gstudio/templates/gstudio/docu.html index 7be5aa7..dc9f151 100644 --- a/gstudio/templates/gstudio/docu.html +++ b/gstudio/templates/gstudio/docu.html @@ -1,37 +1,77 @@ + + {% extends "gstudio/base.html" %} -{% load i18n %} +{% load pagination_tags %} {% load adminmedia grp_tags %} +{% load i18n comments gstudio_tags %} +{% load i18n objectapp_tags %} {% block content %} +{% load tagging_tags comments i18n %} + + + {% if user.is_authenticated %} -

Welcome to the DocZilla

-

{{ image.title }}

-

Logged in as: {{user.username}}

+{% autopaginate documents 8 %} +

Document Library


-
-{% csrf_token %} -

Post File:

-

- +
+{% csrf_token %} +
+Post File:       +

+Description:   +

+                         -
+
+ +
{% csrf_token %} +

Search File

-

-

Sort files by:

-

-  +
+
+ -
+
+
+
+
+

-

SHARE

+
+

Documents Listing

{% for document in documents %} @@ -46,6 +86,8 @@
Posted At : {{document.creation_date}}
+Description:{{ document.content }} +
Download now!!
{% for author in document.authors.all %} @@ -89,8 +131,26 @@
+
+
{% csrf_token %} + + +

+
+

+ {% trans "Tags" %} : + {% tags_for_object document as tag_list %} + {% for tag in tag_list %} + + {% empty %} + {% trans "No tags" %} + {% endfor %} +

+
+



{% endfor %}
@@ -102,6 +162,13 @@ {% endif %} - +

+{% paginate %}

+ + + + + {% endblock %} + diff --git a/gstudio/templates/gstudio/fullscreen.html b/gstudio/templates/gstudio/fullscreen.html index afc3746..8c3efed 100644 --- a/gstudio/templates/gstudio/fullscreen.html +++ b/gstudio/templates/gstudio/fullscreen.html @@ -1,4 +1,127 @@ - {% load adminmedia grp_tags %} - +{% load i18n comments gstudio_tags %} +{% load tagging_tags comments i18n %} + + + + + + + + + + +
+Name : {{image.title}} +
+Posted By : +{% for author in image.authors.all %} + {{author}} +{% endfor %} +
+ +Posted At : {{image.creation_date}} +
+Description:{{ image.content }} +
+ +{% ifequal image.rating.get_rating 0 %} + +Current rating is:   No rating yet +{% else %} +Current rating is:   {{ image.rating.get_rating }} +{% endifequal %} +
+
+{% csrf_token %} + + + + + +
+ + + + +
+
+ +
{% csrf_token %} + + + +
+
+
+

+ {% trans "Tags" %} : + {% tags_for_object image as tag_list %} + {% for tag in tag_list %} + + {% empty %} + {% trans "No tags" %} + {% endfor %} +

+
+

+{% block nodetype-comments %} +
+
{% trans "Comments" %}
+ {% with image.comments as comment_list %} + {% if comment_list.count %} +
    + {% for comment in comment_list %} + + {% endfor %} +
+ {% if not image.comments_are_open %} +

{% trans "Comments are closed." %}

+ {% endif %} + {% else %} + {% if image.comments_are_open %} +

{% trans "No comments yet." %}

+ {% else %} +

{% trans "Comments are closed." %}

+ {% endif %} + {% endif %} + {% endwith %} +
+{% endblock %} + + +
+ {% render_comment_form for image %} +
+ + + + +
+
+
+ diff --git a/gstudio/templates/gstudio/home.html b/gstudio/templates/gstudio/home.html index aec372d..8859bca 100644 --- a/gstudio/templates/gstudio/home.html +++ b/gstudio/templates/gstudio/home.html @@ -1,6 +1,6 @@ -{% load objectapp_tags i18n %} -{% load gstudio_tags i18n %} +{% load gstudio_tags i18n %} +{% load objectapp_tags i18n %} {% load adminmedia grp_tags %} @@ -114,6 +114,10 @@ +
+

{% trans "Tags" %}

+ {% get_tag_cloud %} +
{{ site }}
@@ -128,7 +132,7 @@

Let us collaboratively construct semantic knowledge networks with a special focus on education.more

-

{% trans "Recent Authors" %}

+

{% trans "Recents Authors" %}

{% get_authors %}
diff --git a/gstudio/templates/gstudio/image.html b/gstudio/templates/gstudio/image.html index f70a24b..293b7ec 100644 --- a/gstudio/templates/gstudio/image.html +++ b/gstudio/templates/gstudio/image.html @@ -1,29 +1,69 @@ {% extends "gstudio/base.html" %} +{% load pagination_tags %} {% load adminmedia grp_tags %} {% load i18n %} {% block content %} + + + {% if user.is_authenticated %} -

Welcome to the ImageNation

-

{{ image.title }}

-

Logged in as: {{user.username}}

-
+{% autopaginate images 10 %} + +

Image Library

+
{% csrf_token %} -

Post Image:

-

Title:


-

- - + +

Post Image:

+Title:             

+Image:         

+Description:   +

+                     
-
+
+ +
{% csrf_token %} -

Search Image

+

Search Image:

-

Sort images by:

-

+
+

+

+ +

IMAGES

{% for image in images %} -
-
-

-{{ image.title }} + + +

+ +

{{image.title}}

+
{% csrf_token %} + + + + + -

-
-
- -
-
-

{{image.title}} - -{% csrf_token %} - - - -

-Posted By : -{% for author in image.authors.all %} - {{author}} -{% endfor %} -
-Posted At : {{image.creation_date}} -
+ + + + + + + + + + + + + + + + + + + + + + + {% for author in image.authors.all %} - {% ifequal author.username user.username %} -
-{% csrf_token %} + {% ifequal author.username user.username %} - +
+ {% endifequal %} {% endfor %} -
-Current rating is

{{ image.rating.get_rating }}

-
-
-{% csrf_token %} - - - - - -
- - -
-
-
-
-{% endfor %}
-

+ + + + + + + + + + + + + + + + + +
+ +{% endfor %} +
{% else %}

Sorry you need to log in to see this content !

{% endif %} - - +

+{% paginate %}

+ {% endblock %} diff --git a/gstudio/templates/gstudio/transcript.html b/gstudio/templates/gstudio/transcript.html index ff8dfad..7860061 100644 --- a/gstudio/templates/gstudio/transcript.html +++ b/gstudio/templates/gstudio/transcript.html @@ -1,13 +1,13 @@ -{% load gstudio_tags i18n %} -{% get_tags as nodetype_tags %} {% load adminmedia grp_tags %} - - - - +{% load i18n comments gstudio_tags %} +{% load tagging_tags comments i18n %} + - + + + + @@ -22,7 +22,111 @@ $('#pandoravideo').pandoravideo();
+ + +
+Name: +{{ titlename }}
+Posted By : + + {{postedby}} +
+Posted At : + {{date}} + +
+ Location: +{{we}} +
+Description:{{ contentname }} +
+Current rating is:  {{ rateby }} +
+
+{% csrf_token %} + + + + + + + + +
+
+
+{% csrf_token %} + + + +

+
{% csrf_token %} + + + +
+
+
+
+

+ {% trans "Tags" %} : + {% tags_for_object video as tag_list %} + {% for tag in tag_list %} + + {% empty %} + {% trans "No tags" %} + {% endfor %} +

+
+

+{% block nodetype-comments %} +
+
{% trans "Comments" %}
+ {% with video.comments as comment_list %} + {% if comment_list.count %} +
    + {% for comment in comment_list %} + + {% endfor %} +
+ {% if not video.comments_are_open %} +

{% trans "Comments are closed." %}

+ {% endif %} + {% else %} + {% if video.comments_are_open %} +

{% trans "No comments yet." %}

+ {% else %} +

{% trans "Comments are closed." %}

+ {% endif %} + {% endif %} + {% endwith %} +
+{% endblock %} + + +
+ {% render_comment_form for video %}
+
+
diff --git a/gstudio/templates/gstudio/video.html b/gstudio/templates/gstudio/video.html index 644831a..f2ae11d 100644 --- a/gstudio/templates/gstudio/video.html +++ b/gstudio/templates/gstudio/video.html @@ -1,181 +1,199 @@ {% extends "gstudio/base.html" %} +{% load pagination_tags %} {% load i18n %} {% load adminmedia grp_tags %} +{% load i18n comments gstudio_tags %} + {% block content %} + + + + {% if user.is_authenticated %} -

Welcome to the VideoCore

-

{{ image.title }}

-

Logged in as: {{user.username}}

-
+ +{% autopaginate vids 10 %} + + +

Video Library

+
+
{% csrf_token %} -

Post Video:

+

Submit Videos:

Video: 


+Description:   - + + +

              + + + +
-
+
+
{% csrf_token %} -

Search Video

+

Search Videos:

-

Sort videos by:

-

+ + -
+

-
+ {% csrf_token %}
- -

VIDEOS


- - - - - - - -
- - - - - - - -
-{% if fav %} -

Favourite Videos

-{% endif %} -
- -{% for video in vids %} - -

{{video.title}}

+{{video.title}}
{% csrf_token %} - -
-

Right click to download


-Posted By : + + +Right click to download
+ {% for author in video.get_nbh.posted_by %} - {{author}} + + {% endfor %} -
-Posted At : + + + {% for date in video.get_nbh.creation_day %} - {{date}} + {% endfor %} -
-{% for we in video.get_nbh.source %} - Location: + + + +{% for we in video.get_nbh.source %} + {% for map in video.get_nbh.map_link %} - {% ifnotequal map '' %} - {{we}} - {% endifnotequal %} + {% ifnotequal map '' %} + + + + {% endifnotequal %} {% endfor %} {% endfor %} -
-Current rating is

{{ video.rating.get_rating }}

-
-
-{% csrf_token %} - - - - - + + + + + + + + + + + + -
-
-
-{% csrf_token %} - - - -

-
-
-{% endfor %}
+ + + + + + + + + + + +
+ +{% endfor %} -

-Follow us on Facebook + +
{% else %}

Sorry you need to log in to see this content !

{% endif %} +

+{% paginate %}

+ {% endblock %} {% block chart %} -













- -




+

{% endblock %} diff --git a/gstudio/views/docu.py b/gstudio/views/docu.py index d56b8c4..45be873 100644 --- a/gstudio/views/docu.py +++ b/gstudio/views/docu.py @@ -27,12 +27,15 @@ def docu(request): q=p.get_nbh['contains_members'] if request.method=="POST": user = request.POST.get("user","") + content= request.POST.get("contenttext","") sdoc = request.POST.get("sdoc","") dn = request.POST.get("dn","") sub3 = request.POST.get("mydropdown","") rating = request.POST.get("star1","") docid = request.POST.get("docid","") delete = request.POST.get("delete","") + addtags = request.POST.get("addtags","") + texttags = request.POST.get("texttags","") if rating : rate_it(int(docid),request,int(rating)) if delete != "": @@ -61,13 +64,20 @@ def docu(request): variables = RequestContext(request,{'documents':vido,'val':sdoc}) template = "gstudio/docu.html" return render_to_response(template, variables) + + if addtags != "": + i=Gbobject.objects.get(id=docid) + i.tags = i.tags+ ","+str(texttags) + i.save() + + a=[] for each in request.FILES.getlist("doc[]",""): a.append(each) if a != "": for f in a: save_file(f) - create_object(f,user) + create_object(f,user,content) vars=RequestContext(request,{'documents':q}) template="gstudio/docu.html" return render_to_response(template, vars) @@ -82,7 +92,7 @@ def save_file(file, path=""): fd.write(chunk) fd.close() -def create_object(file,log): +def create_object(file,log,content): p=Gbobject() p.title=file._get_name() p.rurl=MEDIA_ROOTNEW2+"p.title" @@ -95,7 +105,7 @@ def create_object(file,log): else: final = final+each1 p.slug=final - p.content=' ' + p.content=content p.status=2 p.save() p.sites.add(Site.objects.get_current()) diff --git a/gstudio/views/image.py b/gstudio/views/image.py index fd642eb..508755f 100644 --- a/gstudio/views/image.py +++ b/gstudio/views/image.py @@ -28,6 +28,7 @@ def image(request): q=p.get_nbh['contains_members'] if request.method=="POST": title = request.POST.get("title1","") + content= request.POST.get("contenttext","") simg = request.POST.get("simg","") sub3 = request.POST.get("mydropdown","") user = request.POST.get("user","") @@ -36,7 +37,10 @@ def image(request): imgid = request.POST.get("imgid","") pict = request.POST.get("pict","") fulid = request.POST.get("fulid","") - if fulid != "": + show = request.POST.get("Show","") + addtags = request.POST.get("addtags","") + texttags = request.POST.get("texttags","") + if show != "": i=Gbobject.objects.get(id=fulid) vars=RequestContext(request,{'image':i}) template="gstudio/fullscreen.html" @@ -69,6 +73,14 @@ def image(request): variables = RequestContext(request,{'images':vido,'val':simg}) template = "gstudio/image.html" return render_to_response(template, variables) + + + if addtags != "": + i=Gbobject.objects.get(id=imgid) + i.tags = i.tags+ ","+str(texttags) + i.save() + + a=[] for each in request.FILES.getlist("image[]",""): a.append(each) @@ -76,12 +88,12 @@ def image(request): i=0 for f in a: if i==0: - save_file(f,title) - create_object(f,user,title) + save_file(f,title,user) + create_object(f,user,title,content) i=i+1 else: - save_file(f,title+'_'+str(i)) - create_object(f,user,title+'_'+str(i)) + save_file(f,title+'_'+str(i),user) + create_object(f,user,title+'_'+str(i),content) i=i+1 p=Objecttype.objects.get(title="Image") q=p.get_nbh['contains_members'] @@ -92,25 +104,32 @@ def image(request): template="gstudio/image.html" return render_to_response(template, vars) -def save_file(file,title, path=""): +def save_file(file,title, user, path=""): filename = title - fd = open('%s/%s' % (MEDIA_ROOTNEW2, str(path) + str(filename)), 'wb') + os.system("mkdir -p "+ MEDIA_ROOTNEW2+"/"+user) + fd = open('%s/%s/%s' % (MEDIA_ROOTNEW2, str(user),str(path) + str(file)), 'wb') for chunk in file.chunks(): fd.write(chunk) fd.close() -def create_object(file,log,title): +def create_object(f,log,title,content): p=Gbobject() + filename = str(f) p.title=title - p.image=p.title + p.image=log+"/"+filename final = '' - for each1 in p.title: + for each1 in filename: if each1==" ": final=final+'-' else: final = final+each1 - p.slug=final - p.content=' ' + i=0 + dirname = "" + while final[i] != ".": + dirname = dirname + final[i] + i=i+1 + p.slug=dirname + p.content=content p.status=2 p.save() p.sites.add(Site.objects.get_current()) diff --git a/gstudio/views/video.py b/gstudio/views/video.py index 660bf06..668e77b 100644 --- a/gstudio/views/video.py +++ b/gstudio/views/video.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . - - +#!/usr/bin/python +import time; from django.http import HttpResponse from django.shortcuts import render_to_response import ox @@ -22,43 +22,68 @@ import os from gstudio.models import * from objectapp.models import * from django.template import RequestContext +from django.views.generic.list_detail import object_list from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from demo.settings import * from gstudio.methods import * +from django.contrib.auth import authenticate def video(request): api=ox.api.API("http://wetube.gnowledge.org/api") p=Objecttype.objects.get(title="Video") q=p.get_nbh['contains_members'] - api.signin({'username':'nero','password':'nihar'}) + sd = request.user + message = '' + sd = str(sd) + password = request.POST.get("upload","") + content= request.POST.get("contenttext","") if request.method == 'POST': - clip = request.FILES.getlist("clip[]","") + clip = request.FILES.get("clip","") + content= request.POST.get("contenttext","") svid = request.POST.get("svid","") sub1 = request.POST.get("norm","") sub2 = request.POST.get("spe","") rating = request.POST.get("star1","") vidid = request.POST.get("vidid","") user = request.POST.get("user","") + userpassword = request.POST.get("userpassword","") + useremail = request.POST.get("useremail","") sub3 = request.POST.get("mydropdown","") favid=request.POST.get("favid","") favusr=request.POST.get("favusr","") fav=request.POST.get("fav","") full=request.POST.get("full","") + author=request.POST.get("authorname","") + date = request.POST.get("datename","") + rate = request.POST.get("ratename","") + contentname = request.POST.get("contentname","") + mapname = request.POST.get("mapname","") + wename = request.POST.get("wename","") + titlename = request.POST.get("titlename","") + password = request.POST.get("upload","") + addtags = request.POST.get("addtags","") + texttags = request.POST.get("texttags","") + + if rate == '0': + rate = 'No rating yet' + else : + rate = rate + if full!="" : - variables= RequestContext(request,{'id':full}) + i=Gbobject.objects.get(id=vidid) + variables= RequestContext(request,{'id':full,'postedby':author,'date':date,'rateby':rate,'map':mapname,'we':wename,'vidid':vidid ,'titlename':titlename,'contentname':contentname,'video':i}) template="gstudio/transcript.html" return render_to_response(template,variables) if fav != "" : list1=[] - t=Gbobject.objects.get(title=user) + t=Gbobject.objects.get(title=user+"video") for each in t.get_nbh['has_favourite']: d=each.right_subject_id x=Gbobject.objects.get(id=d) list1.append(x) - variables = RequestContext(request,{'vids':list1,'val':svid}) + variables = RequestContext(request,{'vids':list1,'val':svid,'fav':fav}) template = "gstudio/video.html" return render_to_response(template, variables) - if rating : rate_it(int(vidid),request,int(rating)) @@ -66,18 +91,18 @@ def video(request): e=0 r = Objecttype.objects.get(title="user") for each in r.get_nbh['contains_members']: - if favusr == each.title: - e=1 + if favusr+"video" == each.title: + e=1 if e==0 : - t=Gbobject() - t.title=favusr - t.slug=favusr + t=Gbobject() + t.title=favusr+"video" + t.slug=favusr+"video" t.content=' ' t.status=2 t.save() t.objecttypes.add(Objecttype.objects.get(title="user")) t.save() - t=Gbobject.objects.get(title=favusr) + t=Gbobject.objects.get(title=favusr+"video") rel=Relation() rt=Relationtype.objects.get(title="has_favourite") rel.relationtype_id=rt.id @@ -86,9 +111,18 @@ def video(request): rel.right_subject_id=f1.id rel.save() t.save() + + + if addtags != "": + i=Gbobject.objects.get(id=vidid) + i.tags = i.tags+ ","+str(texttags) + i.save() + + if clip != "": - api.signup({'username':user,'password':'wetube'}) - save_file(clip) + userauth = authenticate(username=user, password=password) + api.signup({'username':user,'password':password,'email':useremail}) + save_file(clip,user) clipname = clip._get_name() i=0 dirname = "" @@ -96,16 +130,20 @@ def video(request): dirname = dirname + clipname[i] i=i+1 y=str(dirname) + x=str(clipname[0]).upper() + CreateConfig(user) + # os.system("pandora_client config") + os.system("pandora_client add_volume "+ user+" "+MEDIA_ROOTNEW+"/"+user ) os.system("pandora_client scan") os.system("pandora_client sync") - os.system("pandora_client upload") + os.system("pandora_client upload") wclip= api.find({'sort': [{'key': 'title','operator': '+'}],'query': {'conditions': [{'key': 'title','value': y,'operator': '='}],'operator': '&'},'keys': ['id', 'title','user','duration','sourcedescription','created'],'range': [0,100]}) for each in wclip['data']['items']: - m=Gbobject() + m=Gbobject() m.title=each['title'].lower() m.rurl="http://wetube.gnowledge.org/"+each['id']+'/480p.webm' m.slug=each['id'] - m.content=' ' + m.content=content m.status=2 m.save() m.objecttypes.add(Objecttype.objects.get(id=p.id)) @@ -143,9 +181,13 @@ def video(request): a4.svalue=final a4.save() m.save() + + + if sub3 != "": if svid != "": if sub2 == "": + vidon = Objecttype.objects.get(title="Video") vido_new = vidon.get_nbh['contains_members'] vido = vido_new.filter(title__contains=svid) @@ -174,9 +216,10 @@ def video(request): vido=vido_new.order_by(sub3) else: vido=sort_video(vido_new) - variables = RequestContext(request,{'vids':vido,'val':svid}) + variables = RequestContext(request,{'vids':vido,'val':svid }) template = "gstudio/video.html" return render_to_response(template, variables) + api.signin({'username': sd,'password':password}) r= api.find({'sort': [{'key': 'title','operator': '+'}],'query': {'conditions': [{'key': 'title','value': '','operator': ''}],'operator': '&'},'keys': ['id', 'title','user','created','duration','sourcedescription'],'range': [0,100]}) s=r['data']['items'] for each in s: @@ -189,7 +232,7 @@ def video(request): m.title=each['title'].lower() m.rurl="http://wetube.gnowledge.org/"+each['id']+'/480p.webm' m.slug=each['id'] - m.content=' ' + m.content=content m.status=2 m.save() m.objecttypes.add(Objecttype.objects.get(id=p.id)) @@ -233,9 +276,9 @@ def video(request): template = "gstudio/video.html" return render_to_response(template, variables) -def save_file(file, path=""): +def save_file(file, user,path=""): filename = file._get_name() - i=0 + i=0 dirname = "" while filename[i] != ".": dirname = dirname + filename[i] @@ -248,11 +291,16 @@ def save_file(file, path=""): z=z+'\ ' else: z=z+each1 - os.system("mkdir "+MEDIA_ROOTNEW+"/"+x+"/"+z) - fd = open('%s/%s/%s/%s' % (MEDIA_ROOTNEW, str(filename[0]).upper(), str(dirname), str(path) + str(filename)), 'wb') + fileuser = str(user) + os.system("mkdir -p "+ MEDIA_ROOTNEW+"/"+fileuser+"/"+x+"/"+z) + fd = open('%s/%s/%s/%s/%s' % (MEDIA_ROOTNEW,str(fileuser), str(filename[0]).upper(), str(dirname), str(path) + str(filename)), 'wb') for chunk in file.chunks(): fd.write(chunk) fd.close() + return + + + def sort_video(video): a = [] @@ -271,3 +319,15 @@ def sort_video(video): a[min] = temp i = i+1 return a + + + +def CreateConfig(user): + myfile = open(VIDEO_PANDORA_URL,'w') + myfile = open(VIDEO_PANDORA_URL,'a') + myfile.write('{ \n "username":"'+user+'", \n "url":"http://wetube.gnowledge.org/api/",\n"cache": "~/.ox/client.sqlite",\n"media-cache": "~/.ox/media",\n"volumes":{},\n"password":"wetube"\n }') + myfile.close() + + + + -- cgit v1.1