def create(request): if request.method != "POST" or "status" not in request.POST: return HttpResponseRedirect(reverse("dashboard")) form = StatusForm(data=request.POST) if form.is_valid(): status = form.save(commit=False) status.author = request.user.get_profile() status.save() else: log.debug("form error: %s" % (str(form.errors))) messages.error(request, _("There was an error posting " "your status update")) return HttpResponseRedirect(reverse("dashboard"))
def reply(request, in_reply_to): """Create a status update that is a reply to an activity.""" parent = get_object_or_404(Activity, id=in_reply_to) if request.method == "POST": form = StatusForm(data=request.POST) if form.is_valid(): status = form.save(commit=False) status.author = request.user.get_profile() status.in_reply_to = parent status.save() return HttpResponseRedirect("/") return render_to_response("statuses/reply.html", {"parent": parent}, context_instance=RequestContext(request))
def create(request): if request.method != 'POST' or 'status' not in request.POST: return HttpResponseRedirect('/') form = StatusForm(data=request.POST) if form.is_valid(): status = form.save(commit=False) status.author = request.user.get_profile() status.save() else: log.debug("form error: %s" % (str(form.errors))) messages.error(request, _('There was an error posting ' 'your status update')) return HttpResponseRedirect('/')
def create(request): if request.method != 'POST' or 'status' not in request.POST: return HttpResponseRedirect(reverse('dashboard_index')) form = StatusForm(data=request.POST) if form.is_valid(): status = form.save(commit=False) status.author = request.user.get_profile() status.save() else: log.debug("form error: %s" % (str(form.errors))) messages.error(request, _('There was an error posting ' 'your status update')) return HttpResponseRedirect(reverse('dashboard_index'))
def reply(request, in_reply_to): """Create a status update that is a reply to an activity.""" parent = get_object_or_404(Activity, id=in_reply_to) if request.method == 'POST': form = StatusForm(data=request.POST) if form.is_valid(): status = form.save(commit=False) status.author = request.user.get_profile() status.in_reply_to = parent status.save() return HttpResponseRedirect('/') return render_to_response('statuses/reply.html', { 'parent': parent, }, context_instance=RequestContext(request))
def create_project_status(request, project_id): if request.method != 'POST' or 'status' not in request.POST: return HttpResponseRedirect('/') project = get_object_or_404(Project, id=project_id) profile = request.user.get_profile() form = StatusForm(data=request.POST) if form.is_valid(): status = form.save(commit=False) status.author = request.user.get_profile() status.project = project status.save() else: messages.error(request, _('There was an error posting ' 'your status update')) log.debug("Saved status by user (%d) to project (%d): %s" % ( profile.id, project.id, status)) return HttpResponseRedirect( reverse('projects_show', kwargs=dict(slug=project.slug)))
def create_project_status(request, project_id): if request.method != 'POST' or 'status' not in request.POST: return HttpResponseRedirect('/') project = get_object_or_404(Project, id=project_id) profile = request.user.get_profile() form = StatusForm(data=request.POST) if form.is_valid(): status = form.save(commit=False) status.author = request.user.get_profile() status.project = project status.save() log.debug("Saved status by user (%d) to project (%d): %s" % (profile.id, project.id, status)) else: messages.error(request, _('There was an error posting ' 'your status update')) return HttpResponseRedirect( reverse('projects_show', kwargs=dict(slug=project.slug)))
def create_project_status(request, project_id): if request.method != 'POST' or 'status' not in request.POST: return HttpResponseRedirect('/') project = get_object_or_404(Project, id=project_id) profile = request.user.get_profile() if profile != project.created_by and not profile.user.is_superuser \ and not project.participants().filter(user=profile).exists(): return HttpResponseRedirect('/') form = StatusForm(data=request.POST) if form.is_valid(): status = form.save(commit=False) status.author = request.user.get_profile() status.project = project status.save() log.debug("Saved status by user (%d) to study group (%d): %s" % ( profile.id, project.id, status)) else: log.debug("form error: %s" % (str(form.errors))) messages.error(request, _('There was an error posting ' 'your status update')) return HttpResponseRedirect( reverse('projects_show', kwargs=dict(slug=project.slug)))
def test_sets_correct_author(self): f = StatusForm({'text': 'What is your quest?'}) f.author = User.objects.create_user("jack") self.assertEqual(f.author, f.save().author)