示例#1
0
 def process_POST(self):
     guest = self.request.user
     
     text = self.request.POST.get('text', None)
     
     if guest.is_authenticated():
         app = Application.objects.get(short_name = self.appname)
         
         try:
             DataChecker.check_comment(text)
             
             comment = Comment()
             comment.user = guest
             comment.app = app
             comment.text = text
             comment.save()
             
             messages.success(self.request, UserMsgs.COMMENT_ADDED)
             
             if MeritsChecker.check_comments(guest):
                 messages.info(self.request, UserMsgs.MERIT_ACHIEVED)
             
             return HttpResponseRedirect('/app/%s/comments/' % \
                     app.short_name)
         except DataError, error:
             messages.error(self.request, error.msg)
             
             comments = app.comment_set.all().order_by('-time')
             
             return render_to_response('app_comments_list.html', \
                     {'guest': guest, 'app': app, \
                     'comments': comments, 'text': text,}, \
                     context_instance=RequestContext(self.request))
示例#2
0
 def process_PUT(self):
     guest = self.request.user
     
     if guest.is_authenticated():
         app = Application.objects.get(short_name = self.appname)
         comment = Comment.objects.get(app = app, order = self.commentno)
         
         try:
             text = self.request.POST.get('text', '')
             
             DataChecker.check_comment(text)
             
             comment.text = text
             comment.save()
             
             return HttpResponseRedirect('/app/%s/comment/%s/' % \
                     (app.short_name, comment.order))
         except DataError, error:
             messages.error(self.request, error.msg)
             
             return render_to_response('comment.html', \
                     {'guest': guest, 'app': app, \
                     'comment': comment, 'edit': True, 'text': text,}, \
                     context_instance=RequestContext(self.request))