[open-ils-commits] r269 - in servres/trunk/conifer: . static syrup templates templates/components (gfawcett)

svn at svn.open-ils.org svn at svn.open-ils.org
Sat Apr 4 15:11:11 EDT 2009


Author: gfawcett
Date: 2009-04-04 15:11:08 -0400 (Sat, 04 Apr 2009)
New Revision: 269

Added:
   servres/trunk/conifer/templates/item_delete_confirm.xhtml
Modified:
   servres/trunk/conifer/TODO
   servres/trunk/conifer/static/main.css
   servres/trunk/conifer/static/menublocks.js
   servres/trunk/conifer/syrup/models.py
   servres/trunk/conifer/syrup/urls.py
   servres/trunk/conifer/syrup/views.py
   servres/trunk/conifer/templates/components/course.xhtml
   servres/trunk/conifer/templates/item_add_elec.xhtml
   servres/trunk/conifer/templates/item_add_heading.xhtml
   servres/trunk/conifer/templates/item_add_phys.xhtml
   servres/trunk/conifer/templates/item_add_url.xhtml
   servres/trunk/conifer/templates/item_heading_detail.xhtml
   servres/trunk/conifer/templates/item_metadata.xhtml
Log:
added 'delete this item' support in the user-interface.

Modified: servres/trunk/conifer/TODO
===================================================================
--- servres/trunk/conifer/TODO	2009-04-04 19:04:52 UTC (rev 268)
+++ servres/trunk/conifer/TODO	2009-04-04 19:11:08 UTC (rev 269)
@@ -17,6 +17,10 @@
 
 * 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

Modified: servres/trunk/conifer/static/main.css
===================================================================
--- servres/trunk/conifer/static/main.css	2009-04-04 19:04:52 UTC (rev 268)
+++ servres/trunk/conifer/static/main.css	2009-04-04 19:11:08 UTC (rev 269)
@@ -223,7 +223,7 @@
 
 #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; }

Modified: servres/trunk/conifer/static/menublocks.js
===================================================================
--- servres/trunk/conifer/static/menublocks.js	2009-04-04 19:04:52 UTC (rev 268)
+++ servres/trunk/conifer/static/menublocks.js	2009-04-04 19:11:08 UTC (rev 269)
@@ -9,7 +9,7 @@
     var menublock = $(this);
     var blockid = 'menublock' + (blocknum++);
     menublock.attr('id', blockid);
-    var opener = '<a class="menublockopener" onmouseout="maybe_cancelblock(\'' + blockid + '\');" onmouseover="maybe_openblock(\'' + blockid + '\');" href="javascript:openblock(\'' + blockid + '\');">&raquo;</a>';
+    var opener = '<a class="menublockopener" onmouseout="maybe_cancelblock(\'' + blockid + '\');" onmouseover="maybe_openblock(\'' + blockid + '\');" href="javascript:maybe_openblock(\'' + blockid + '\');">&raquo;</a>';
     menublock.before(opener);
     menublock.hide();
 }

