예제 #1
0
파일: views.py 프로젝트: noamsu/lernanta
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"))
예제 #2
0
파일: views.py 프로젝트: vtamara/lernanta
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))
예제 #3
0
파일: views.py 프로젝트: cillian/batucada
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('/')
예제 #4
0
파일: views.py 프로젝트: AndyHendy/lernanta
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'))
예제 #5
0
파일: views.py 프로젝트: AndyHendy/lernanta
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))
예제 #6
0
파일: views.py 프로젝트: cillian/batucada
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)))
예제 #7
0
파일: views.py 프로젝트: waytai/batucada
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)))
예제 #8
0
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)))
예제 #9
0
파일: tests.py 프로젝트: oinopion/twitz
 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)