예제 #1
0
 def update(self, request, userid, entryid=None):
     if id is None:
         return rc.BAD_REQUEST
     people = get_people(userid)
     if not people.is_local():
         return rc.NOT_IMPLEMENTED
     try:
         entry = Entry.objects.get(author=people, id2=entryid)
     except Entry.DoesNotExist:
         return rc.NOT_FOUND
     if not entry.can_edit(people):
         return rc.FORBIDDEN
     form = EntryForm(request.PUT, instance=entry)
     form.save()
     return rc.ALL_OK
예제 #2
0
def post(request):
    entry = None
    if request.method == 'POST':
        # TODO: implement this
        form = EntryForm(request.POST)
        if form.is_valid():
            if 'post' in request.POST:
                entry = form.save(commit=False)
                author = People.objects.get(user=request.user)
                entry.author = author
                entry.save()
                return HttpResponseRedirect(reverse('wididit:web:entry',
                        args=[entry.author, entry.id2]))
            elif 'preview' in request.POST:
                entry = form.save(commit=False)
                author = People.objects.get(user=request.user)
                entry.author = author
    else:
        form = EntryForm()
    c = RequestContext(request, {
        'form': form,
        'entry': entry,
        })
    return render_to_response('wididitserver/post_form.html', c)