Modified: servres/trunk/conifer/syrup/models.py
===================================================================
--- servres/trunk/conifer/syrup/models.py	2009-04-04 19:04:52 UTC (rev 268)
+++ servres/trunk/conifer/syrup/models.py	2009-04-04 19:11:08 UTC (rev 269)
@@ -436,6 +436,9 @@
         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?"""
 

Modified: servres/trunk/conifer/syrup/urls.py
===================================================================
--- servres/trunk/conifer/syrup/urls.py	2009-04-04 19:04:52 UTC (rev 268)
+++ servres/trunk/conifer/syrup/urls.py	2009-04-04 19:11:08 UTC (rev 269)
@@ -37,6 +37,7 @@
     (ITEM_PREFIX + r'dl/(?P<filename>.*)$', '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'),
 

Modified: servres/trunk/conifer/syrup/views.py
===================================================================
--- servres/trunk/conifer/syrup/views.py	2009-04-04 19:04:52 UTC (rev 268)
+++ servres/trunk/conifer/syrup/views.py	2009-04-04 19:11:08 UTC (rev 269)
@@ -807,6 +807,24 @@
         item.save()
         return HttpResponseRedirect(item.parent_url())
         
+ at 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):

Modified: servres/trunk/conifer/templates/components/course.xhtml
===================================================================
--- servres/trunk/conifer/templates/components/course.xhtml	2009-04-04 19:04:52 UTC (rev 268)
+++ servres/trunk/conifer/templates/components/course.xhtml	2009-04-04 19:11:08 UTC (rev 269)
@@ -115,10 +115,13 @@
       <span id="i18n-save-order">Save Sequence</span>
       <span id="i18n-resequence-items">Resequence Items</span>
       <span id="i18n-new-order-saved">The new sequence has been saved.</span>
-      <div id="ropanelmessage" style="clear: right; width: 10em;"
+      <div id="eropanelmessage" style="clear: right; width: 10em;"
 	   class="little_action_panel">Drag the items around. Then click Save Sequence, above.</div>
     </div>
     </div>
 
+    <div py:def="offer_to_delete(item)" class="little_action_panel" py:if="item.id">
+      <a href="../delete/">Delete this item</a>
+    </div>
 </html>
 

Modified: servres/trunk/conifer/templates/item_add_elec.xhtml
===================================================================
--- servres/trunk/conifer/templates/item_add_elec.xhtml	2009-04-04 19:04:52 UTC (rev 268)
+++ servres/trunk/conifer/templates/item_add_elec.xhtml	2009-04-04 19:11:08 UTC (rev 269)
@@ -18,6 +18,7 @@
   <body>
     ${course_banner(course)}
     ${nested_title(parent_item)}
+    ${offer_to_delete(item)}
     <h2>${title}</h2>
     <h3>Metadata</h3>
     <div py:if="not is_edit">

Modified: servres/trunk/conifer/templates/item_add_heading.xhtml
===================================================================
--- servres/trunk/conifer/templates/item_add_heading.xhtml	2009-04-04 19:04:52 UTC (rev 268)
+++ servres/trunk/conifer/templates/item_add_heading.xhtml	2009-04-04 19:11:08 UTC (rev 269)
@@ -18,6 +18,7 @@
   <body>
     ${course_banner(course)}
     ${nested_title(parent_item)}
+    ${offer_to_delete(item)}
     <h3>${title}</h3>
     <form action=".?item_type=${item_type}" method="POST">
       <table>

Modified: servres/trunk/conifer/templates/item_add_phys.xhtml
===================================================================
--- servres/trunk/conifer/templates/item_add_phys.xhtml	2009-04-04 19:04:52 UTC (rev 268)
+++ servres/trunk/conifer/templates/item_add_phys.xhtml	2009-04-04 19:11:08 UTC (rev 269)
@@ -17,6 +17,7 @@
   <body>
     ${course_banner(course)}
     ${nested_title(parent_item)}
+    ${offer_to_delete(item)}
     <h3>${title}</h3>
 
     <form action=".?item_type=${item_type}" method="POST">

Modified: servres/trunk/conifer/templates/item_add_url.xhtml
===================================================================
--- servres/trunk/conifer/templates/item_add_url.xhtml	2009-04-04 19:04:52 UTC (rev 268)
+++ servres/trunk/conifer/templates/item_add_url.xhtml	2009-04-04 19:11:08 UTC (rev 269)
@@ -18,6 +18,7 @@
   <body>
     ${course_banner(course)}
     ${nested_title(parent_item)}
+    ${offer_to_delete(item)}
     <h3>${title}</h3>
     <form action=".?item_type=${item_type}" method="POST">
       <table>

Copied: servres/trunk/conifer/templates/item_delete_confirm.xhtml (from rev 267, servres/trunk/conifer/templates/item_metadata.xhtml)
===================================================================
--- servres/trunk/conifer/templates/item_delete_confirm.xhtml	                        (rev 0)
+++ servres/trunk/conifer/templates/item_delete_confirm.xhtml	2009-04-04 19:11:08 UTC (rev 269)
@@ -0,0 +1,41 @@
+<?python
+course_title = '%s: %s (%s)' % (course.code, course.title, course.term)
+hier = item.hierarchy()[:-1]
+if item.item_type == 'HEADING':
+    title = _('Delete this heading?')
+    children = item.children()
+else:
+    title = _('Delete this item?')
+    children = []
+metadata = item.metadata_set.all()
+?>
+<html xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:xi="http://www.w3.org/2001/XInclude"
+      xmlns:py="http://genshi.edgewall.org/">
+  <xi:include href="master.xhtml"/>
+  <xi:include href="components/course.xhtml"/>
+  <head>
+    <title>${title}</title>
+  </head>
+  <body>
+    ${course_banner(course)}
+    ${nested_title(item)}
+    <h1>${title}</h1>
+    <p>Are you sure you want to delete this?</p>
+    <p py:if="children">
+      <strong>Note: this will also delete all items under the heading!</strong>
+    </p>
+    <table class="metadata_table" style="margin-top: 1em;">
+      <tr><th>Title</th><td>${item.title}</td></tr>
+      <tr><th>Type</th><td>${item.get_item_type_display()}</td></tr>
+      <tr py:if="item.url"><th>URL</th><td><a href="${item.url}">${item.url}</a></td></tr>
+    </table>
+    <p>
+    <form action="." method="POST">
+      <input type="submit" name="yes" value="Yes, delete it" style="padding: 4 12; margin-right: 24;"/>
+      <input type="submit" name="no" value="Cancel"/>
+    </form>
+    </p>
+  </body>
+</html>
+

Modified: servres/trunk/conifer/templates/item_heading_detail.xhtml
===================================================================
--- servres/trunk/conifer/templates/item_heading_detail.xhtml	2009-04-04 19:04:52 UTC (rev 268)
+++ servres/trunk/conifer/templates/item_heading_detail.xhtml	2009-04-04 19:11:08 UTC (rev 269)
@@ -17,6 +17,17 @@
   <body>
     ${course_banner(course)}
     ${nested_title(item)}
+    <div py:if="is_editor" class="little_action_panel">
+      <div>
+	<a href="edit/">Edit this heading</a>
+      </div>
+      <div>
+	<a href="delete/">Delete this heading</a>
+      </div>
+      <div>
+	<a href="relocate/">Relocate this heading</a>
+      </div>
+    </div>
     <p py:if="not item_tree">
       There are no items in this section.
     </p>

Modified: servres/trunk/conifer/templates/item_metadata.xhtml
===================================================================
--- servres/trunk/conifer/templates/item_metadata.xhtml	2009-04-04 19:04:52 UTC (rev 268)
+++ servres/trunk/conifer/templates/item_metadata.xhtml	2009-04-04 19:11:08 UTC (rev 269)
@@ -3,6 +3,7 @@
 hier = item.hierarchy()[:-1]
 title = item.title
 metadata = item.metadata_set.all()
+is_editor = course.can_edit(request.user)
 ?>
 <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:xi="http://www.w3.org/2001/XInclude"
@@ -15,6 +16,14 @@
   <body>
     ${course_banner(course)}
     ${nested_title(item)}
+    <div py:if="is_editor">
+    <div class="little_action_panel">
+      <a href="edit/">Edit this item</a>
+    </div>
+    <div class="little_action_panel">
+      <a href="delete/">Delete this item</a>
+    </div>
+    </div>
     <table class="metadata_table" style="margin-top: 1em;">
       <tr><th>Title</th><td>${item.title}</td></tr>
       <tr><th>Type</th><td>${item.get_item_type_display()}</td></tr>



More information about the open-ils-commits mailing list