diff --git a/editor/urls.py b/editor/urls.py index 9ff6497..a4c01f4 100644 --- a/editor/urls.py +++ b/editor/urls.py @@ -9,6 +9,8 @@ (r'^authors/$', 'authors'), (r'^authors/create/$', 'create_author'), + (r'^authors/(?P\d+)/$', 'author_edit'), + (r'^authors/(?P\d+)/create/$', 'create_author'), (r'^projects/$', 'projects'), (r'^projects/create/$', 'create_project'), diff --git a/editor/views.py b/editor/views.py index 15cfd47..68d9826 100644 --- a/editor/views.py +++ b/editor/views.py @@ -129,9 +129,18 @@ def project_body(request, id): @login_required def authors(request): authors = Author.objects.all() + author = authors[0] return render_to_response('lifeflow/editor/authors.html', - {'authors':authors}, + {'author':author,'authors':authors}, RequestContext(request,{})) + +@login_required +def author_edit(request,id): + author = Author.objects.get(pk=id) + return render_to_response('lifeflow/editor/author.html', + {'author':author}, + RequestContext(request,{})) + @@ -500,10 +509,10 @@ def create_project(request): return HttpResponseRedirect("/editor/projects/%s/details/" % obj.pk) @login_required -def create_author(request): +def create_author(request,id=None): obj = Author() obj.save() - return HttpResponseRedirect("/editor/authors/%s/" % obj.pk) + return HttpResponseRedirect("/editor/authors/") @login_required diff --git a/templates/lifeflow/editor/authors.html b/templates/lifeflow/editor/authors.html index 931a4d0..74d7bec 100644 --- a/templates/lifeflow/editor/authors.html +++ b/templates/lifeflow/editor/authors.html @@ -22,7 +22,16 @@ delete_model("author",pk,onComplete); } }); + $("#authors").change(function() { + var res = $("#authors"); + var index = res[0].selectedIndex; + var pk = res[0][index].value; +// update this to load via ajax + $("#author").load(pk + '/').show(); + }); + }); +
@@ -35,10 +44,8 @@ {% endfor %}
-
- {% with authors.0 as author %} +
{% include "lifeflow/editor/author.html" %} - {% endwith %}
{% endblock %} \ No newline at end of file