summaryrefslogtreecommitdiff
path: root/gstudio/views/page.py
blob: d673f77093dbc176844621eaa5624ab8205ec64e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# 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 pagedashboard(request,pageid):
   pageid = int(pageid)
   # boolean1 = False
   flag= False
   page_ob = System.objects.get(id=pageid)
   if request.method == "POST" :
      boolean = False
      rep = request.POST.get("replytosection",'')
      print "rep" ,rep
#      content_org = request.POST.get("orgreply",'')
      id_no = request.POST.get("iden",'')
      id_no1 = request.POST.get("parentid","")
      print"id",id_no1
      idusr = request.POST.get("idusr",'')
      rating = request.POST.get("star1","")
   # #    flag1=request.POST.get("pagerelease","")
   # #    block = request.POST.get("block","")
      section_del = request.POST.get("del_section", "")
      comment_del = request.POST.get("del_comment", "")
      if section_del:
         del_section(int(id_no))
      if comment_del:
         del_comment(int(id_no1))
      if rating :
         rate_section(int(id_no),request,int(rating))
      if rep :
         if not id_no :
            ptitle= make_title(int(id_no))      
            boolean = make_sectionrelation(rep,ptitle,int(id_no1),int(idusr))
            
           
         elif not id_no1 :
            ptitle= make_title(int(id_no))
            boolean = make_sectionrelation(rep,ptitle,int(id_no),int(idusr))
            
      if boolean :
         return HttpResponseRedirect("/gstudio/page/gnowsys-page/"+str(pageid))
   pageid = int(pageid)
   if request.user.id == page_ob.authors.all()[0].id :
      flag = True 
   Section = page_ob.system_set.all()[0].gbobject_set.all()
   admin_id = page_ob.authors.all()[0].id #a list of topics
   #    #    for each in page_ob.subject_of.all():
   #    #       if each.attributetype.title=='pagerelease':
   #    #          attob = each.svalue
   #    #       break
   admin_m = page_ob.authors.all()[0]
   
   topic_type_set=Objecttype.objects.get(title='Section')
   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!!"
   ot=Gbobject.objects.get(id=pageid)

   variables = RequestContext(request, {'ot' : ot,'section' : Section,'page_ob' : page_ob,'admin_m':admin_m,"flag" : flag,"admin_id" : admin_id,'post':post})
   template = "metadashboard/pgedashboard.html"
   return render_to_response(template, variables)