Beispiel #1
0
def edit(request, id):
    photo = get_object_or_404(Photo, pk=id)
    user = request.user
    if photo.user != user:
        return HttpResponseRedirect('/photos/check/%s/' % photo.id)
    context_map = get_base_context_map(request)
    data = photo.__dict__
    from oldphoto.utils.html2text import html2text
    data['descn'] = html2text(photo.descn)
    data['txt_tags'] = photo.get_txt_tags()
    form = PhotoForm(data=data)
    if request.POST:
        form = PhotoForm(request.POST, request.FILES, user, photo)
        if form.is_valid():
            photo = form.save()
            if photo == None:
                context_map['form'] = form
                return render_to_response('photos/edit.html', context_map)
            return HttpResponseRedirect('/photos/check/%s/' % photo.id)
    context_map['form'] = form
    context_map['photo'] = photo
    return render_to_response('photos/edit.html', context_map)
Beispiel #2
0
def edit(request, id):
    photo=get_object_or_404(Photo, pk=id)
    user = request.user
    if photo.user!=user:
        return HttpResponseRedirect('/photos/check/%s/' % photo.id)
    context_map=get_base_context_map(request)
    data=photo.__dict__
    from oldphoto.utils.html2text import html2text
    data['descn']=html2text(photo.descn)
    data['txt_tags']=photo.get_txt_tags()
    form = PhotoForm(data=data)
    if request.POST:
        form = PhotoForm(request.POST, request.FILES, user, photo)
        if form.is_valid():
            photo=form.save()
            if photo==None:
                context_map['form']=form
                return render_to_response('photos/edit.html',
                    context_map)
            return HttpResponseRedirect('/photos/check/%s/' % photo.id)
    context_map['form']=form
    context_map['photo']=photo
    return render_to_response('photos/edit.html',
        context_map)
Beispiel #3
0
 def get_short_comment(self):
     from oldphoto.utils.html2text import html2text
     comment=html2text(self.comment)
     if len(comment)>40:
         return comment[0:38]+'...'
     return comment