"""
Copyright 2010 Jason Chu, Dusty Phillips, and Phil Schalm

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

from django.shortcuts import render_to_response, redirect
from django.views.generic.list_detail import object_list
from django.views.generic.list_detail import object_detail
from django.template import RequestContext

from project.models import Project
from project.forms import ProjectForm

def index(request):
    '''We should move this to a different app'''
    return render_to_response('index.html', RequestContext(request, {}))

def list_projects(request):
    projects = Project.objects.all()
    return object_list(request, projects, template_name="project/project_list.html",
            template_object_name="project")

def view_project(request, project_id):
    return object_detail(request, Project.objects.all(), object_id=project_id,
            template_object_name='project')

def add_project(request):
    form = ProjectForm(request.POST or None)
    if form.is_valid():
        instance = form.save()
        return redirect(instance.get_absolute_url())
    return render_to_response("project/project_form.html",
            RequestContext(request, {'form': form}))

@@ -873,16 +873,57 @@
 jectForm
+%0Afrom preference.models import Preference
 %0A%0Adef in
@@ -1596,16 +1596,89 @@
 _url())%0A
+%0A    base_url = Preference.objects.get(name=%22projects_directory%22).value%0A%0A
     retu
@@ -1777,12 +1777,34 @@
 m': form
+, 'base_url': base_url
 %7D))%0A

send the base_url into the add project form for some jquery goodness.