Add is_featured boolean property to the Work model, so that Works can be
authorTodd Larsen <tlarsen@google.com>
Tue, 14 Oct 2008 21:39:57 +0000
changeset 329 2d90d49ce78a
parent 328 275a47dd0ac8
child 330 2ef48e962655
Add is_featured boolean property to the Work model, so that Works can be designated as "featured" items in various places in the UI. This will be used to allow Sponsors, Programs, and Organizations to select Documents that should be included in their sidebar menus. Perhaps featured "site" Documents, such as site-wide Terms of Service, should probably be listed below the "User (sign-out)" menu, since the User will have to read and agree to these before being allowed to use the site. A collapsable Javascript sidebar is probably going to be needed soon... Patch by: Todd Larsen Review by: to-be-reviewed
app/soc/models/work.py
app/soc/templates/soc/site/docs/list/docs_heading.html
app/soc/templates/soc/site/docs/list/docs_row.html
app/soc/views/site/docs/edit.py
--- a/app/soc/models/work.py	Tue Oct 14 21:33:57 2008 +0000
+++ b/app/soc/models/work.py	Tue Oct 14 21:39:57 2008 +0000
@@ -98,3 +98,11 @@
   #    * anyone, even those not logged in
   #  (and possibly others)
 
+  #: field storing whether a link to the Work should be featured in
+  #: the sidebar menu (and possibly elsewhere); FAQs, Terms of Service,
+  #: and the like are examples of "featured" Works
+  is_featured = db.BooleanProperty(
+      verbose_name=ugettext_lazy('Is Featured'))
+  is_featured.help_text = ugettext_lazy(
+      'Field used to indicate if a Work should be featured, for example,'
+      ' in the sidebar menu.')
--- a/app/soc/templates/soc/site/docs/list/docs_heading.html	Tue Oct 14 21:33:57 2008 +0000
+++ b/app/soc/templates/soc/site/docs/list/docs_heading.html	Tue Oct 14 21:39:57 2008 +0000
@@ -3,6 +3,7 @@
   <th>Title</th>
   <th>Partial Path</th>
   <th>Linkname</th>
+  <th>Featured</th>
   <th>Created</th>
   <th>Modified</th>
 </tr>
--- a/app/soc/templates/soc/site/docs/list/docs_row.html	Tue Oct 14 21:33:57 2008 +0000
+++ b/app/soc/templates/soc/site/docs/list/docs_row.html	Tue Oct 14 21:39:57 2008 +0000
@@ -9,6 +9,7 @@
   <td><div class="title">{{ data_element.title }}</div></td>
   <td><div class="partialpath">{{ data_element.partial_path }}</div></td>
   <td><div class="link_name">{{ data_element.link_name }}</div></td>
+  <td><div class="featured">{{ data_element.is_featured }}</div></td>
   <td><div class="created">{{ data_element.created }}</div></td>
   <td><div class="modified">{{ data_element.modified }}</div></td>
 </tr>
--- a/app/soc/views/site/docs/edit.py	Tue Oct 14 21:33:57 2008 +0000
+++ b/app/soc/views/site/docs/edit.py	Tue Oct 14 21:39:57 2008 +0000
@@ -101,6 +101,7 @@
   properties['abstract'] = form.cleaned_data.get('abstract')
   properties['content'] = form.cleaned_data.get('content')
   properties['user'] = models.user.logic.getFromFields(email=email)
+  properties['is_featured'] = form.cleaned_data.get('is_featured')
 
   doc = document.logic.updateOrCreateFromFields(properties,
                                                 partial_path=partial_path,
@@ -188,7 +189,7 @@
             'title': doc.title, 'partial_path': doc.partial_path,
             'link_name': doc.link_name, 'short_name': doc.short_name,
             'abstract': doc.abstract, 'content': doc.content,
-            'user': doc.user})       
+            'user': doc.user, 'is_featured': doc.is_featured})       
       else:
         if request.GET.get(profile.SUBMIT_MSG_PARAM_NAME):
           # redirect to aggressively remove 'Profile saved' query parameter
@@ -324,4 +325,4 @@
   if existing_doc:
     document.logic.delete(existing_doc)
 
-  return http.HttpResponseRedirect('/site/docs/list')
\ No newline at end of file
+  return http.HttpResponseRedirect('/site/docs/list')