コード例 #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
ファイル: views.py プロジェクト: Suggsgested/lernanta
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_is_not_valid_with_too_long_text(self):
     f = StatusForm({'text': 'a' * 257})
     self.assertFalse(f.is_valid())
コード例 #10
0
ファイル: tests.py プロジェクト: oinopion/twitz
 def test_is_valid_with_text(self):
     f = StatusForm({'text': 'What is your quest?'})
     self.assertTrue(f.is_valid())