Eliminate the Work.abstract property and move the Document.content property
authorTodd Larsen <tlarsen@google.com>
Thu, 16 Oct 2008 04:37:13 +0000
changeset 351 b37fc4c1e189
parent 350 e8f14fde7f0e
child 352 c66de4d12c82
Eliminate the Work.abstract property and move the Document.content property to Work.content instead. Update affected views, and re-base some classes that were deriving from Document just to get Document.content to now be derived from Work instead. The Document class now has a "pass" body with no additional properties. It is debatable whether Work should become Document, since I am not sure that we plan to be able to generically display, say, a Quiz or a Question (which are Works) on the home page (which can only specifically display a Document, or now, the basic Work entity...). Patch by: Todd Larsen Review by: to-be-reviewed
app/soc/models/document.py
app/soc/models/documentation.py
app/soc/models/proposal.py
app/soc/models/question.py
app/soc/models/quiz.py
app/soc/models/work.py
app/soc/templates/soc/docs/public.html
app/soc/views/site/docs/edit.py
app/soc/views/site/settings.py
--- a/app/soc/models/document.py	Thu Oct 16 04:30:26 2008 +0000
+++ b/app/soc/models/document.py	Thu Oct 16 04:37:13 2008 +0000
@@ -38,14 +38,8 @@
 
     work.title:  the title of the Document
 
-    work.abstract:  document summary displayed as a snippet in Document
-      list views
-
     work.reviews:  reviews of the Document by Reviewers
-  """
 
-  #: Required db.TextProperty containing the Document contents.
-  #: Unlike the work.abstract, which is considered "public" information,
-  #: the content is only to be displayed to Persons in Roles eligible to
-  #: view them (which may be anyone, for example, with the site front page).
-  content = db.TextProperty(verbose_name=ugettext_lazy('Content'))
+    work.content:  the rich-text contents of the Document
+  """
+  pass
\ No newline at end of file
--- a/app/soc/models/documentation.py	Thu Oct 16 04:30:26 2008 +0000
+++ b/app/soc/models/documentation.py	Thu Oct 16 04:37:13 2008 +0000
@@ -38,19 +38,19 @@
   The specific way that some properties and relations inherited from Work
   are used with a piece of Documentation are described below.
 
