예제 #1
0
파일: views.py 프로젝트: Fangang/microblog
def postinternal(request):
    if request.method != 'POST' or 'secret' not in request.POST or request.POST['secret'] != 'SECRET!':
	raise Http404()

    profile = get_object_or_404(Profile, jid=request.POST['jid'])
    entry = Entry(owner=profile, content=request.POST['content'], post_date=datetime.now())
    entry.save()
    try:
	entry.parse_post()
	entry.save()
	entry.publish()
    except:
	entry.delete()
	raise

    return HttpResponse('OK')
예제 #2
0
def postinternal(request):
    if request.method != 'POST' or 'secret' not in request.POST or request.POST[
            'secret'] != 'SECRET!':
        raise Http404()

    profile = get_object_or_404(Profile, jid=request.POST['jid'])
    entry = Entry(owner=profile,
                  content=request.POST['content'],
                  post_date=datetime.now())
    entry.save()
    try:
        entry.parse_post()
        entry.save()
        entry.publish()
    except:
        entry.delete()
        raise

    return HttpResponse('OK')
예제 #3
0
파일: views.py 프로젝트: Fangang/microblog
def postentry(request):
    if request.method == 'POST':
	form = PostEntryForm(request.POST)
	if form.is_valid():
	    profile = Profile.objects.get_or_create(user=request.user)[0]
	    entry = Entry(owner=profile, content=form.cleaned_data['content'], post_date=datetime.now())
	    entry.save()
	    try:
		entry.parse_post()
		entry.save()
		entry.publish()
	    except:
		entry.delete()
		raise

	    next = urlresolvers.reverse('microblog_index')
	    return HttpResponseRedirect(next + "?posted=1")
    else:
	form = PostEntryForm()

    return render_to_response('microblog/postentry.html', { 'form': form })
예제 #4
0
def postentry(request):
    if request.method == 'POST':
        form = PostEntryForm(request.POST)
        if form.is_valid():
            profile = Profile.objects.get_or_create(user=request.user)[0]
            entry = Entry(owner=profile,
                          content=form.cleaned_data['content'],
                          post_date=datetime.now())
            entry.save()
            try:
                entry.parse_post()
                entry.save()
                entry.publish()
            except:
                entry.delete()
                raise

            next = urlresolvers.reverse('microblog_index')
            return HttpResponseRedirect(next + "?posted=1")
    else:
        form = PostEntryForm()

    return render_to_response('microblog/postentry.html', {'form': form})