def post(self, request): me, rqstPst = request.user, request.POST fid, body = rqstPst['fid'], rqstPst['body'] oldForum = Forum.objects.get(id=fid) post = me.author_post.create(body=body) FILES = request.FILES.getlist('attached') if FILES: postMediaAdd(me, post, FILES) forum_reply = oldForum.selv_forum.create(post=post) tmpl = loader.get_template('forum-reply.html') ctx = tmpl.render({'forum_reply': forum_reply}, request) return JsonResponse({'ctx': ctx, 'forumReply': True})
def post(self, request): me, rqstPst = request.user, request.POST title, body = rqstPst['title'], rqstPst['body'] title = Title.objects.create(title=title) post = me.author_post.create(body=body) FILES = request.FILES.getlist('attached') if FILES: postMediaAdd(me, post, FILES) forum = post.post_forum.create( title=title) #Forum.objects.create(post=post) tmpl = loader.get_template('forum-template.html') ctx = tmpl.render({'forum': forum}, request) return JsonResponse({'forumAdded': True, 'ctx': ctx})
def post(self, request): me, rqstPst = request.user, request.POST fid, title, body = rqstPst['fid'], rqstPst['title'], rqstPst['body'] title = Title.objects.create(title=title) oldForum = Forum.objects.get(id=fid) post = me.author_post.create( body=body) #Post.objects.create(author=me) FILES = request.FILES.getlist('attached') if FILES: postMediaAdd(me, post, FILES) forum_self = oldForum.selv_forum.create(post=post, title=title) tmpl = loader.get_template('forum-self.html') ctx = tmpl.render({'forum': forum_self}, request) return JsonResponse({'ctx': ctx, 'forumSelf': True})
def post(self, request): me, rqstPst=request.user, request.POST title, body=rqstPst['title'], rqstPst['body'] post=me.author_post.create(body=body) title=Title.objects.create(title=title) blog=post.post_blog.create(title=title) FILES=request.FILES.getlist('attached') if FILES: postMediaAdd(me, post, FILES) ''' for media in request.FILES.getlist('attached'): mdm=me.user_medium.create(media=media) post.media.add(mdm) ''' tmpl=loader.get_template('blog-template.html') ctx=tmpl.render({'blog':blog}, request) return JsonResponse({'blogAdded':True, 'ctx':ctx})
def post(self, request): me, rqstPst=request.user, request.POST bid, title, body=rqstPst['bid'], rqstPst['title'], rqstPst['body'] blog=Blog.objects.get(id=bid) post, blogTitle=blog.post, blog.title FILES=request.FILES.getlist('attached') if FILES: postMediaAdd(me, post, FILES) titleRevised, bodyRevised=title!=blogTitle.title, body!=post.body if titleRevised: blogTitle.title=title blogTitle.save() if bodyRevised: post.body=body post.save() if bodyRevised or titleRevised: return JsonResponse({'blogUpdated':True}) return JsonResponse({'blogUpdated':False})
def post(self, request): me, rqstPst = request.user, request.POST fid, title, body = rqstPst['fid'], rqstPst['title'], rqstPst['body'] forum = Forum.objects.get(id=fid) post, forumTitle = forum.post, forum.title FILES = request.FILES.getlist('attached') if FILES: postMediaAdd(me, post, FILES) forumBody = post.body titleRevised, bodyRevised = title != forumTitle.title, body != forumBody if titleRevised: forumTitle.title = title forumTitle.save() if bodyRevised: post.body = body post.save() if bodyRevised or titleRevised: return JsonResponse({'forumUpdated': True}) return JsonResponse({'forumUpdated': False})