summaryrefslogtreecommitdiff
path: root/gstudio/views/sectionadd1.py
blob: 55ba6ff632dbac9ab5a8ff906af67a9b95ac9b50 (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

#     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 sectionadd1(request,pageid):
    errors = []
    if request.method == 'POST':
        if not request.POST.get('subject', ''):
             errors.append('Enter a title.')
        if not request.POST.get('org', ''):
             errors.append('Enter a page.')
        if not errors:
  	     title=request.POST['subject']
 	    # content=request.POST['page']
             content_org=unicode(request.POST['org'])
	     idusr=request.POST['idusr']
             usr=request.POST['usr']
             tp = make_section_object(title,int(idusr),content_org,usr)
             System.objects.get(id=int(pageid)).system_set.all()[0].gbobject_set.add(tp)
             if  tp:
              return HttpResponseRedirect('/gstudio/page/gnowsys-page/'+pageid)
    
    
    variables = RequestContext(request,{'errors' : errors,'pageid' : pageid})
    template = "gstudio/NewSection1.html"
    return render_to_response(template, variables)