From: gfawcett Date: Sat, 4 Apr 2009 19:11:08 +0000 (+0000) Subject: added 'delete this item' support in the user-interface. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4f856573a48a8f961215c29d1e5a68f84e103a8c;p=syrup%2Fmasslnc.git added 'delete this item' support in the user-interface. git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@269 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- diff --git a/conifer/TODO b/conifer/TODO index eeba77e..eca65a0 100644 --- a/conifer/TODO +++ b/conifer/TODO @@ -17,6 +17,10 @@ IMPORTANT: * the code is littered with 'dwarf' refrences. Factor out into config. +* allow for bulk-import on add-physical-item + MAYBE: * Generating barcodes in emails, printable screens? (3 of 9 enough?) + +* add a hook for a MARC-record-to-maybe-cover-image-URL function diff --git a/conifer/static/main.css b/conifer/static/main.css index 4582472..8be1ac7 100644 --- a/conifer/static/main.css +++ b/conifer/static/main.css @@ -223,7 +223,7 @@ p.todo, div.todo { background-color: #fdd; padding: 6; margin: 12; border-left: #feeds_panel, .little_action_panel -{ float: right; font-size: 95%; margin: 8 0; clear: both; } +{ float: right; font-size: 95%; margin: 8 0; clear: both; text-align: right; } .breadcrumbs { margin: 8 8 8 0; } diff --git a/conifer/static/menublocks.js b/conifer/static/menublocks.js index 7d4de56..5071b7f 100644 --- a/conifer/static/menublocks.js +++ b/conifer/static/menublocks.js @@ -9,7 +9,7 @@ function make_opener() { var menublock = $(this); var blockid = 'menublock' + (blocknum++); menublock.attr('id', blockid); - var opener = '»'; + var opener = '»'; menublock.before(opener); menublock.hide(); } diff --git a/conifer/syrup/models.py b/conifer/syrup/models.py index 40c934f..30e87f1 100644 --- a/conifer/syrup/models.py +++ b/conifer/syrup/models.py @@ -436,6 +436,9 @@ class Item(m.Model): else: return self.parent_heading.hierarchy() + [self] + def children(self): + return Item.objects.filter(parent_heading=self) + def needs_meta_link(self): """Should an 'About' link be displayed for this item?""" diff --git a/conifer/syrup/urls.py b/conifer/syrup/urls.py index 3b0da4a..bda3362 100644 --- a/conifer/syrup/urls.py +++ b/conifer/syrup/urls.py @@ -37,6 +37,7 @@ urlpatterns = patterns('conifer.syrup.views', (ITEM_PREFIX + r'dl/(?P.*)$', 'item_download'), (ITEM_PREFIX + r'meta$', 'item_metadata'), (ITEM_PREFIX + r'edit/$', 'item_edit'), + (ITEM_PREFIX + r'delete/$', 'item_delete'), (ITEM_PREFIX + r'add/$', 'item_add'), # for adding sub-things (ITEM_PREFIX + r'add/cat_search/$', 'item_add_cat_search'), diff --git a/conifer/syrup/views.py b/conifer/syrup/views.py index 0e8c247..96013a0 100644 --- a/conifer/syrup/views.py +++ b/conifer/syrup/views.py @@ -807,6 +807,24 @@ def item_edit(request, course_id, item_id): item.save() return HttpResponseRedirect(item.parent_url()) +@instructors_only +def item_delete(request, course_id, item_id): + course = get_object_or_404(models.Course, pk=course_id) + item = get_object_or_404(models.Item, pk=item_id, course__id=course_id) + if request.method != 'POST': + return g.render('item_delete_confirm.xhtml', **locals()) + else: + if 'yes' in request.POST: + # I think Django's ON DELETE CASCADE-like behaviour will + # take care of the sub-items. + if item.parent_heading: + redir = HttpResponseRedirect(item.parent_heading.item_url('meta')) + else: + redir = HttpResponseRedirect(course.course_url()) + item.delete() + return redir + else: + return HttpResponseRedirect('../meta') @members_only def item_download(request, course_id, item_id, filename): diff --git a/conifer/templates/components/course.xhtml b/conifer/templates/components/course.xhtml index 6208a76..779b331 100644 --- a/conifer/templates/components/course.xhtml +++ b/conifer/templates/components/course.xhtml @@ -115,10 +115,13 @@ searchtext = _('search this course...') Save Sequence Resequence Items The new sequence has been saved. -
Drag the items around. Then click Save Sequence, above.
+ diff --git a/conifer/templates/item_add_elec.xhtml b/conifer/templates/item_add_elec.xhtml index af516fc..18bd0f9 100644 --- a/conifer/templates/item_add_elec.xhtml +++ b/conifer/templates/item_add_elec.xhtml @@ -18,6 +18,7 @@ course_title = '%s: %s (%s)' % (course.code, course.title, course.term) ${course_banner(course)} ${nested_title(parent_item)} + ${offer_to_delete(item)}

${title}

Metadata

diff --git a/conifer/templates/item_add_heading.xhtml b/conifer/templates/item_add_heading.xhtml index 8b9587a..94ab2b2 100644 --- a/conifer/templates/item_add_heading.xhtml +++ b/conifer/templates/item_add_heading.xhtml @@ -18,6 +18,7 @@ course_title = '%s: %s (%s)' % (course.code, course.title, course.term) ${course_banner(course)} ${nested_title(parent_item)} + ${offer_to_delete(item)}

${title}

diff --git a/conifer/templates/item_add_phys.xhtml b/conifer/templates/item_add_phys.xhtml index 89e3327..01692a3 100644 --- a/conifer/templates/item_add_phys.xhtml +++ b/conifer/templates/item_add_phys.xhtml @@ -17,6 +17,7 @@ course_title = '%s: %s (%s)' % (course.code, course.title, course.term) ${course_banner(course)} ${nested_title(parent_item)} + ${offer_to_delete(item)}

${title}

diff --git a/conifer/templates/item_add_url.xhtml b/conifer/templates/item_add_url.xhtml index b23c955..da68d9e 100644 --- a/conifer/templates/item_add_url.xhtml +++ b/conifer/templates/item_add_url.xhtml @@ -18,6 +18,7 @@ course_title = '%s: %s (%s)' % (course.code, course.title, course.term) ${course_banner(course)} ${nested_title(parent_item)} + ${offer_to_delete(item)}

${title}

diff --git a/conifer/templates/item_delete_confirm.xhtml b/conifer/templates/item_delete_confirm.xhtml new file mode 100644 index 0000000..034d921 --- /dev/null +++ b/conifer/templates/item_delete_confirm.xhtml @@ -0,0 +1,41 @@ + + + + + + ${title} + + + ${course_banner(course)} + ${nested_title(item)} +

${title}

+

Are you sure you want to delete this?

+

+ Note: this will also delete all items under the heading! +

+
+ + + + +

+ + + +

+

+ + + diff --git a/conifer/templates/item_heading_detail.xhtml b/conifer/templates/item_heading_detail.xhtml index 7c4c35d..d008916 100644 --- a/conifer/templates/item_heading_detail.xhtml +++ b/conifer/templates/item_heading_detail.xhtml @@ -17,6 +17,17 @@ item_tree = course.item_tree(subtree=item) ${course_banner(course)} ${nested_title(item)} +

There are no items in this section.

diff --git a/conifer/templates/item_metadata.xhtml b/conifer/templates/item_metadata.xhtml index 8f05df1..1014bcb 100644 --- a/conifer/templates/item_metadata.xhtml +++ b/conifer/templates/item_metadata.xhtml @@ -3,6 +3,7 @@ course_title = '%s: %s (%s)' % (course.code, course.title, course.term) hier = item.hierarchy()[:-1] title = item.title metadata = item.metadata_set.all() +is_editor = course.can_edit(request.user) ?> ${course_banner(course)} ${nested_title(item)} +
+ + +