def thread(request, threadid): thread = Thread.get_by_id(int(threadid)) posts = ThreadPostsViewModel(thread) return render_to_response( 'home/thread.html', { 'forum': thread.forum, 'thread': ThreadViewModel(thread), 'posts': posts, 'post_form': PostForm() })
def thread(request, threadid): thread = Thread.get_by_id(int(threadid)) posts = ThreadPostsViewModel(thread) return render_to_response('home/thread.html', { 'forum' : thread.forum, 'thread' : ThreadViewModel(thread), 'posts' : posts, 'post_form' : PostForm() })
def create_post_submit_process(request): try: logging.info("User Id {0}".format(request.POST['userid'])) thread = Thread.get_by_id(int(request.POST['threadid'])) user = User(request.POST['userid']) #I have to add some value that is not null or empty to content #to get round what seems to be a bug with either Django forms or Django #forms with the google app engine post = Post(user=user, thread=thread, content="CONTENT") data = PostForm(data=request.POST, instance=post) if data.is_valid(): entity = data.save(commit=False) entity.put() thread.forum.increment_post_count() thread.set_last_post(entity) thread.increment_post_count() else: logging.info("data not valid") except Exception, e: logging.info(e.message)
def create_post_submit_process(request): try: logging.info("User Id {0}".format(request.POST['userid'])) thread = Thread.get_by_id(int(request.POST['threadid'])) user = User(request.POST['userid']) #I have to add some value that is not null or empty to content #to get round what seems to be a bug with either Django forms or Django #forms with the google app engine post = Post(user=user, thread=thread, content="CONTENT") data = PostForm(data=request.POST, instance=post) if data.is_valid(): entity = data.save(commit=False) entity.put() thread.forum.increment_post_count() thread.set_last_post(entity) thread.increment_post_count() else: logging.info("data not valid") except Exception, e: logging.info(e.message)
def create_post_submit(request, threadid): thread = Thread.get_by_id(int(threadid)) #I have to add some value that is not null or empty to content #to get round what seems to be a bug with either Django forms or Django #forms with the google app engine post = Post(user=request._user, thread=thread, content="CONTENT") data = PostForm(data=request.POST, instance=post) if data.is_valid(): for n in range(10): dataToSend = dict(request.POST) dataToSend['userid'] = request._user.user_id() dataToSend['threadid'] = thread.key().id() taskqueue.add(url='/tasks/insertpost/', params=dataToSend) return HttpResponseRedirect('/thread/{0}/'.format(threadid)) posts = Post.all().filter('thread =', thread).order('datetime') return render_to_response('home/thread.html', { 'forum': thread.forum, 'thread': thread, 'posts': posts, 'post_form': data })
def create_post_submit(request, threadid): thread = Thread.get_by_id(int(threadid)) #I have to add some value that is not null or empty to content #to get round what seems to be a bug with either Django forms or Django #forms with the google app engine post = Post(user=request._user, thread=thread, content="CONTENT") data = PostForm(data=request.POST, instance=post) if data.is_valid(): for n in range(10): dataToSend = dict(request.POST) dataToSend['userid'] = request._user.user_id() dataToSend['threadid'] = thread.key().id() taskqueue.add(url='/tasks/insertpost/', params=dataToSend) return HttpResponseRedirect('/thread/{0}/'.format(threadid)) posts = Post.all().filter('thread =', thread).order('datetime') return render_to_response('home/thread.html',{ 'forum' : thread.forum, 'thread' : thread, 'posts' : posts, 'post_form' : data })