summaryrefslogtreecommitdiff
path: root/gstudio/views
diff options
context:
space:
mode:
authorAnkita <ankita@ankita-Inspiron-N5010.(none)>2012-07-13 12:31:27 +0530
committerAnkita <ankita@ankita-Inspiron-N5010.(none)>2012-07-13 12:31:27 +0530
commit527ab688a8608ded5fc854cf8641228181efa981 (patch)
tree825f17422ce610922f8f34854c5e54db7a7f35ad /gstudio/views
parentef3793b349be5744d6ef98a034f0c009159ed85b (diff)
downloadgnowsys-527ab688a8608ded5fc854cf8641228181efa981.tar.gz
this patch was added for metastudio by BITS Pilani team in 2012.
Diffstat (limited to 'gstudio/views')
-rw-r--r--gstudio/views/docu.py113
-rw-r--r--gstudio/views/group.py105
-rw-r--r--gstudio/views/groupadd.py50
-rw-r--r--gstudio/views/image.py128
-rw-r--r--gstudio/views/login.py80
-rw-r--r--gstudio/views/topicadd.py47
-rw-r--r--gstudio/views/topicadd1.py50
-rw-r--r--gstudio/views/user.py38
-rw-r--r--gstudio/views/video.py273
9 files changed, 884 insertions, 0 deletions
diff --git a/gstudio/views/docu.py b/gstudio/views/docu.py
new file mode 100644
index 0000000..d56b8c4
--- /dev/null
+++ b/gstudio/views/docu.py
@@ -0,0 +1,113 @@
+# Copyright (c) 2011, 2012 Free Software Foundation
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+
+from django.http import HttpResponse
+from django.shortcuts import render_to_response
+from django.template import RequestContext
+from demo.settings import *
+from gstudio.models import *
+from objectapp.models import *
+
+def docu(request):
+ p=Objecttype.objects.get(title="Document")
+ q=p.get_nbh['contains_members']
+ if request.method=="POST":
+ user = request.POST.get("user","")
+ 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","")
+ if rating :
+ rate_it(int(docid),request,int(rating))
+ if delete != "":
+ each=q.get(id=dn)
+ each.delete()
+ ti=each.title
+ os.system("rm -f "+MEDIA_ROOTNEW+'/'+ti)
+ p=Objecttype.objects.get(title="Document")
+ q=p.get_nbh['contains_members']
+ vars=RequestContext(request,{'documents':q,'val':sdoc})
+ template="gstudio/docu.html"
+ return render_to_response(template, vars)
+ if sub3 != "":
+ if sdoc != "":
+ vidon = Objecttype.objects.get(title="Document")
+ vido_new = vidon.get_nbh['contains_members']
+ vido = vido_new.filter(title__contains=sdoc)
+ vido2 = vido.order_by(sub3)
+ variables = RequestContext(request,{'documents':vido2,'val':sdoc})
+ template = "gstudio/docu.html"
+ return render_to_response(template, variables)
+ else:
+ vidon = Objecttype.objects.get(title="Document")
+ vido_new = vidon.get_nbh['contains_members']
+ vido=vido_new.order_by(sub3)
+ variables = RequestContext(request,{'documents':vido,'val':sdoc})
+ template = "gstudio/docu.html"
+ return render_to_response(template, variables)
+ a=[]
+ for each in request.FILES.getlist("doc[]",""):
+ a.append(each)
+ if a != "":
+ for f in a:
+ save_file(f)
+ create_object(f,user)
+ vars=RequestContext(request,{'documents':q})
+ template="gstudio/docu.html"
+ return render_to_response(template, vars)
+ vars=RequestContext(request,{'documents':q})
+ template="gstudio/docu.html"
+ return render_to_response(template, vars)
+
+def save_file(file, path=""):
+ filename = file._get_name()
+ fd = open('%s/%s' % (MEDIA_ROOTNEW2, str(path) + str(filename)), 'wb')
+ for chunk in file.chunks():
+ fd.write(chunk)
+ fd.close()
+
+def create_object(file,log):
+ p=Gbobject()
+ p.title=file._get_name()
+ p.rurl=MEDIA_ROOTNEW2+"p.title"
+ final = ''
+ for each1 in p.title:
+ if each1==".":
+ final=final+'-'
+ elif each1==" ":
+ final=final+'-'
+ else:
+ final = final+each1
+ p.slug=final
+ p.content=' '
+ p.status=2
+ p.save()
+ p.sites.add(Site.objects.get_current())
+ p.save()
+ s=Author.objects.get(username=log)
+ p.authors.add(s)
+ p.save()
+ q=Objecttype.objects.get(title="Document")
+ p.objecttypes.add(Objecttype.objects.get(id=q.id))
+ p.save()
+
+def rate_it(topic_id,request,rating):
+ ob = Gbobject.objects.get(id=topic_id)
+ ob.rating.add(score=rating ,user=request.user, ip_address=request.META['REMOTE_ADDR'])
+ return True
diff --git a/gstudio/views/group.py b/gstudio/views/group.py
new file mode 100644
index 0000000..157e276
--- /dev/null
+++ b/gstudio/views/group.py
@@ -0,0 +1,105 @@
+# Copyright (c) 2011, 2012 Free Software Foundation
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+from django.http import HttpResponse
+from django.http import HttpResponseRedirect
+from django.template import RequestContext
+from django.shortcuts import render_to_response
+from gstudio.models import *
+from gstudio.methods import *
+
+
+def grouplater(request, sys_id, starttime):
+# return HttpResponse("the meeting is scheduled later")
+ now=datetime.datetime.now()
+ sys=System.objects.get(id=sys_id)
+ template="gstudio/later.html"
+ var=RequestContext(request, {'sys':sys, 'starttime':starttime})
+ return render_to_response(template, var)
+def groupover(request,sys_id, endtime):
+# return HttpResponse("the meeting is over!")
+ sys=System.objects.get(id=sys_id)
+ template="gstudio/over.html"
+ var=RequestContext(request, {'sys':sys, 'endtime':endtime})
+ return render_to_response(template, var)
+
+
+
+def groupdashboard(request,grpid):
+ grpid = int(grpid)
+ (later, meetover, starttime, endtime) = get_time(grpid)
+ # if meetover:
+# return groupover(request, grpid, endtime)
+ if later and request.user.id != System.objects.get(id=grpid).authors.all()[0].id:
+ return grouplater(request, grpid, starttime)
+ else:
+
+ boolean1 = False
+ flag= False
+ meeting_ob = System.objects.get(id=grpid)
+ if request.method == "POST" :
+ boolean = False
+ rep = request.POST.get("reply",'')
+ id_no = request.POST.get("iden",'')
+ id_no1 = request.POST.get("parentid","")
+ idusr = request.POST.get("idusr",'')
+ rating = request.POST.get("star1","")
+ flag1=request.POST.get("release","")
+ block = request.POST.get("block","")
+ topic_del = request.POST.get("del_topic", "")
+ comment_del = request.POST.get("del_comment", "")
+
+ if topic_del:
+ del_topic(int(id_no))
+ if comment_del:
+ del_comment(int(id_no1))
+
+ if flag1:
+ boolean1 = True
+ make_att_true(meeting_ob)
+ if block :
+ make_att_false(meeting_ob)
+ if rating :
+ rate_it(int(id_no),request,int(rating))
+ if rep :
+ if not id_no :
+ boolean = make_relation(rep,int(id_no1),int(idusr))
+ elif not id_no1 :
+ boolean = make_relation(rep,int(id_no),int(idusr))
+ if boolean :
+ return HttpResponseRedirect("/gstudio/group/gnowsys-grp/"+str(grpid))
+ grpid = int(grpid)
+ if request.user.id == meeting_ob.authors.all()[0].id :
+ flag = True
+ Topic = meeting_ob.system_set.all()[0].gbobject_set.all()
+ admin_id = meeting_ob.authors.all()[0].id #a list of topics
+ for each in meeting_ob.subject_of.all():
+ if each.attributetype.title=='release':
+
+ attob = each.svalue
+ break
+ admin_m = meeting_ob.authors.all()[0]
+ topic_type_set=Objecttype.objects.get(title='Topic')
+ if(len(topic_type_set.get_members)):
+ latest_topic=topic_type_set.get_members[0]
+ post=latest_topic.get_absolute_url()
+ else:
+ post="no topic added yet!!"
+ variables = RequestContext(request,{'topic' : Topic , 'meet_ob' : meeting_ob, "flag" : flag, "flag1" : boolean1, "admin_id" : admin_id, "attribute" : attob, 'admin_m':admin_m, 'endtime':endtime, 'post':post})
+ template = "metadashboard/grpdashboard.html"
+ return render_to_response(template, variables)
+
+
+
diff --git a/gstudio/views/groupadd.py b/gstudio/views/groupadd.py
new file mode 100644
index 0000000..d0c7242
--- /dev/null
+++ b/gstudio/views/groupadd.py
@@ -0,0 +1,50 @@
+# Copyright (c) 2011, 2012 Free Software Foundation
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+from django.http import HttpResponse
+from django.http import HttpResponseRedirect
+from django.template import RequestContext
+from django.shortcuts import render_to_response
+from gstudio.models import *
+from gstudio.methods import *
+import datetime
+def groupadd(request):
+ errors = []
+ if request.method == 'POST':
+ if not request.POST.get('subject', ''):
+ errors.append('Enter a title.')
+ if not request.POST.get('message', ''):
+ errors.append('Enter a message.')
+ stDate = (request.POST["stDate"]).split("/")
+ endDate=(request.POST["endDate"]).split("/")
+ hours1 = int(request.POST["hours1"])
+ minutes1 = int(request.POST["minutes1"])
+ hours2 = int(request.POST["hours2"])
+ minutes2 = int(request.POST["minutes2"])
+ time1 = datetime.datetime(int(stDate[2]),int(stDate[0]),int(stDate[1]),hours1,minutes1)
+ time2 = datetime.datetime(int(endDate[2]),int(endDate[0]),int(endDate[1]),hours2,minutes2)
+
+ if not errors:
+ title=request.POST['subject']
+ content=request.POST['message']
+ idusr=request.POST['idusr']
+ meetId = create_meeting(title,int(idusr),content)
+ schedule_time(time1, time2, meetId)
+ if meetId :
+ return HttpResponseRedirect('/gstudio/group/gnowsys-grp/'+ str(meetId))
+ variables = RequestContext(request,{'errors' : errors })
+ template = "gstudio/NewGroup.html"
+ return render_to_response(template, variables)
+
diff --git a/gstudio/views/image.py b/gstudio/views/image.py
new file mode 100644
index 0000000..fd642eb
--- /dev/null
+++ b/gstudio/views/image.py
@@ -0,0 +1,128 @@
+# Copyright (c) 2011, 2012 Free Software Foundation
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+
+from django.http import HttpResponse
+from django.shortcuts import render_to_response
+from django.template import RequestContext
+from demo.settings import *
+from gstudio.models import *
+from objectapp.models import *
+import os
+
+def image(request):
+ p=Objecttype.objects.get(title="Image")
+ q=p.get_nbh['contains_members']
+ if request.method=="POST":
+ title = request.POST.get("title1","")
+ simg = request.POST.get("simg","")
+ sub3 = request.POST.get("mydropdown","")
+ user = request.POST.get("user","")
+ delete = request.POST.get("delete","")
+ rating = request.POST.get("star1","")
+ imgid = request.POST.get("imgid","")
+ pict = request.POST.get("pict","")
+ fulid = request.POST.get("fulid","")
+ if fulid != "":
+ i=Gbobject.objects.get(id=fulid)
+ vars=RequestContext(request,{'image':i})
+ template="gstudio/fullscreen.html"
+ return render_to_response(template, vars)
+ if rating :
+ rate_it(int(imgid),request,int(rating))
+ if delete != "":
+ each=q.get(id=pict)
+ each.delete()
+ ti=each.title
+ os.system("rm -f "+MEDIA_ROOTNEW+'/'+ti)
+ p=Objecttype.objects.get(title="Image")
+ q=p.get_nbh['contains_members']
+ vars=RequestContext(request,{'images':q,'val':simg})
+ template="gstudio/image.html"
+ return render_to_response(template, vars)
+ if sub3 != "":
+ if simg != "":
+ vidon = Objecttype.objects.get(title="Image")
+ vido_new = vidon.get_nbh['contains_members']
+ vido = vido_new.filter(title__contains=simg)
+ vido2 = vido.order_by(sub3)
+ variables = RequestContext(request,{'images':vido2,'val':simg})
+ template = "gstudio/image.html"
+ return render_to_response(template, variables)
+ else:
+ vidon = Objecttype.objects.get(title="Image")
+ vido_new = vidon.get_nbh['contains_members']
+ vido=vido_new.order_by(sub3)
+ variables = RequestContext(request,{'images':vido,'val':simg})
+ template = "gstudio/image.html"
+ return render_to_response(template, variables)
+ a=[]
+ for each in request.FILES.getlist("image[]",""):
+ a.append(each)
+ if a != "":
+ i=0
+ for f in a:
+ if i==0:
+ save_file(f,title)
+ create_object(f,user,title)
+ i=i+1
+ else:
+ save_file(f,title+'_'+str(i))
+ create_object(f,user,title+'_'+str(i))
+ i=i+1
+ p=Objecttype.objects.get(title="Image")
+ q=p.get_nbh['contains_members']
+ vars=RequestContext(request,{'images':q})
+ template="gstudio/image.html"
+ return render_to_response(template, vars)
+ vars=RequestContext(request,{'images':q,'val':""})
+ template="gstudio/image.html"
+ return render_to_response(template, vars)
+
+def save_file(file,title, path=""):
+ filename = title
+ fd = open('%s/%s' % (MEDIA_ROOTNEW2, str(path) + str(filename)), 'wb')
+ for chunk in file.chunks():
+ fd.write(chunk)
+ fd.close()
+
+def create_object(file,log,title):
+ p=Gbobject()
+ p.title=title
+ p.image=p.title
+ final = ''
+ for each1 in p.title:
+ if each1==" ":
+ final=final+'-'
+ else:
+ final = final+each1
+ p.slug=final
+ p.content=' '
+ p.status=2
+ p.save()
+ p.sites.add(Site.objects.get_current())
+ p.save()
+ s=Author.objects.get(username=log)
+ p.authors.add(s)
+ p.save()
+ q=Objecttype.objects.get(title="Image")
+ p.objecttypes.add(Objecttype.objects.get(id=q.id))
+ p.save()
+
+def rate_it(topic_id,request,rating):
+ ob = Gbobject.objects.get(id=topic_id)
+ ob.rating.add(score=rating ,user=request.user, ip_address=request.META['REMOTE_ADDR'])
+ return True
diff --git a/gstudio/views/login.py b/gstudio/views/login.py
new file mode 100644
index 0000000..469719b
--- /dev/null
+++ b/gstudio/views/login.py
@@ -0,0 +1,80 @@
+# Copyright (c) 2011, 2012 Free Software Foundation
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+# This project incorporates work covered by the following copyright and permission notice:
+
+# Copyright (c) 2009, Julien Fache
+# All rights reserved.
+
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of the author nor the names of other
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+# OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Copyright (c) 2011, 2012 Free Software Foundation
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+
+from django.http import HttpResponse
+from django.http import HttpResponseRedirect
+from django.template import RequestContext
+from django.shortcuts import render_to_response
+
+def logindashboard(request):
+ if request.user.is_authenticated():
+ link = u"/gstudio/user/" + request.user.username
+ return HttpResponseRedirect(link)
+ else :
+ variables = RequestContext(request)
+ template = "metadashboard/logindashboard.html"
+ return render_to_response(template,variables)
+
+
diff --git a/gstudio/views/topicadd.py b/gstudio/views/topicadd.py
new file mode 100644
index 0000000..ba094c5
--- /dev/null
+++ b/gstudio/views/topicadd.py
@@ -0,0 +1,47 @@
+
+
+# Copyright (c) 2011, 2012 Free Software Foundation
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+
+from django.http import HttpResponse
+from django.http import HttpResponseRedirect
+from django.template import RequestContext
+from django.shortcuts import render_to_response
+from gstudio.models import *
+from gstudio.methods import *
+
+def topicadd(request):
+ errors = []
+ if request.method == 'POST':
+ if not request.POST.get('subject', ''):
+ errors.append('Enter a title.')
+ if not request.POST.get('message', ''):
+ errors.append('Enter a message.')
+ if not errors:
+ title=request.POST['subject']
+ content=request.POST['message']
+ idusr=request.POST['idusr']
+ boolean = make_topic_object(title,int(idusr),content)
+ if boolean :
+ return HttpResponseRedirect('/betameta/Chatroom/')
+ variables = RequestContext(request,{'errors' : errors })
+ template = "gstudio/NewTopic.html"
+ return render_to_response(template, variables)
+
+
+
+
diff --git a/gstudio/views/topicadd1.py b/gstudio/views/topicadd1.py
new file mode 100644
index 0000000..dc1865f
--- /dev/null
+++ b/gstudio/views/topicadd1.py
@@ -0,0 +1,50 @@
+
+
+# Copyright (c) 2011, 2012 Free Software Foundation
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+
+from django.http import HttpResponse
+from django.http import HttpResponseRedirect
+from django.template import RequestContext
+from django.shortcuts import render_to_response
+from gstudio.models import *
+from gstudio.methods import *
+
+def topicadd1(request,grpid):
+ errors = []
+ if request.method == 'POST':
+ if not request.POST.get('subject', ''):
+ errors.append('Enter a title.')
+ if not request.POST.get('message', ''):
+ errors.append('Enter a message.')
+ if not errors:
+ title=request.POST['subject']
+ content=request.POST['message']
+ idusr=request.POST['idusr']
+ tp = make_topic_object(title,int(idusr),content)
+ System.objects.get(id=int(grpid)).system_set.all()[0].gbobject_set.add(tp)
+ if tp:
+ return HttpResponseRedirect('/gstudio/group/gnowsys-grp/'+grpid)
+
+
+ variables = RequestContext(request,{'errors' : errors})
+ template = "gstudio/NewTopic1.html"
+ return render_to_response(template, variables)
+
+
+
+
diff --git a/gstudio/views/user.py b/gstudio/views/user.py
new file mode 100644
index 0000000..10e1ff7
--- /dev/null
+++ b/gstudio/views/user.py
@@ -0,0 +1,38 @@
+# Copyright (c) 2011, 2012 Free Software Foundation
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+
+from django.http import HttpResponse
+from django.http import HttpResponseRedirect
+from django.template import RequestContext
+from django.shortcuts import render_to_response
+from gstudio.methods import *
+
+def userdashboard(request,username):
+ if request.user.username == username :
+ meetings = Systemtype.objects.get(title="Meeting")
+ variables = RequestContext(request,{"meetings" : meetings })
+ template = "metadashboard/userdashboard.html"
+ return render_to_response(template, variables)
+ else :
+ variables = RequestContext(request)
+ template = "metadashboard/logindashboard.html"
+ return render_to_response(template,variables)
+
+
+
+
+
diff --git a/gstudio/views/video.py b/gstudio/views/video.py
new file mode 100644
index 0000000..660bf06
--- /dev/null
+++ b/gstudio/views/video.py
@@ -0,0 +1,273 @@
+# Copyright (c) 2011, 2012 Free Software Foundation
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+
+from django.http import HttpResponse
+from django.shortcuts import render_to_response
+import ox
+import os
+from gstudio.models import *
+from objectapp.models import *
+from django.template import RequestContext
+from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
+from demo.settings import *
+from gstudio.methods import *
+
+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'})
+ if request.method == 'POST':
+ clip = request.FILES.getlist("clip[]","")
+ 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","")
+ 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","")
+ if full!="" :
+ variables= RequestContext(request,{'id':full})
+ template="gstudio/transcript.html"
+ return render_to_response(template,variables)
+ if fav != "" :
+ list1=[]
+ t=Gbobject.objects.get(title=user)
+ 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})
+ template = "gstudio/video.html"
+ return render_to_response(template, variables)
+
+ if rating :
+ rate_it(int(vidid),request,int(rating))
+
+ if favid!="":
+ e=0
+ r = Objecttype.objects.get(title="user")
+ for each in r.get_nbh['contains_members']:
+ if favusr == each.title:
+ e=1
+ if e==0 :
+ t=Gbobject()
+ t.title=favusr
+ t.slug=favusr
+ t.content=' '
+ t.status=2
+ t.save()
+ t.objecttypes.add(Objecttype.objects.get(title="user"))
+ t.save()
+ t=Gbobject.objects.get(title=favusr)
+ rel=Relation()
+ rt=Relationtype.objects.get(title="has_favourite")
+ rel.relationtype_id=rt.id
+ f1=Gbobject.objects.get(id=favid)
+ rel.left_subject_id=t.id
+ rel.right_subject_id=f1.id
+ rel.save()
+ t.save()
+ if clip != "":
+ api.signup({'username':user,'password':'wetube'})
+ save_file(clip)
+ clipname = clip._get_name()
+ i=0
+ dirname = ""
+ while clipname[i] != ".":
+ dirname = dirname + clipname[i]
+ i=i+1
+ y=str(dirname)
+ os.system("pandora_client scan")
+ os.system("pandora_client sync")
+ 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.title=each['title'].lower()
+ m.rurl="http://wetube.gnowledge.org/"+each['id']+'/480p.webm'
+ m.slug=each['id']
+ m.content=' '
+ m.status=2
+ m.save()
+ m.objecttypes.add(Objecttype.objects.get(id=p.id))
+ m.save()
+ a=Attribute()
+ a.attributetype=Attributetype.objects.get(title="posted_by")
+ a.subject=m
+ a.svalue=user
+ a.save()
+ a1=Attribute()
+ a1.attributetype=Attributetype.objects.get(title="time_limit")
+ a1.subject=m
+ a1.svalue=each['duration']
+ a1.save()
+ a2=Attribute()
+ a2.attributetype=Attributetype.objects.get(title="creation_day")
+ a2.subject=m
+ a2.svalue=each['created']
+ a2.save()
+ a3=Attribute()
+ a3.attributetype=Attributetype.objects.get(title="source")
+ a3.subject=m
+ a3.svalue=each['sourcedescription']
+ a3.save()
+ a4=Attribute()
+ a4.attributetype=Attributetype.objects.get(title="map_link")
+ a4.subject=m
+ l=each['sourcedescription']
+ final=''
+ for each in l:
+ if each==" ":
+ final=final+'+'
+ else:
+ final=final+each
+ 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)
+ if sub3 == 'title':
+ vido2 = vido.order_by(sub3)
+ else:
+ vido2 = sort_video(vido)
+ variables = RequestContext(request,{'vids':vido2,'val':svid})
+ template = "gstudio/video.html"
+ return render_to_response(template, variables)
+ else:
+ vidon = Objecttype.objects.get(title="Video")
+ vido_new = vidon.get_nbh['contains_members']
+ vido = vido_new.filter(slug__contains=svid)
+ if sub3 == 'title':
+ vido2 = vido.order_by(sub3)
+ else:
+ vido2 = sort_video(vido)
+ variables = RequestContext(request,{'vids':vido2,'val':svid})
+ template = "gstudio/video.html"
+ return render_to_response(template, variables)
+ else:
+ vidon = Objecttype.objects.get(title="Video")
+ vido_new = vidon.get_nbh['contains_members']
+ if sub3 == 'title':
+ vido=vido_new.order_by(sub3)
+ else:
+ vido=sort_video(vido_new)
+ variables = RequestContext(request,{'vids':vido,'val':svid})
+ template = "gstudio/video.html"
+ return render_to_response(template, variables)
+ 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:
+ flag=0
+ for vid in q:
+ if vid.title==each['title'].lower():
+ flag=1
+ if flag==0:
+ m=Gbobject()
+ m.title=each['title'].lower()
+ m.rurl="http://wetube.gnowledge.org/"+each['id']+'/480p.webm'
+ m.slug=each['id']
+ m.content=' '
+ m.status=2
+ m.save()
+ m.objecttypes.add(Objecttype.objects.get(id=p.id))
+ m.save()
+ a=Attribute()
+ a.attributetype=Attributetype.objects.get(title="posted_by")
+ a.subject=m
+ a.svalue=each['user']
+ a.save()
+ a1=Attribute()
+ a1.attributetype=Attributetype.objects.get(title="time_limit")
+ a1.subject=m
+ a1.svalue=each['duration']
+ a1.save()
+ a2=Attribute()
+ a2.attributetype=Attributetype.objects.get(title="creation_day")
+ a2.subject=m
+ a2.svalue=each['created']
+ a2.save()
+ a3=Attribute()
+ a3.attributetype=Attributetype.objects.get(title="source")
+ a3.subject=m
+ a3.svalue=each['sourcedescription']
+ a3.save()
+ a4=Attribute()
+ a4.attributetype=Attributetype.objects.get(title="map_link")
+ a4.subject=m
+ l=each['sourcedescription']
+ final=''
+ for each in l:
+ if each==" ":
+ final=final+'+'
+ else:
+ final=final+each
+ a4.svalue=final
+ a4.save()
+ m.save()
+ svid=""
+ q=p.get_nbh['contains_members']
+ variables = RequestContext(request,{'vids':q,'val':svid})
+ template = "gstudio/video.html"
+ return render_to_response(template, variables)
+
+def save_file(file, path=""):
+ filename = file._get_name()
+ i=0
+ dirname = ""
+ while filename[i] != ".":
+ dirname = dirname + filename[i]
+ i=i+1
+ x=str(filename[0]).upper()
+ y=str(dirname)
+ z = ''
+ for each1 in y:
+ if each1==" ":
+ 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')
+ for chunk in file.chunks():
+ fd.write(chunk)
+ fd.close()
+
+def sort_video(video):
+ a = []
+ i = 0
+ for each in video:
+ a.append(each)
+ while i < video.count()-1:
+ min = i
+ j = i+1
+ while j < video.count():
+ if a[min].get_nbh['creation_day'][0] > a[j].get_nbh['creation_day'][0] :
+ min = j
+ j = j+1
+ temp = a[i]
+ a[i] = a[min]
+ a[min] = temp
+ i = i+1
+ return a