def form_valid(self, form): text = Text(content=form.cleaned_data['content'], title=form.cleaned_data['title']) if self.request.user.is_authenticated(): text.user_id = self.request.user.id; text.save() add_language_to_paste.delay(text) return render_to_response('paste/added.html', { "id": text.id })
def form_valid(self, form): text = Text(content=form.cleaned_data['content'], title=form.cleaned_data['title']) if self.request.user.is_authenticated(): text.user_id = self.request.user.id text.save() add_language_to_paste.delay(text) return render_to_response('paste/added.html', {"id": text.id})
def form_valid(self, form, request, **kwargs): text = Text.objects.get(id=kwargs['pk']) text.content = form.cleaned_data['content'] text.title = form.cleaned_data['title'] if request.user.is_authenticated: if text.user_id: if request.user.id == text.user_id: text.save() add_language_to_paste.delay(text) return render_to_response('paste/edited.html', { "id": text.id });
def form_valid(self, form, request, **kwargs): text = Text.objects.get(id=kwargs['pk']) text.content = form.cleaned_data['content'] text.title = form.cleaned_data['title'] if request.user.is_authenticated: if text.user_id: if request.user.id == text.user_id: text.save() add_language_to_paste.delay(text) return render_to_response('paste/edited.html', {"id": text.id})
def post(self, request): if 'content' in request.POST and 'title' in request.POST: content = request.POST['content'] title = request.POST['title'] text = Text(content=content, title=title) if request.user.is_authenticated: if request.user.id: text.user_id = self.request.user.id; add_language_to_paste.delay(text) text.save() response = { 'id': text.id } else: response = { 'error': 'malformed request'} return response
def post(self, request, key): response = { 'error': 'malformed request' } if 'content' in request.POST and 'id' in request.POST: response = { 'error': 'authorization denied' } content = request.POST['content'] id = request.POST['id'] text = Text.objects.get(id=id) if request.user.is_authenticated: if text.user_id: if request.user.id == text.user_id: text.save() add_language_to_paste.delay(text) response = { 'id': text.id } return response