diff options
author | Ankita <ankita@ankita-Inspiron-N5010.(none)> | 2012-07-13 12:31:27 +0530 |
---|---|---|
committer | Ankita <ankita@ankita-Inspiron-N5010.(none)> | 2012-07-13 12:31:27 +0530 |
commit | 527ab688a8608ded5fc854cf8641228181efa981 (patch) | |
tree | 825f17422ce610922f8f34854c5e54db7a7f35ad /gstudio/views/topicadd1.py | |
parent | ef3793b349be5744d6ef98a034f0c009159ed85b (diff) | |
download | gnowsys-527ab688a8608ded5fc854cf8641228181efa981.tar.gz |
this patch was added for metastudio by BITS Pilani team in 2012.
Diffstat (limited to 'gstudio/views/topicadd1.py')
-rw-r--r-- | gstudio/views/topicadd1.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/gstudio/views/topicadd1.py b/gstudio/views/topicadd1.py new file mode 100644 index 00000000..dc1865fb --- /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) + + + + |