Ejemplo n.º 1
0
def user_edit(request, user_id):
    user = get_object_or_404(User, pk=user_id)
    form = PartialUserForm(request.POST or None, instance=user)
    if form.is_valid():
        user = form.save()
        # this is where you might choose to do stuff.
        # user.name = 'test'
        user.save()
        return redirect(users)

    return render_to_response(
        "mks/user_edit.html", {"user_form": form, "user_id": user_id}, context_instance=RequestContext(request)
    )
Ejemplo n.º 2
0
def user_add(request):
    # sticks in a POST or renders empty form
    form = PartialUserForm(request.POST or None)
    if form.is_valid():
        cmodel = form.save()
        # This is where you might chooose to do stuff.
        cmodel.save()
        dr = os.getcwd()
        os.chdir("/home/nyan/SpotiPi/cfhack/spotify_daemon/src/")
        os.system(
            "/home/nyan/SpotiPi/cfhack/spotify_daemon/src/populate_pldb/populate_pldb -f /home/nyan/SpotiPi/cfhack/web/examplesite/example.db"
        )
        os.chdir(dr)
        return redirect(users)

    return render_to_response("mks/user_add.html", {"user_form": form}, context_instance=RequestContext(request))