Esempio n. 1
0
def edit_stand(request):
    if request.method == "POST":
        form = StandForm(request.POST,instance=request.stand)
        if form.is_valid():
            form.save()
        return HttpResponseRedirect("/_stand/")
    else:
        is_seed_stand = True
        if settings.DEBUG == False:
            # in production
            is_seed_stand = request.stand.hostname == "forest.ccnmtl.columbia.edu"
        return dict(stand=request.stand,
                    form=StandForm(instance=request.stand),
                    is_seed_stand=is_seed_stand
                    )
Esempio n. 2
0
def add_stand(request):
    if not request.user.is_staff:
        return HttpResponse("only staff may access this")
    form = StandForm()
    if request.method == "POST":
        form = StandForm(request.POST)
        hostname = request.POST.get('hostname','')
        r = Stand.objects.filter(hostname=hostname)
        if r.count() > 0:
            return HttpResponse("a stand with that hostname already exists")
        if form.is_valid():
            stand = form.save()
            su = StandUser.objects.create(stand=stand,user=request.user,access="admin")
            for pb in settings.PAGEBLOCKS:
                sapb = StandAvailablePageBlock.objects.create(stand=stand,block=pb)
            if hostname.endswith(".forest.ccnmtl.columbia.edu"):
                # if it's a *.forest site, just send them on their way
                return HttpResponseRedirect("http://%s/_stand/" % hostname)
            else:
                return dict(created=True,stand=stand)
    return dict(form=form)