Skip to content

Commit

Permalink
Can now create,delete and edit authors in LFE.
Browse files Browse the repository at this point in the history
  • Loading branch information
lethain committed Jun 4, 2008
1 parent bf49d4f commit 2908ed6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
2 changes: 2 additions & 0 deletions editor/urls.py
Expand Up @@ -9,6 +9,8 @@

(r'^authors/$', 'authors'),
(r'^authors/create/$', 'create_author'),
(r'^authors/(?P<id>\d+)/$', 'author_edit'),
(r'^authors/(?P<id>\d+)/create/$', 'create_author'),

(r'^projects/$', 'projects'),
(r'^projects/create/$', 'create_project'),
Expand Down
15 changes: 12 additions & 3 deletions editor/views.py
Expand Up @@ -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,{}))




Expand Down Expand Up @@ -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
Expand Down
13 changes: 10 additions & 3 deletions templates/lifeflow/editor/authors.html
Expand Up @@ -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();
});

});

</script>

<div class="authors">
Expand All @@ -35,10 +44,8 @@
{% endfor %}
</select>
</div>
<div class="author">
{% with authors.0 as author %}
<div id="author" class="author">
{% include "lifeflow/editor/author.html" %}
{% endwith %}
</div>
</div>
{% endblock %}

0 comments on commit 2908ed6

Please sign in to comment.