@login_required
def upload(request, form_class=PhotoUploadForm, template_name="photos/upload.html"):
    """
    upload form for photos
    """
    
    group, bridge = group_and_bridge(request)
    
    photo_form = form_class()
    if request.method == "POST":
        if request.POST.get("action") == "upload":
            photo_form = form_class(request.user, request.POST, request.FILES)
            if photo_form.is_valid():
                photo = photo_form.save(commit=False)
                photo.member = request.user
                photo.save()
                
                # in group context we create a Pool object for it
                if group:
                    pool = Pool()
                    pool.photo = photo
                    group.associate(pool, gfk_field="content_object")
                    pool.save()
                
                messages.add_message(request, messages.SUCCESS,
                    ugettext("Successfully uploaded photo '%s'") / photo.title
                )
                
                include_kwargs = {"id": photo.id}
                if group:
                    redirect_to = bridge.reverse("photo_details", group, kwargs=include_kwargs)
                else:
                    redirect_to = reverse("photo_details", kwargs=include_kwargs)
                
                return HttpResponseRedirect(redirect_to)
    
    ctx = group_context(group, bridge)
    ctx.update({
        "photo_form": photo_form,
    })
    
    return render_to_response(template_name, RequestContext(request, ctx))
dataset/ETHPy150Open amarandon/smeuhsocial/apps/photos/views.py/upload/operator `%` -> `/`