added news-item admin tool
authorgfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Wed, 4 Mar 2009 01:33:21 +0000 (01:33 +0000)
committergfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Wed, 4 Mar 2009 01:33:21 +0000 (01:33 +0000)
git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@134 6d9bc8c9-1ec2-4278-b937-99fde70a366f

conifer/static/main.css
conifer/syrup/urls.py
conifer/syrup/views.py
conifer/templates/admin/index.xhtml
conifer/templates/generic/index.xhtml
conifer/templates/welcome.xhtml

index fd6a3c9..7596901 100644 (file)
@@ -180,6 +180,10 @@ p.todo, div.todo { background-color: #fdd; padding: 6; margin: 12; border-left:
 .newsitem { 
     max-width: 600;
 }
+.newsitem .newsdate { 
+    margin: 4 0 8 0; text-align: right; 
+    font-size: 80%; color: navy;
+}
 
 .menublockopener { color: gray !important; font-weight: normal !important; }
 .menublock { background-color: #f0f0e0; font-size: 95%; padding: 1 4; }
index c5e21f8..5e1f6a1 100644 (file)
@@ -27,6 +27,7 @@ urlpatterns = patterns('conifer.syrup.views',
     (r'^admin/$', 'admin_index'),
     (r'^admin/terms/' + GENERIC_REGEX, 'admin_terms'),
     (r'^admin/depts/' + GENERIC_REGEX, 'admin_depts'),
+    (r'^admin/news/' + GENERIC_REGEX, 'admin_news'),
 
 #     (r'^admin/terms/(?P<term_id>\d+)/$', 'admin_term_edit'),
 #     (r'^admin/terms/(?P<term_id>\d+)/delete$', 'admin_term_delete'),
index ffb423e..ddfd243 100644 (file)
@@ -462,3 +462,19 @@ class DeptForm(ModelForm):
 
 admin_depts = generic_handler(DeptForm)
 
+
+class NewsForm(ModelForm):
+    class Meta:
+        model = models.NewsItem
+
+    class Index:
+        title = 'News Items'
+        all   = models.NewsItem.objects.order_by('-id').all
+        cols  = ['id', 'subject', 'published']
+        links = [0, 1]
+
+    clean_subject = strip_and_nonblank('subject')
+    clean_body = strip_and_nonblank('body')
+
+admin_news = generic_handler(NewsForm)
+
index a4a7150..9d2250a 100644 (file)
@@ -13,6 +13,7 @@ title = 'Administrative Options'
   <ul>
     <li><a href="depts/">Departments</a></li>
     <li><a href="terms/">Terms</a></li>
+    <li><a href="news/">News Items</a></li>
   </ul>
 </body>
 </html>
index ecab82f..819129a 100644 (file)
@@ -8,6 +8,9 @@ title = index.title
 <xi:include href="../master.xhtml"/>
 <head>
   <title>${title}</title>
+  <script type="text/javascript">
+    $(function() { $('table').tablesorter(); });
+  </script>
 </head>
 <body>
   <h1>${title}</h1>
index dac15ff..57cfcc0 100644 (file)
@@ -10,9 +10,10 @@ title = 'Welcome!'
 </head>
 <body>
   <h1>News</h1>
-  <div class="newsitem" py:for="news in models.NewsItem.objects.all().order_by('-published')[0:5]">
+  <div class="newsitem" py:for="news in models.NewsItem.objects.all().order_by('-published','-id')[0:5]">
     <h2>${news.subject}</h2>
     <div>${news.generated_body()}</div>
+    <div class="newsdate">posted ${news.published.strftime('%c')}</div>
   </div>
 </body>
 </html>