#NEWLINE# @ login_required #NEWLINE# def postTopic( request ) : #NEWLINE# #INDENT# mlogger . info ( 'In post Topic page.....................' ) #NEWLINE# mlogger . debug ( ( 'Type of request.user %s' % type ( request . user ) ) ) #NEWLINE# topic = FtopicForm ( request . POST , request . FILES ) #NEWLINE# if ( not topic . is_valid ( ) ) : #NEWLINE# #INDENT# d = { #NEWLINE# #INDENT# 'is_valid' : 'false' , #NEWLINE# 'response_html' : topic . as_table ( ) , #NEWLINE# #UNINDENT# } #NEWLINE# json = json . dumps ( d ) #NEWLINE# if request . FILES : #NEWLINE# #INDENT# json = ( ( '<textarea>' + json . dumps ( d ) ) + '</textarea>' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# json = json . dumps ( d ) #NEWLINE# #UNINDENT# return HttpResponse ( json , mimetype = json_mimetype ) #NEWLINE# #UNINDENT# if ( ( datetime . now ( ) - request . user . dinetteuserprofile . last_posttime ) . seconds < settings . FLOOD_TIME ) : #NEWLINE# #INDENT# d2 = { #NEWLINE# #INDENT# 'is_valid' : 'flood' , #NEWLINE# 'errormessage' : 'Flood control..................' , #NEWLINE# #UNINDENT# } #NEWLINE# if ftopic . FILES : #NEWLINE# #INDENT# json = ( ( '<textarea>' + json . dumps ( d2 ) ) + '</textarea>' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# json = json . dumps ( d2 ) #NEWLINE# #UNINDENT# return HttpResponse ( json , mimetype = json_mimetype ) #NEWLINE# #UNINDENT# ftopic = topic . save ( commit = False ) #NEWLINE# if request . FILES : #NEWLINE# #INDENT# if ( request . FILES [ 'file' ] . content_type . find ( 'image' ) >= 0 ) : #NEWLINE# #INDENT# ftopic . attachment_type = 'image' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ftopic . attachment_type = 'text' #NEWLINE# #UNINDENT# ftopic . filename = request . FILES [ 'file' ] . name #NEWLINE# #UNINDENT# ftopic . posted_by = request . user #NEWLINE# mlogger . debug ( ( 'categoryid= %s' % request . POST [ 'categoryid' ] ) ) #NEWLINE# ftopic . category = Category . objects . get ( pk = request . POST [ 'categoryid' ] ) #NEWLINE# mlogger . debug ( 'Assigning an user rank and last posted datetime' ) #NEWLINE# assignUserElements ( request . user ) #NEWLINE# ftopic . save ( ) #NEWLINE# ftopic . subscribers . add ( request . user ) #NEWLINE# mlogger . debug ( ( 'what is the message (%s %s) ' % ( ftopic . message , ftopic . subject ) ) ) #NEWLINE# payload = { #NEWLINE# #INDENT# 'topic' : ftopic , #NEWLINE# #UNINDENT# } #NEWLINE# response_html = render_to_string ( 'dinette/topic_detail_frag.html' , payload , RequestContext ( request ) ) #NEWLINE# mlogger . debug ( ( 'what is the response = %s ' % response_html ) ) #NEWLINE# d2 = { #NEWLINE# #INDENT# 'is_valid' : 'true' , #NEWLINE# 'response_html' : response_html , #NEWLINE# #UNINDENT# } #NEWLINE# if request . FILES : #NEWLINE# #INDENT# json = ( ( '<textarea>' + json . dumps ( d2 ) ) + '</textarea>' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# json = json . dumps ( d2 ) #NEWLINE# #UNINDENT# return HttpResponse ( json , mimetype = json_mimetype )