def postTopic(request): mlogger.info("In post Topic page.....................") mlogger.debug("Type of request.user %s" % type(request.user)) topic = FtopicForm(request.POST, request.FILES) if not topic.is_valid(): d = {"is_valid": "false", "response_html": topic.as_table()} json = simplejson.dumps(d) if request.FILES: json = "<textarea>"+simplejson.dumps(d)+"</textarea>" else: json = simplejson.dumps(d) return HttpResponse(json, content_type=json_mimetype) #code which checks for flood control if (timezone.now()-request.user.get_profile().last_posttime).seconds < settings.FLOOD_TIME: #oh....... user trying to flood us Stop him d2 = {"is_valid": "flood", "errormessage": "Flood control.................."} if request.FILES: json = "<textarea>"+simplejson.dumps(d2)+"</textarea>" else : json = simplejson.dumps(d2) return HttpResponse(json, content_type=json_mimetype) ftopic = topic.save(commit=False) #only if there is any file if request.FILES : if(request.FILES['file'].content_type.find("image") >= 0 ) : ftopic.attachment_type = "image" else : ftopic.attachment_type = "text" ftopic.filename = request.FILES['file'].name ftopic.posted_by = request.user mlogger.debug("categoryid= %s" %request.POST['categoryid']) ftopic.category = Category.objects.get(pk = request.POST['categoryid']) #Assigning user rank mlogger.debug("Assigning an user rank and last posted datetime") assignUserElements(request.user) ftopic.save() #autosubsribe ftopic.subscribers.add(request.user) mlogger.debug("what is the message (%s %s) " % (ftopic.message,ftopic.subject)) payload = {'topic':ftopic} response_html = render_to_string('dinette/topic_detail_frag.html', payload,RequestContext(request)) mlogger.debug("what is the response = %s " % response_html) d2 = {"is_valid":"true","response_html":response_html} #this the required for ajax file uploads if request.FILES : json = "<textarea>"+simplejson.dumps(d2)+"</textarea>" else : json = simplejson.dumps(d2) return HttpResponse(json, content_type=json_mimetype)
def postTopic(request) : mlogger.info("In post Topic page.....................") mlogger.debug("Type of request.user %s" % type(request.user) ) topic = FtopicForm(request.POST,request.FILES) if topic.is_valid() == False : d = {"is_valid":"false","response_html":topic.as_table()} json = simplejson.dumps(d) return HttpResponse(json, mimetype = json_mimetype) #code which checks for flood control if (datetime.now() -(request.user.get_profile().last_posttime)).seconds <= settings.FLOOD_TIME : #oh....... user trying to flood us Stop him d2 = {"is_valid":"flood","errormessage":_("Flood control..................")} json = simplejson.dumps(d2) return HttpResponse(json, mimetype = json_mimetype) ftopic = topic.save(commit=False) #only if there is any file if request.FILES : if(request.FILES['file'].content_type.find("image") >= 0 ) : ftopic.attachment_type = "image" else : ftopic.attachment_type = "text" ftopic.filename = request.FILES['file'].name ftopic.posted_by = request.user mlogger.debug("categoryid= %s" %request.POST['categoryid']) ftopic.category = Category.objects.get(pk = request.POST['categoryid']) #Assigning user rank mlogger.debug("Assigning an user rank and last posted datetime") assignUserElements(request.user) ftopic.save() #autosubsribe ftopic.subscribers.add(request.user) ftopic.save() mlogger.debug("what is the message (%s %s) " % (ftopic.message,ftopic.subject)) payload = {'topic':ftopic} response_html = render_to_string('dinette/topic_detail_frag.html', payload,RequestContext(request)) mlogger.debug("what is the response = %s " % response_html) d2 = {"is_valid":"true","response_html":response_html} json = simplejson.dumps(d2) return HttpResponse(json, mimetype = json_mimetype)
def postTopic(request) : topic = FtopicForm(request.POST,request.FILES) if topic.is_valid() == False : d = {"is_valid":"false","response_html":topic.as_table()} json = simplejson.dumps(d) if request.FILES : json = "<textarea>"+simplejson.dumps(d)+"</textarea>" else: json = simplejson.dumps(d) return HttpResponse(json, mimetype = json_mimetype) #code which checks for flood control last_posttime = request.user.last_posttime if last_posttime and (datetime.now() - last_posttime).seconds <= settings.FLOOD_TIME: #oh....... user trying to flood us Stop him d2 = {"is_valid":"flood","errormessage":"Flood control.................."} if request.FILES : json = "<textarea>"+simplejson.dumps(d2)+"</textarea>" else : json = simplejson.dumps(d2) return HttpResponse(json, mimetype = json_mimetype) ftopic = topic.save(commit=False) #only if there is any file if request.FILES : if(request.FILES['file'].content_type.find("image") >= 0 ) : ftopic.attachment_type = "image" else : ftopic.attachment_type = "text" ftopic.filename = request.FILES['file'].name ftopic.posted_by = request.user ftopic.category = Category.objects.get(pk = request.POST['categoryid']) #Assigning user rank assignUserElements(request.user) ftopic.save() payload = {'topic':ftopic} response_html = render_to_string('dinette/topic_detail_frag.html', payload,RequestContext(request)) d2 = {"is_valid":"true","response_html":response_html} #this the required for ajax file uploads if request.FILES : json = "<textarea>"+simplejson.dumps(d2)+"</textarea>" else : json = simplejson.dumps(d2) return HttpResponse(json, mimetype = json_mimetype)