diff options
-rw-r--r-- | snakeplan/projects/forms.py | 9 | ||||
-rw-r--r-- | snakeplan/projects/urls.py | 5 | ||||
-rw-r--r-- | snakeplan/projects/views/projects.py | 17 | ||||
-rwxr-xr-x | snakeplan/settings.py | 5 | ||||
-rw-r--r-- | snakeplan/templates/projects/project_form.html | 13 |
5 files changed, 44 insertions, 5 deletions
diff --git a/snakeplan/projects/forms.py b/snakeplan/projects/forms.py new file mode 100644 index 0000000..a218394 --- /dev/null +++ b/snakeplan/projects/forms.py | |||
@@ -0,0 +1,9 @@ | |||
1 | from django.forms import ModelForm | ||
2 | |||
3 | import models as project_models | ||
4 | |||
5 | |||
6 | class ProjectForm(ModelForm): | ||
7 | |||
8 | class Meta: | ||
9 | model = project_models.Project | ||
diff --git a/snakeplan/projects/urls.py b/snakeplan/projects/urls.py index 46c10a4..6aec48a 100644 --- a/snakeplan/projects/urls.py +++ b/snakeplan/projects/urls.py | |||
@@ -1,9 +1,10 @@ | |||
1 | from django.conf.urls.defaults import patterns | 1 | from django.conf.urls.defaults import patterns, url |
2 | 2 | ||
3 | 3 | ||
4 | urlpatterns = patterns('snakeplan.projects.views', | 4 | urlpatterns = patterns('snakeplan.projects.views', |
5 | (r'^$', 'projects.index'), | 5 | (r'^$', 'projects.index'), |
6 | (r'^story/(.*)/', 'stories.index'), | 6 | (r'^story/(.*)/', 'stories.index'), |
7 | (r'^iteration/(.*)/', 'iterations.index'), | 7 | (r'^iteration/(.*)/', 'iterations.index'), |
8 | (r'^(.*)/', 'projects.project_iterations'), | 8 | (r'^create/', 'projects.create_project'), |
9 | url(r'^(.*)/', 'projects.project_iterations', name='project_iterations'), | ||
9 | ) | 10 | ) |
diff --git a/snakeplan/projects/views/projects.py b/snakeplan/projects/views/projects.py index 78de64c..7cc4017 100644 --- a/snakeplan/projects/views/projects.py +++ b/snakeplan/projects/views/projects.py | |||
@@ -1,6 +1,10 @@ | |||
1 | from django.views.generic import list_detail | 1 | from django.views.generic import list_detail, create_update |
2 | from django.core.urlresolvers import reverse | ||
3 | |||
2 | from snakeplan.projects.models import Project | 4 | from snakeplan.projects.models import Project |
3 | from snakeplan.projects.models import Iteration | 5 | from snakeplan.projects.models import Iteration |
6 | from snakeplan.projects.forms import ProjectForm | ||
7 | |||
4 | 8 | ||
5 | 9 | ||
6 | def index(request): | 10 | def index(request): |
@@ -12,8 +16,8 @@ def index(request): | |||
12 | 16 | ||
13 | 17 | ||
14 | def project_iterations(request, project_id): | 18 | def project_iterations(request, project_id): |
15 | iterations = Iteration.objects.filter(project=project_id) | 19 | project = Project.objects.get(id=project_id) |
16 | project = iterations[0].project | 20 | iterations = project.iteration_set.all() |
17 | 21 | ||
18 | return list_detail.object_list( | 22 | return list_detail.object_list( |
19 | request=request, | 23 | request=request, |
@@ -21,3 +25,10 @@ def project_iterations(request, project_id): | |||
21 | extra_context={'project_name': project}, | 25 | extra_context={'project_name': project}, |
22 | allow_empty=True | 26 | allow_empty=True |
23 | ) | 27 | ) |
28 | |||
29 | |||
30 | def create_project(request): | ||
31 | post_save_redirect = '/project/%(id)s/' | ||
32 | return create_update.create_object(request, | ||
33 | form_class=ProjectForm, | ||
34 | post_save_redirect=post_save_redirect) | ||
diff --git a/snakeplan/settings.py b/snakeplan/settings.py index 6da9ec1..0a9d681 100755 --- a/snakeplan/settings.py +++ b/snakeplan/settings.py | |||
@@ -1,3 +1,7 @@ | |||
1 | import os.path | ||
2 | |||
3 | PROJECT_DIR = os.path.abspath(os.path.dirname(__file__)) | ||
4 | |||
1 | DEBUG = True | 5 | DEBUG = True |
2 | TEMPLATE_DEBUG = DEBUG | 6 | TEMPLATE_DEBUG = DEBUG |
3 | 7 | ||
@@ -43,6 +47,7 @@ MIDDLEWARE_CLASSES = ( | |||
43 | ROOT_URLCONF = 'snakeplan.urls' | 47 | ROOT_URLCONF = 'snakeplan.urls' |
44 | 48 | ||
45 | TEMPLATE_DIRS = ( | 49 | TEMPLATE_DIRS = ( |
50 | os.path.join(PROJECT_DIR, 'templates'), | ||
46 | ) | 51 | ) |
47 | 52 | ||
48 | INSTALLED_APPS = ( | 53 | INSTALLED_APPS = ( |
diff --git a/snakeplan/templates/projects/project_form.html b/snakeplan/templates/projects/project_form.html new file mode 100644 index 0000000..9f91f87 --- /dev/null +++ b/snakeplan/templates/projects/project_form.html | |||
@@ -0,0 +1,13 @@ | |||
1 | <html> | ||
2 | <head> | ||
3 | <title>OH: oh shit, i just added templates to the old directory</title> | ||
4 | </head> | ||
5 | <body> | ||
6 | <form action="" method="POST"> | ||
7 | <ul> | ||
8 | {{ form.as_ul }} | ||
9 | </ul> | ||
10 | <input type="submit" value="Save"/> | ||
11 | </form> | ||
12 | </body> | ||
13 | </html> | ||