示例#1
0
文件: views.py 项目: clayw/CoClass
def edit_place(request, place_id=None):
    # if place_id:
    # place =
    if request.method == "POST":
        form = VenueForm(request.POST)
        if form.is_valid():
            pass
    else:
        form = VenueForm()
    return render_to_response("accounts/makeplace.html", {"form": form}, context_instance=RequestContext(request))
示例#2
0
文件: views.py 项目: meriloi/dealy
def create_venue(request):
    if request.POST:
        form = VenueForm(request.POST)
        if form.is_valid():
            form.save()

            return HttpResponseRedirect('/')
    else:
        form = VenueForm()

    args = {}
    args.update(csrf(request))

    args['form'] = form

    return render_to_response('create_venue.html', args)
示例#3
0
文件: views.py 项目: clayw/CoClass
def expert_settings(request):
    user = request.user
    places = user.place.all()
    try:
        expert = user.expert.all()[0]
    except:
        expert = None
    if request.method == "POST":
        from accounts.forms import VenueForm
        from places.models import Place

        post_data = request.POST
        place_form = VenueForm(post_data)
        form = ExpertForm(request.POST, instance=expert)
        if form.is_valid():
            if post_data["place"] == "-1":
                if place_form.is_valid():
                    place = place_form.save(request)
                else:
                    raise Exception("place not valid?")
            else:
                place = Place.objects.get(pk=int(post_data["place"]))
            expert = form.save(commit=False)
            expert.user = user
            expert.place = place
            if post_data.get("active", False):
                expert.privacy = "a"
            expert.save()
            return HttpResponseRedirect("/users/%s/expert" % (request.user.username))
    else:
        form = ExpertForm(instance=expert)
    return render_to_response(
        "accounts/expert_settings.html",
        {"expert": expert, "form": form, "places": places},
        context_instance=RequestContext(request),
    )