-  work.title: The title of the Documentation (e.g. "Verification
-    of Eligibility").
+    work.title: The title of the Documentation (e.g. "Verification
+      of Eligibility").
 
-  work.abstract: Summary of the contents of the 'attachment', or
-    just an indication that the required documentation was 
-    supplied but is not actually attached.
+    work.author: The author of the Work referred to by this 
+      relation is the Administrator (or Host) creating the
+      Documentation.
 
-  work.author: The author of the Work referred to by this 
-    relation is the Administrator (or Host) creating the
-    Documentation.
+    work.reviews: Annotations to the Documentation made by other
+      Administrators.
 
-  work.reviews: Annotations to the Documentation made by other
-    Administrators.
+    work.content: Summary of the contents of the 'attachment', or
+      just an indication that the required documentation was 
+      supplied but is not actually attached.
   """
 
   #: a many:1 relationship of Documentation entities that pertain
--- a/app/soc/models/proposal.py	Thu Oct 16 04:30:26 2008 +0000
+++ b/app/soc/models/proposal.py	Thu Oct 16 04:37:13 2008 +0000
@@ -24,26 +24,24 @@
 
 from google.appengine.ext import db
 
-import soc.models.document
+import soc.models.work
 import soc.models.quiz
 import soc.models.response
 
 
-class Proposal(soc.models.document.Document):
+class Proposal(soc.models.work.Work):
   """Model of a Proposal, which is a specific form of a Work.
 
   The specific way that the properties and relations inherited from Work
   are used with a Proposal are described below.
 
-  work.title:  the title of the Proposal
+    work.title:  the title of the Proposal
 
-  work.abstract:  publicly displayed as a proposal abstract or summary
+    work.reviews:  reviews of the Proposal by Reviewers
 
-  work.reviews:  reviews of the Proposal by Reviewers
-
-  document.content:  the details of the Proposal; which, unlike work.abstract
-    is considered "public" information, the contents of a Proposal are only
-    displayed to Persons in Roles that have a "need to know" those details.
+    work.content:  the details of the Proposal; which, unlike work.abstract
+      is considered "public" information, the contents of a Proposal are only
+      displayed to Persons in Roles that have a "need to know" those details.
 
   A Proposal entity participates in the following relationships implemented 
   as a db.ReferenceProperty elsewhere in another db.Model:
@@ -52,6 +50,13 @@
     Proposal as their foundation.  This relation is implemented as the
     'tasks' back-reference Query of the Task model 'proposal' reference.
   """
+  #: optional, indexed plain text field used for different purposes,
+  #: depending on the specific type of the work
+  abstract = db.StringProperty(multiline=True)
+  abstract.help_text = ugettext_lazy(
+      'short abstract, summary, or snippet;'
+      ' 500 characters or less, plain text displayed publicly')
+
   #: an optional many:1 relationship between Proposal and a Quiz that
   #: defines what Questions were added by the prospective Proposal Reviewer
   #: for the Proposal author to answer.
--- a/app/soc/models/question.py	Thu Oct 16 04:30:26 2008 +0000
+++ b/app/soc/models/question.py	Thu Oct 16 04:37:13 2008 +0000
@@ -37,8 +37,6 @@
     work.title:  the title of the Question, used for finding the
       Question in a list of Questions
 
-    work.abstract:  the Question text, asked to the respondent
-
     work.author:  the author of the Work referred to by this relation
       is the original author of the actual Question, regardless of
       which Quizzes might incorporate the Question
@@ -54,6 +52,8 @@
       work.partial_path, *uniquely* identify) a Question in the same way
       these properties are used with Documents, etc.
       
+    work.content:  the Question text, asked to the respondent
+
   In addition to any explicit ReferenceProperties in the Question Model
   and those inherited as described above, a Question entity participates
   in these relationships:
--- a/app/soc/models/quiz.py	Thu Oct 16 04:30:26 2008 +0000
+++ b/app/soc/models/quiz.py	Thu Oct 16 04:37:13 2008 +0000
@@ -27,11 +27,11 @@
 from django.utils.translation import ugettext_lazy
 
 import soc.models.answer
-import soc.models.document
 import soc.models.question
+import soc.models.work
 
 
-class Quiz(soc.models.document.Document):
+class Quiz(soc.models.work.Work):
   """Model of a Quiz, a collection of Questions to be asked.
   
   (named Quiz because Questionnaire was too much to type...)
@@ -49,8 +49,6 @@
 
     work.title:  the title of the Quiz
 
-    work.abstract:  summary displayed as a snippet in Quiz list views
-
     work.author:  the author of the Work referred to by this relation
       is the author of the Quiz (but not necessarily the individual
       Questions themselves, see the Question Model)
@@ -61,7 +59,7 @@
     work.partial_path/work.link_name: used to scope and uniquely identify
       a Quiz in the same way these properties are used with Documents, etc.
 
-    document.content:  the "preface" of the Quiz, displayed before any
+    work.content:  the "preface" of the Quiz, displayed before any
       of the Questions, usually containing instructions for the Quiz
 
   In addition to any explicit ReferenceProperties in the Quiz Model and
--- a/app/soc/models/work.py	Thu Oct 16 04:30:26 2008 +0000
+++ b/app/soc/models/work.py	Thu Oct 16 04:37:13 2008 +0000
@@ -56,13 +56,6 @@
   title.help_text = ugettext_lazy(
       'title of the document; often used in the window title')
 
-  #: optional, indexed plain text field used for different purposes,
-  #: depending on the specific type of the work
-  abstract = db.StringProperty(multiline=True)
-  abstract.help_text = ugettext_lazy(
-      'short abstract, summary, or snippet;'
-      ' 500 characters or less, plain text displayed publicly')
-
   #: Required path, prepended to a "link name" to form the document URL.
   #: The combined path and link name must be globally unique on the
   #: site.  Except in /site/docs (Developer) forms, this field is not
@@ -86,6 +79,11 @@
   short_name = db.StringProperty(verbose_name=ugettext_lazy('Short name'))
   short_name.help_text = ugettext_lazy(
       'short name used, for example, in the sidebar menu')
+
+  #: Required db.TextProperty containing the contents of the Work.
+  #: The content is only to be displayed to Persons in Roles eligible to
+  #: view them (which may be anyone, for example, with the site front page).
+  content = db.TextProperty(verbose_name=ugettext_lazy('Content'))
   
   #: date when the work was created
   created = db.DateTimeProperty(auto_now_add=True)
--- a/app/soc/templates/soc/docs/public.html	Thu Oct 16 04:30:26 2008 +0000
+++ b/app/soc/templates/soc/docs/public.html	Thu Oct 16 04:37:13 2008 +0000
@@ -23,12 +23,7 @@
 
 {% block body %}
 <div id="createdon">Created on: {{ document.created }}</div>
-{% if document.abstract %}
-<div id="docsummary">
-<h2>Summary</h2>
-{{ document.abstract }}
-</div>
-{% endif %}
+<div id="createdby">Created on: {{ document.author.nick_name }}</div>
 {{ document.content|safe }}
 <div id="lastmodified">Last updated on: {{ document.modified }}</div>
 {% endblock %}
--- a/app/soc/views/site/docs/edit.py	Thu Oct 16 04:30:26 2008 +0000
+++ b/app/soc/views/site/docs/edit.py	Thu Oct 16 04:37:13 2008 +0000
@@ -73,7 +73,6 @@
   properties['link_name'] = link_name
   properties['title'] = form.cleaned_data.get('title')
   properties['short_name'] = form.cleaned_data.get('short_name')
-  properties['abstract'] = form.cleaned_data.get('abstract')
   properties['content'] = form.cleaned_data.get('content')
   properties['author'] = models.user.logic.getFromFields(email=email)
   properties['is_featured'] = form.cleaned_data.get('is_featured')
@@ -244,9 +243,8 @@
         form = EditForm(initial={'doc_key_name': doc.key().name(),
             'title': doc.title, 'partial_path': doc.partial_path,
             'link_name': doc.link_name, 'short_name': doc.short_name,
-            'abstract': doc.abstract, 'content': doc.content,
-            'author': doc.author, 'is_featured': doc.is_featured,
-            'created_by': author_link_name})       
+            'content': doc.content, 'author': doc.author,
+            'is_featured': doc.is_featured, 'created_by': author_link_name})       
       else:
         if request.GET.get(profile.SUBMIT_MSG_PARAM_NAME):
           # redirect to aggressively remove 'Profile saved' query parameter
--- a/app/soc/views/site/settings.py	Thu Oct 16 04:30:26 2008 +0000
+++ b/app/soc/views/site/settings.py	Thu Oct 16 04:37:13 2008 +0000
@@ -130,7 +130,6 @@
       properties = {
         'title': document_form.cleaned_data.get('title'),
         'short_name': document_form.cleaned_data.get('short_name'),
-        'abstract': document_form.cleaned_data.get('abstract'),
         'content': document_form.cleaned_data.get('content'),
         'link_name': link_name,
         'partial_path': partial_path,