Moved from docs -> document
authorSverre Rabbelier <srabbelier@gmail.com>
Thu, 13 Nov 2008 16:40:05 +0000
changeset 477 8a8b1bd035c4
parent 476 3b0662786f95
child 478 613951c35706
Moved from docs -> document
app/soc/logic/site/map.py
app/soc/logic/site/sidebar.py
app/soc/models/work.py
app/soc/templates/soc/docs/list/docs_heading.html
app/soc/templates/soc/docs/list/docs_row.html
app/soc/templates/soc/docs/public.html
app/soc/templates/soc/document/list/docs_heading.html
app/soc/templates/soc/document/list/docs_row.html
app/soc/templates/soc/document/public.html
app/soc/templates/soc/home_settings/public.html
app/soc/templates/soc/site_settings/edit.html
app/soc/views/docs/__init__.py
app/soc/views/docs/edit.py
app/soc/views/docs/list.py
app/soc/views/docs/show.py
app/soc/views/document/__init__.py
app/soc/views/document/edit.py
app/soc/views/document/list.py
app/soc/views/document/show.py
app/soc/views/models/docs.py
app/soc/views/models/document.py
app/soc/views/models/home_settings.py
app/soc/views/models/site_settings.py
--- a/app/soc/logic/site/map.py	Wed Nov 12 21:43:15 2008 +0000
+++ b/app/soc/logic/site/map.py	Thu Nov 13 16:40:05 2008 +0000
@@ -252,51 +252,51 @@
 
 
 # Document views
-docs_show = page.Page(
+document_show = page.Page(
   page.Url(
-    r'^docs/show/%s$' % path_link_name.PATH_LINKNAME_ARGS_PATTERN,
-    'soc.views.models.docs.public'),
+    r'^document/show/%s$' % path_link_name.PATH_LINKNAME_ARGS_PATTERN,
+    'soc.views.models.document.public'),
   'Show Document',
   parent=home)
 
 # Site Document views
-site_docs_sub_menu = page.NonPage(
-  'site-docs-sub-menu',
+site_document_sub_menu = page.NonPage(
+  'site-document-sub-menu',
   'Site: Documents Sub-Menu',
   short_name='Site Documents',
   parent=site_sub_menu)
 
-site_docs_create = page.Page(
+site_document_create = page.Page(
   page.Url(
-    r'^docs/edit$',
-    'soc.views.models.docs.create'),
+    r'^document/edit$',
+    'soc.views.models.document.create'),
   'Site: Create New Document',
   'Create Site Document',
-  parent=site_docs_sub_menu)
+  parent=site_document_sub_menu)
 
-site_docs_edit = page.Page(
+site_document_edit = page.Page(
   page.Url(
-    r'^docs/edit/%s$' % path_link_name.PATH_LINKNAME_ARGS_PATTERN,
-    'soc.views.models.docs.edit'),
+    r'^document/edit/%s$' % path_link_name.PATH_LINKNAME_ARGS_PATTERN,
+    'soc.views.models.document.edit'),
   'Site: Modify Existing Document',
   short_name='Modify Site Document',
-  parent=site_docs_sub_menu)
+  parent=site_document_sub_menu)
 
-site_docs_delete = page.Page(
+site_document_delete = page.Page(
   page.Url(
-    r'^docs/delete/%s$' % path_link_name.PATH_LINKNAME_ARGS_PATTERN,
-    'soc.views.models.docs.delete'),
+    r'^document/delete/%s$' % path_link_name.PATH_LINKNAME_ARGS_PATTERN,
+    'soc.views.models.document.delete'),
   'Site: Delete Existing Document',
   short_name='Delete Site Document',
-  parent=site_docs_sub_menu)
+  parent=site_document_sub_menu)
 
-site_docs_list = page.Page(
+site_document_list = page.Page(
   page.Url(
-    r'^docs/list$',
-    'soc.views.models.docs.list'),
+    r'^document/list$',
+    'soc.views.models.document.list'),
   'Site: List of Documents',
   short_name='List Site Documents',
-  parent=site_docs_sub_menu)
+  parent=site_document_sub_menu)
 
 # Sponsor Group public view
 sponsor_profile = page.Page(
--- a/app/soc/logic/site/sidebar.py	Wed Nov 12 21:43:15 2008 +0000
+++ b/app/soc/logic/site/sidebar.py	Thu Nov 13 16:40:05 2008 +0000
@@ -87,10 +87,10 @@
           value='/program/gsoc2009/community'),
         menu.MenuItem(
           'FAQs',
-          value='/program/gsoc2009/docs/faqs'),
+          value='/program/gsoc2009/document/faqs'),
         menu.MenuItem(
           'Terms of Service',
-          value='/program/gsoc2009/docs/tos'),
+          value='/program/gsoc2009/document/tos'),
         ]
       )
     ),
@@ -103,10 +103,10 @@
           value='/program/ghop2008/community'),
         menu.MenuItem(
           'FAQs',
-          value='/program/ghop2008/docs/faqs'),
+          value='/program/ghop2008/document/faqs'),
         menu.MenuItem(
           'Contest Rules',
-          value='/program/ghop2008/docs/rules'),
+          value='/program/ghop2008/document/rules'),
         ]
       )
     ),
--- a/app/soc/models/work.py	Wed Nov 12 21:43:15 2008 +0000
+++ b/app/soc/models/work.py	Thu Nov 13 16:40:05 2008 +0000
@@ -59,7 +59,7 @@
 
   #: 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
+  #: site.  Except in /site/document (Developer) forms, this field is not
   #: usually directly editable by the User, but is instead set by controller
   #: logic to match the "scope" of the document.
   partial_path = db.StringProperty(required=True,
--- a/app/soc/templates/soc/docs/list/docs_heading.html	Wed Nov 12 21:43:15 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-<tr align="left">
-  <th>Path</th>
-  <th>Title</th>
-  <th>Linkname</th>
-  <th>Featured</th>
-  <th>Created By</th>
-  <th>Created On</th>
-  <th>Modified</th>
-</tr>
--- a/app/soc/templates/soc/docs/list/docs_row.html	Wed Nov 12 21:43:15 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-<tr class="off" onmouseover="this.className='on'" onmouseout="this.className='off'" 
-onclick="document.location.href='/docs/edit/{{ data_element.partial_path }}/{{ data_element.link_name }}'" name="name">
-  <td align="right">
-   <div class="title">
-    <a class="noul"
-     href="/docs/edit/{{ data_element.partial_path }}/{{ data_element.link_name }}">{{ data_element.partial_path}}/{{ data_element.link_name }}</a>
-   </div>
-  </td>
-  <td><div class="title">{{ data_element.title }}</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="author">{{ data_element.author.link_name }}</div></td>
-  <td><div class="created">{{ data_element.created }}</div></td>
-  <td><div class="modified">{{ data_element.modified }}</div></td>
-</tr>
--- a/app/soc/templates/soc/docs/public.html	Wed Nov 12 21:43:15 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-{% extends "soc/base.html" %}
-{% comment %}
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-{% endcomment %}
-
-{% block page_title %}
-{{ entity.title }}
-{% endblock %}
-
-{% block header_title %}
-{{ entity.title }}
-{% endblock %}
-
-{% block body %}
-<div id="created">Created on {{ entity.created }} by {{ entity.author.nick_name }}</div>
-<div id="content">{{ entity.content|safe }}</div>
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/document/list/docs_heading.html	Thu Nov 13 16:40:05 2008 +0000
@@ -0,0 +1,9 @@
+<tr align="left">
+  <th>Path</th>
+  <th>Title</th>
+  <th>Linkname</th>
+  <th>Featured</th>
+  <th>Created By</th>
+  <th>Created On</th>
+  <th>Modified</th>
+</tr>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/document/list/docs_row.html	Thu Nov 13 16:40:05 2008 +0000
@@ -0,0 +1,15 @@
+<tr class="off" onmouseover="this.className='on'" onmouseout="this.className='off'" 
+onclick="document.location.href='/document/edit/{{ data_element.partial_path }}/{{ data_element.link_name }}'" name="name">
+  <td align="right">
+   <div class="title">
+    <a class="noul"
+     href="/document/edit/{{ data_element.partial_path }}/{{ data_element.link_name }}">{{ data_element.partial_path}}/{{ data_element.link_name }}</a>
+   </div>
+  </td>
+  <td><div class="title">{{ data_element.title }}</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="author">{{ data_element.author.link_name }}</div></td>
+  <td><div class="created">{{ data_element.created }}</div></td>
+  <td><div class="modified">{{ data_element.modified }}</div></td>
+</tr>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/document/public.html	Thu Nov 13 16:40:05 2008 +0000
@@ -0,0 +1,27 @@
+{% extends "soc/base.html" %}
+{% comment %}
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+{% endcomment %}
+
+{% block page_title %}
+{{ entity.title }}
+{% endblock %}
+
+{% block header_title %}
+{{ entity.title }}
+{% endblock %}
+
+{% block body %}
+<div id="created">Created on {{ entity.created }} by {{ entity.author.nick_name }}</div>
+<div id="content">{{ entity.content|safe }}</div>
+{% endblock %}
--- a/app/soc/templates/soc/home_settings/public.html	Wed Nov 12 21:43:15 2008 +0000
+++ b/app/soc/templates/soc/home_settings/public.html	Thu Nov 13 16:40:05 2008 +0000
@@ -15,8 +15,8 @@
 
 {% block missing_doc %}
 The contents of this default Site home page can be changed by
-<a href="/docs/edit">creating a new Document</a> or
-<a href="/docs/list">editing an existing Document</a> and then selecting
+<a href="/document/edit">creating a new Document</a> or
+<a href="/document/list">editing an existing Document</a> and then selecting
 that Document in the
 <a href="/settings/edit">Site Settings</a> interface.
 Other elements of this page, such as a feed to be displayed below this
--- a/app/soc/templates/soc/site_settings/edit.html	Wed Nov 12 21:43:15 2008 +0000
+++ b/app/soc/templates/soc/site_settings/edit.html	Thu Nov 13 16:40:05 2008 +0000
@@ -77,10 +77,10 @@
  Any existing Document (to which access is permitted) can be used as the body contents of the home page.
  <ul>
   <li>
-<a href="/docs/edit">Create a new Document to use for the home page content here.</a>
+<a href="/document/edit">Create a new Document to use for the home page content here.</a>
   </li>
   <li>
-<a href="/docs/list">Edit an existing Document to use for the home page content here.</a>
+<a href="/document/list">Edit an existing Document to use for the home page content here.</a>
   </li>
  </ul>
 Then, specify the Document to use below:
--- a/app/soc/views/docs/edit.py	Wed Nov 12 21:43:15 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,327 +0,0 @@
-#!/usr/bin/python2.5
-#
-# Copyright 2008 the Melange authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Views for editing and examining Documents.
-"""
-
-__authors__ = [
-  '"Todd Larsen" <tlarsen@google.com>',
-  ]
-
-
-from google.appengine.api import users
-
-from django import forms
-from django import http
-from django.utils.translation import ugettext_lazy
-
-from soc.logic import models
-from soc.logic import out_of_band
-from soc.logic import path_link_name
-from soc.logic.models import document
-
-from soc.views import helper
-from soc.views import simple
-from soc.views.helper import access
-from soc.views.helper import decorators
-from soc.views.user import profile
-
-import soc.models.document
-import soc.views.helper.forms
-import soc.views.helper.requests
-import soc.views.helper.responses
-import soc.views.helper.widgets
-import soc.views.out_of_band
-
-
-DEF_CREATE_NEW_DOC_MSG = ' You can create a new document by visiting the' \
-                         ' <a href="/docs/edit">Create ' \
-                         'a New Document</a> page.'
-
-SUBMIT_MESSAGES = (
- ugettext_lazy('Document saved.'),
-)
-
-
-def getDocForForm(form):
-  """Extracts doc fields from a form and creates a new doc from it
-  """
-
-  user = users.get_current_user()
-
-  partial_path = form.cleaned_data.get('partial_path')
-  link_name = form.cleaned_data.get('link_name')
-
-  properties = {}
-  properties['partial_path'] = partial_path
-  properties['link_name'] = link_name
-  properties['title'] = form.cleaned_data.get('title')
-  properties['short_name'] = form.cleaned_data.get('short_name')
-  properties['content'] = form.cleaned_data.get('content')
-  properties['author'] = models.user.logic.getForFields({'id': user}, unique=True)
-  properties['is_featured'] = form.cleaned_data.get('is_featured')
-
-  key_fields = document.logic.getKeyFieldsFromDict(properties)
-
-  doc = document.logic.updateOrCreateFromFields(properties, key_fields)
-  return doc
-
-
-class CreateForm(helper.forms.BaseForm):
-  """Django form displayed when Developer creates a Document.
-  """
-  content = forms.fields.CharField(widget=helper.widgets.TinyMCE(
-      attrs={'rows':10, 'cols':40}))
-
-  class Meta:
-    model = soc.models.document.Document
-
-    #: list of model fields which will *not* be gathered by the form
-    exclude = ['inheritance_line', 'author', 'created', 'modified']
-
-  def clean_partial_path(self):
-    partial_path = self.cleaned_data.get('partial_path')
-    # TODO(tlarsen): combine path and link_name and check for uniqueness
-    return partial_path
-
-  def clean_link_name(self):
-    link_name = self.cleaned_data.get('link_name')
-    # TODO(tlarsen): combine path and link_name and check for uniqueness
-    return link_name
-
-
-DEF_DOCS_CREATE_TMPL = 'soc/models/edit.html'
-
-@decorators.view
-def create(request, page=None, template=DEF_DOCS_CREATE_TMPL):
-  """View to create a new Document entity.
-
-  Args:
-    request: the standard django request object
-    page: a soc.logic.site.page.Page object which is abstraction that combines 
-      a Django view with sidebar menu info
-    template: the "sibling" template (or a search list of such templates)
-      from which to construct the public.html template name (or names)
-
-  Returns:
-    A subclass of django.http.HttpResponse which either contains the form to
-    be filled out, or a redirect to the correct view in the interface.
-  """
-
-  try:
-    access.checkIsDeveloper(request)
-  except  soc.views.out_of_band.AccessViolationResponse, alt_response:
-    # TODO(tlarsen): change this to just limit the Documents that can be
-    #   created by the User in their current Role
-    return alt_response.response()
-
-  # create default template context for use with any templates
-  context = helper.responses.getUniversalContext(request)
-  context['page'] = page
-
-  if request.method == 'POST':
-    form = CreateForm(request.POST)
-
-    if form.is_valid():
-      doc = getDocForForm(form)
-
-      if not doc:
-        return http.HttpResponseRedirect('/')
-
-      new_path = path_link_name.combinePath([doc.partial_path, doc.link_name])
-
-      # redirect to new /docs/edit/new_path?s=0
-      # (causes 'Profile saved' message to be displayed)
-      return helper.responses.redirectToChangedSuffix(
-          request, None, new_path,
-          params=profile.SUBMIT_PROFILE_SAVED_PARAMS)
-  else: # method == 'GET':
-    # no link name specified, so start with an empty form
-    form = CreateForm()
-
-  context['form'] = form
-
-  return helper.responses.respond(request, template, context)
-
-
-DEF_DOCS_EDIT_TMPL = 'soc/models/edit.html'
-
-class EditForm(CreateForm):
-  """Django form displayed a Document is edited.
-  """
-  doc_key_name = forms.fields.CharField(widget=forms.HiddenInput)
-  created_by = forms.fields.CharField(widget=helper.widgets.ReadOnlyInput(),
-                                      required=False)
-
-
-@decorators.view
-def edit(request, page=None, partial_path=None, link_name=None,
-         template=DEF_DOCS_EDIT_TMPL):
-  """View to modify the properties of a Document Model entity.
-
-  Args:
-    request: the standard django request object
-    page: a soc.logic.site.page.Page object which is abstraction that combines 
-      a Django view with sidebar menu info
-    partial_path: the Document's site-unique "path" extracted from the URL,
-      minus the trailing link_name
-    link_name: the last portion of the Document's site-unique "path"
-      extracted from the URL
-    template: the "sibling" template (or a search list of such templates)
-      from which to construct the public.html template name (or names)
-
-  Returns:
-    A subclass of django.http.HttpResponse which either contains the form to
-    be filled out, or a redirect to the correct view in the interface.
-  """
-
-  try:
-    access.checkIsDeveloper(request)
-  except  soc.views.out_of_band.AccessViolationResponse, alt_response:
-    # TODO(tlarsen): change this to just limit the Documents that can be
-    #   edited by the User in their current Role
-    return alt_response.response()
-
-  # create default template context for use with any templates
-  context = helper.responses.getUniversalContext(request)
-  context['page'] = page
-
-  doc = None  # assume that no Document entity will be found
-
-  path = path_link_name.combinePath([partial_path, link_name])
-
-  # try to fetch Document entity corresponding to path if one exists    
-  try:
-    if path:
-      doc = document.logic.getFromFields(partial_path=partial_path,
-                                         link_name=link_name)
-  except out_of_band.ErrorResponse, error:
-    # show custom 404 page when path doesn't exist in Datastore
-    error.message = error.message + DEF_CREATE_NEW_DOC_MSG
-    return simple.errorResponse(request, page, error, template, context)
-
-  if request.method == 'POST':
-    form = EditForm(request.POST)
-
-    if form.is_valid():
-      doc = getDocForForm(form)
-      
-      if not doc:
-        return http.HttpResponseRedirect('/')
-
-      new_path = path_link_name.combinePath([doc.partial_path, doc.link_name])
-        
-      # redirect to new /docs/edit/new_path?s=0
-      # (causes 'Profile saved' message to be displayed)
-      return helper.responses.redirectToChangedSuffix(
-          request, path, new_path,
-          params=profile.SUBMIT_PROFILE_SAVED_PARAMS)
-  else: # method == 'GET':
-    # try to fetch Document entity corresponding to path if one exists
-    if path:
-      if doc:
-        # is 'Profile saved' parameter present, but referrer was not ourself?
-        # (e.g. someone bookmarked the GET that followed the POST submit) 
-        if (request.GET.get(profile.SUBMIT_MSG_PARAM_NAME)
-            and (not helper.requests.isReferrerSelf(request, suffix=path))):
-          # redirect to aggressively remove 'Profile saved' query parameter
-          return http.HttpResponseRedirect(request.path)
-    
-        # referrer was us, so select which submit message to display
-        # (may display no message if ?s=0 parameter is not present)
-        context['notice'] = (
-            helper.requests.getSingleIndexedParamValue(
-                request, profile.SUBMIT_MSG_PARAM_NAME,
-                values=SUBMIT_MESSAGES))
-
-        # populate form with the existing Document entity
-        author_link_name = doc.author.link_name
-        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,
-            '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
-          return http.HttpResponseRedirect(request.path)
-          
-        context['lookup_error'] = ugettext_lazy(
-            'Document with that path not found.')
-        form = EditForm(initial={'link_name': link_name})
-    else:  # no link name specified in the URL
-      if request.GET.get(profile.SUBMIT_MSG_PARAM_NAME):
-        # redirect to aggressively remove 'Profile saved' query parameter
-        return http.HttpResponseRedirect(request.path)
-
-      # no link name specified, so start with an empty form
-      form = EditForm()
-
-  context.update({'form': form,
-                  'entity': doc})
-
-  return helper.responses.respond(request, template, context)
-
-
-@decorators.view
-def delete(request, page=None, partial_path=None, link_name=None,
-           template=DEF_DOCS_EDIT_TMPL):
-  """Request handler to delete Document Model entity.
-
-  Args:
-    request: the standard django request object
-    page: a soc.logic.site.page.Page object which is abstraction that combines 
-      a Django view with sidebar menu info
-    partial_path: the Document's site-unique "path" extracted from the URL,
-      minus the trailing link_name
-    link_name: the last portion of the Document's site-unique "path"
-      extracted from the URL
-    template: the "sibling" template (or a search list of such templates)
-      from which to construct the public.html template name (or names)
-
-  Returns:
-    A subclass of django.http.HttpResponse which redirects 
-    to /site/docs/list.
-  """
-
-  try:
-    access.checkIsDeveloper(request)
-  except  soc.views.out_of_band.AccessViolationResponse, alt_response:
-    # TODO(tlarsen): change this to just limit the Documents that can be
-    #   deleted by the User in their current Role
-    return alt_response.response()
-
-  # create default template context for use with any templates
-  context = helper.responses.getUniversalContext(request)
-  context['page'] = page
-
-  existing_doc = None
-  path = path_link_name.combinePath([partial_path, link_name])
-
-  # try to fetch Document entity corresponding to path if one exists    
-  try:
-    if path:
-      existing_doc = document.logic.getFromFields(partial_path=partial_path,
-                                                  link_name=link_name)
-  except out_of_band.ErrorResponse, error:
-    # show custom 404 page when path doesn't exist in Datastore
-    error.message = error.message + DEF_CREATE_NEW_DOC_MSG
-    return simple.errorResponse(request, page, error, template, context)
-
-  if existing_doc:
-    document.logic.delete(existing_doc)
-
-  return http.HttpResponseRedirect('/docs/list')
--- a/app/soc/views/docs/list.py	Wed Nov 12 21:43:15 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-#!/usr/bin/python2.5
-#
-# Copyright 2008 the Melange authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Views for listing Documents.
-"""
-
-__authors__ = [
-  '"Todd Larsen" <tlarsen@google.com>',
-  ]
-
-
-from soc.logic.models import work
-from soc.views import helper
-from soc.views.helper import access
-from soc.views.helper import decorators
-
-import soc.logic
-import soc.models.document
-import soc.views.helper.lists
-import soc.views.helper.responses
-import soc.views.out_of_band
-
-
-DEF_DOCS_LIST_ALL_TMPL = 'soc/models/list.html'
-
-
-@decorators.view
-def all(request, page=None, templates={}):
-  """Show a list of all Documents (limit rows per page).
-  
-  Args:
-    request: the standard Django HTTP request object
-    page: a soc.logic.site.page.Page object which is abstraction that combines 
-      a Django view with sidebar menu info
-    template: the "sibling" template (or a search list of such templates)
-      from which to construct an alternate template name (or names)
-
-  Returns:
-    A subclass of django.http.HttpResponse which either contains the form to
-    be filled out, or a redirect to the correct view in the interface.
-  """
-
-  try:
-    access.checkIsDeveloper(request)
-  except  soc.views.out_of_band.AccessViolationResponse, alt_response:
-    return alt_response.response()
-
-  # create default template context for use with any templates
-  context = helper.responses.getUniversalContext(request)
-  context['page'] = page
-
-  offset, limit = helper.lists.cleanListParameters(
-      offset=request.GET.get('offset'), limit=request.GET.get('limit'))
-
-  # Fetch one more to see if there should be a 'next' link
-  docs = work.logic.getForLimitAndOffset(limit + 1, offset=offset)
-
-  context['pagination_form'] = helper.lists.makePaginationForm(request, limit)
-
-  list_templates = {
-    'list_main': templates.get('list_main',
-                               'soc/list/list_main.html'),
-    'list_pagination': templates.get('list_pagination',
-                                     'soc/list/list_pagination.html'),
-    'list_row': templates.get('list_row',
-                              'soc/docs/list/docs_row.html'),
-    'list_heading': templates.get('list_heading',
-                                  'soc/docs/list/docs_heading.html'),
-    }
-                      
-  context = helper.lists.setList(
-      request, context, docs, 
-      offset=offset, limit=limit, list_templates=list_templates)
-
-  template = templates.get('all', DEF_DOCS_LIST_ALL_TMPL)
-  return helper.responses.respond(request, template, context)
--- a/app/soc/views/docs/show.py	Wed Nov 12 21:43:15 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-#!/usr/bin/python2.5
-#
-# Copyright 2008 the Melange authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Document viewers.
-
-public: how the general public sees a Document
-"""
-
-__authors__ = [
-  '"Todd Larsen" <tlarsen@google.com>',
-  ]
-
-
-from soc.logic import out_of_band
-from soc.logic import path_link_name
-from soc.logic.models import document
-from soc.views import helper
-from soc.views import simple
-from soc.views.helper import decorators
-
-import soc.views.helper.responses
-import soc.views.helper.templates
-
-
-DEF_DOCS_PUBLIC_TMPL = 'soc/docs/public.html'
-
-@decorators.view
-def public(request, page=None, partial_path=None, link_name=None,
-           template=DEF_DOCS_PUBLIC_TMPL):
-  """How the "general public" sees a Document.
-
-  Args:
-    request: the standard django request object
-    page: a soc.logic.site.page.Page object which is abstraction that combines 
-      a Django view with sidebar menu info
-    partial_path: the Document's site-unique "path" extracted from the URL,
-      minus the trailing link_name
-    link_name: the last portion of the Document's site-unique "path"
-      extracted from the URL
-    template: the "sibling" template (or a search list of such templates)
-      from which to construct the public.html template name (or names)
-
-  Returns:
-    A subclass of django.http.HttpResponse which either contains the form to
-    be filled out, or a redirect to the correct view in the interface.
-  """
-  # create default template context for use with any templates
-  context = helper.responses.getUniversalContext(request)
-
-  # TODO: there eventually needs to be a call to some controller logic that
-  #   implements some sort of access controls, based on the currently
-  #   logged-in User's Roles, etc.
-
-  # TODO: based on the User's Roles, Documents that the User can edit
-  #   should display a link to a document edit form
-  
-  doc = None
-
-  # try to fetch User entity corresponding to link_name if one exists
-  path = path_link_name.combinePath([partial_path, link_name])
-
-  # try to fetch Document entity corresponding to path if one exists    
-  try:
-    if path:
-      doc = document.logic.getFromFields(partial_path=partial_path,
-                                         link_name=link_name)
-  except out_of_band.ErrorResponse, error:
-    # show custom 404 page when Document path doesn't exist in Datastore
-    return simple.errorResponse(request, page, error, template, context)
-
-  doc.content = helper.templates.unescape(doc.content)
-  context['entity'] = doc
-
-  return helper.responses.respond(request, template, context)
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/views/document/edit.py	Thu Nov 13 16:40:05 2008 +0000
@@ -0,0 +1,327 @@
+#!/usr/bin/python2.5
+#
+# Copyright 2008 the Melange authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Views for editing and examining Documents.
+"""
+
+__authors__ = [
+  '"Todd Larsen" <tlarsen@google.com>',
+  ]
+
+
+from google.appengine.api import users
+
+from django import forms
+from django import http
+from django.utils.translation import ugettext_lazy
+
+from soc.logic import models
+from soc.logic import out_of_band
+from soc.logic import path_link_name
+from soc.logic.models import document
+
+from soc.views import helper
+from soc.views import simple
+from soc.views.helper import access
+from soc.views.helper import decorators
+from soc.views.user import profile
+
+import soc.models.document
+import soc.views.helper.forms
+import soc.views.helper.requests
+import soc.views.helper.responses
+import soc.views.helper.widgets
+import soc.views.out_of_band
+
+
+DEF_CREATE_NEW_DOC_MSG = ' You can create a new document by visiting the' \
+                         ' <a href="/document/edit">Create ' \
+                         'a New Document</a> page.'
+
+SUBMIT_MESSAGES = (
+ ugettext_lazy('Document saved.'),
+)
+
+
+def getDocForForm(form):
+  """Extracts doc fields from a form and creates a new doc from it
+  """
+
+  user = users.get_current_user()
+
+  partial_path = form.cleaned_data.get('partial_path')
+  link_name = form.cleaned_data.get('link_name')
+
+  properties = {}
+  properties['partial_path'] = partial_path
+  properties['link_name'] = link_name
+  properties['title'] = form.cleaned_data.get('title')
+  properties['short_name'] = form.cleaned_data.get('short_name')
+  properties['content'] = form.cleaned_data.get('content')
+  properties['author'] = models.user.logic.getForFields({'id': user}, unique=True)
+  properties['is_featured'] = form.cleaned_data.get('is_featured')
+
+  key_fields = document.logic.getKeyFieldsFromDict(properties)
+
+  doc = document.logic.updateOrCreateFromFields(properties, key_fields)
+  return doc
+
+
+class CreateForm(helper.forms.BaseForm):
+  """Django form displayed when Developer creates a Document.
+  """
+  content = forms.fields.CharField(widget=helper.widgets.TinyMCE(
+      attrs={'rows':10, 'cols':40}))
+
+  class Meta:
+    model = soc.models.document.Document
+
+    #: list of model fields which will *not* be gathered by the form
+    exclude = ['inheritance_line', 'author', 'created', 'modified']
+
+  def clean_partial_path(self):
+    partial_path = self.cleaned_data.get('partial_path')
+    # TODO(tlarsen): combine path and link_name and check for uniqueness
+    return partial_path
+
+  def clean_link_name(self):
+    link_name = self.cleaned_data.get('link_name')
+    # TODO(tlarsen): combine path and link_name and check for uniqueness
+    return link_name
+
+
+DEF_DOCS_CREATE_TMPL = 'soc/models/edit.html'
+
+@decorators.view
+def create(request, page=None, template=DEF_DOCS_CREATE_TMPL):
+  """View to create a new Document entity.
+
+  Args:
+    request: the standard django request object
+    page: a soc.logic.site.page.Page object which is abstraction that combines 
+      a Django view with sidebar menu info
+    template: the "sibling" template (or a search list of such templates)
+      from which to construct the public.html template name (or names)
+
+  Returns:
+    A subclass of django.http.HttpResponse which either contains the form to
+    be filled out, or a redirect to the correct view in the interface.
+  """
+
+  try:
+    access.checkIsDeveloper(request)
+  except  soc.views.out_of_band.AccessViolationResponse, alt_response:
+    # TODO(tlarsen): change this to just limit the Documents that can be
+    #   created by the User in their current Role
+    return alt_response.response()
+
+  # create default template context for use with any templates
+  context = helper.responses.getUniversalContext(request)
+  context['page'] = page
+
+  if request.method == 'POST':
+    form = CreateForm(request.POST)
+
+    if form.is_valid():
+      doc = getDocForForm(form)
+
+      if not doc:
+        return http.HttpResponseRedirect('/')
+
+      new_path = path_link_name.combinePath([doc.partial_path, doc.link_name])
+
+      # redirect to new /document/edit/new_path?s=0
+      # (causes 'Profile saved' message to be displayed)
+      return helper.responses.redirectToChangedSuffix(
+          request, None, new_path,
+          params=profile.SUBMIT_PROFILE_SAVED_PARAMS)
+  else: # method == 'GET':
+    # no link name specified, so start with an empty form
+    form = CreateForm()
+
+  context['form'] = form
+
+  return helper.responses.respond(request, template, context)
+
+
+DEF_DOCS_EDIT_TMPL = 'soc/models/edit.html'
+
+class EditForm(CreateForm):
+  """Django form displayed a Document is edited.
+  """
+  doc_key_name = forms.fields.CharField(widget=forms.HiddenInput)
+  created_by = forms.fields.CharField(widget=helper.widgets.ReadOnlyInput(),
+                                      required=False)
+
+
+@decorators.view
+def edit(request, page=None, partial_path=None, link_name=None,
+         template=DEF_DOCS_EDIT_TMPL):
+  """View to modify the properties of a Document Model entity.
+
+  Args:
+    request: the standard django request object
+    page: a soc.logic.site.page.Page object which is abstraction that combines 
+      a Django view with sidebar menu info
+    partial_path: the Document's site-unique "path" extracted from the URL,
+      minus the trailing link_name
+    link_name: the last portion of the Document's site-unique "path"
+      extracted from the URL
+    template: the "sibling" template (or a search list of such templates)
+      from which to construct the public.html template name (or names)
+
+  Returns:
+    A subclass of django.http.HttpResponse which either contains the form to
+    be filled out, or a redirect to the correct view in the interface.
+  """
+
+  try:
+    access.checkIsDeveloper(request)
+  except  soc.views.out_of_band.AccessViolationResponse, alt_response:
+    # TODO(tlarsen): change this to just limit the Documents that can be
+    #   edited by the User in their current Role
+    return alt_response.response()
+
+  # create default template context for use with any templates
+  context = helper.responses.getUniversalContext(request)
+  context['page'] = page
+
+  doc = None  # assume that no Document entity will be found
+
+  path = path_link_name.combinePath([partial_path, link_name])
+
+  # try to fetch Document entity corresponding to path if one exists    
+  try:
+    if path:
+      doc = document.logic.getFromFields(partial_path=partial_path,
+                                         link_name=link_name)
+  except out_of_band.ErrorResponse, error:
+    # show custom 404 page when path doesn't exist in Datastore
+    error.message = error.message + DEF_CREATE_NEW_DOC_MSG
+    return simple.errorResponse(request, page, error, template, context)
+
+  if request.method == 'POST':
+    form = EditForm(request.POST)
+
+    if form.is_valid():
+      doc = getDocForForm(form)
+      
+      if not doc:
+        return http.HttpResponseRedirect('/')
+
+      new_path = path_link_name.combinePath([doc.partial_path, doc.link_name])
+        
+      # redirect to new /document/edit/new_path?s=0
+      # (causes 'Profile saved' message to be displayed)
+      return helper.responses.redirectToChangedSuffix(
+          request, path, new_path,
+          params=profile.SUBMIT_PROFILE_SAVED_PARAMS)
+  else: # method == 'GET':
+    # try to fetch Document entity corresponding to path if one exists
+    if path:
+      if doc:
+        # is 'Profile saved' parameter present, but referrer was not ourself?
+        # (e.g. someone bookmarked the GET that followed the POST submit) 
+        if (request.GET.get(profile.SUBMIT_MSG_PARAM_NAME)
+            and (not helper.requests.isReferrerSelf(request, suffix=path))):
+          # redirect to aggressively remove 'Profile saved' query parameter
+          return http.HttpResponseRedirect(request.path)
+    
+        # referrer was us, so select which submit message to display
+        # (may display no message if ?s=0 parameter is not present)
+        context['notice'] = (
+            helper.requests.getSingleIndexedParamValue(
+                request, profile.SUBMIT_MSG_PARAM_NAME,
+                values=SUBMIT_MESSAGES))
+
+        # populate form with the existing Document entity
+        author_link_name = doc.author.link_name
+        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,
+            '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
+          return http.HttpResponseRedirect(request.path)
+          
+        context['lookup_error'] = ugettext_lazy(
+            'Document with that path not found.')
+        form = EditForm(initial={'link_name': link_name})
+    else:  # no link name specified in the URL
+      if request.GET.get(profile.SUBMIT_MSG_PARAM_NAME):
+        # redirect to aggressively remove 'Profile saved' query parameter
+        return http.HttpResponseRedirect(request.path)
+
+      # no link name specified, so start with an empty form
+      form = EditForm()
+
+  context.update({'form': form,
+                  'entity': doc})
+
+  return helper.responses.respond(request, template, context)
+
+
+@decorators.view
+def delete(request, page=None, partial_path=None, link_name=None,
+           template=DEF_DOCS_EDIT_TMPL):
+  """Request handler to delete Document Model entity.
+
+  Args:
+    request: the standard django request object
+    page: a soc.logic.site.page.Page object which is abstraction that combines 
+      a Django view with sidebar menu info
+    partial_path: the Document's site-unique "path" extracted from the URL,
+      minus the trailing link_name
+    link_name: the last portion of the Document's site-unique "path"
+      extracted from the URL
+    template: the "sibling" template (or a search list of such templates)
+      from which to construct the public.html template name (or names)
+
+  Returns:
+    A subclass of django.http.HttpResponse which redirects 
+    to /site/document/list.
+  """
+
+  try:
+    access.checkIsDeveloper(request)
+  except  soc.views.out_of_band.AccessViolationResponse, alt_response:
+    # TODO(tlarsen): change this to just limit the Documents that can be
+    #   deleted by the User in their current Role
+    return alt_response.response()
+
+  # create default template context for use with any templates
+  context = helper.responses.getUniversalContext(request)
+  context['page'] = page
+
+  existing_doc = None
+  path = path_link_name.combinePath([partial_path, link_name])
+
+  # try to fetch Document entity corresponding to path if one exists    
+  try:
+    if path:
+      existing_doc = document.logic.getFromFields(partial_path=partial_path,
+                                                  link_name=link_name)
+  except out_of_band.ErrorResponse, error:
+    # show custom 404 page when path doesn't exist in Datastore
+    error.message = error.message + DEF_CREATE_NEW_DOC_MSG
+    return simple.errorResponse(request, page, error, template, context)
+
+  if existing_doc:
+    document.logic.delete(existing_doc)
+
+  return http.HttpResponseRedirect('/document/list')
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/views/document/list.py	Thu Nov 13 16:40:05 2008 +0000
@@ -0,0 +1,89 @@
+#!/usr/bin/python2.5
+#
+# Copyright 2008 the Melange authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Views for listing Documents.
+"""
+
+__authors__ = [
+  '"Todd Larsen" <tlarsen@google.com>',
+  ]
+
+
+from soc.logic.models import work
+from soc.views import helper
+from soc.views.helper import access
+from soc.views.helper import decorators
+
+import soc.logic
+import soc.models.document
+import soc.views.helper.lists
+import soc.views.helper.responses
+import soc.views.out_of_band
+
+
+DEF_DOCS_LIST_ALL_TMPL = 'soc/models/list.html'
+
+
+@decorators.view
+def all(request, page=None, templates={}):
+  """Show a list of all Documents (limit rows per page).
+  
+  Args:
+    request: the standard Django HTTP request object
+    page: a soc.logic.site.page.Page object which is abstraction that combines 
+      a Django view with sidebar menu info
+    template: the "sibling" template (or a search list of such templates)
+      from which to construct an alternate template name (or names)
+
+  Returns:
+    A subclass of django.http.HttpResponse which either contains the form to
+    be filled out, or a redirect to the correct view in the interface.
+  """
+
+  try:
+    access.checkIsDeveloper(request)
+  except  soc.views.out_of_band.AccessViolationResponse, alt_response:
+    return alt_response.response()
+
+  # create default template context for use with any templates
+  context = helper.responses.getUniversalContext(request)
+  context['page'] = page
+
+  offset, limit = helper.lists.cleanListParameters(
+      offset=request.GET.get('offset'), limit=request.GET.get('limit'))
+
+  # Fetch one more to see if there should be a 'next' link
+  document = work.logic.getForLimitAndOffset(limit + 1, offset=offset)
+
+  context['pagination_form'] = helper.lists.makePaginationForm(request, limit)
+
+  list_templates = {
+    'list_main': templates.get('list_main',
+                               'soc/list/list_main.html'),
+    'list_pagination': templates.get('list_pagination',
+                                     'soc/list/list_pagination.html'),
+    'list_row': templates.get('list_row',
+                              'soc/document/list/docs_row.html'),
+    'list_heading': templates.get('list_heading',
+                                  'soc/document/list/docs_heading.html'),
+    }
+                      
+  context = helper.lists.setList(
+      request, context, document, 
+      offset=offset, limit=limit, list_templates=list_templates)
+
+  template = templates.get('all', DEF_DOCS_LIST_ALL_TMPL)
+  return helper.responses.respond(request, template, context)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/views/document/show.py	Thu Nov 13 16:40:05 2008 +0000
@@ -0,0 +1,87 @@
+#!/usr/bin/python2.5
+#
+# Copyright 2008 the Melange authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Document viewers.
+
+public: how the general public sees a Document
+"""
+
+__authors__ = [
+  '"Todd Larsen" <tlarsen@google.com>',
+  ]
+
+
+from soc.logic import out_of_band
+from soc.logic import path_link_name
+from soc.logic.models import document
+from soc.views import helper
+from soc.views import simple
+from soc.views.helper import decorators
+
+import soc.views.helper.responses
+import soc.views.helper.templates
+
+
+DEF_DOCS_PUBLIC_TMPL = 'soc/document/public.html'
+
+@decorators.view
+def public(request, page=None, partial_path=None, link_name=None,
+           template=DEF_DOCS_PUBLIC_TMPL):
+  """How the "general public" sees a Document.
+
+  Args:
+    request: the standard django request object
+    page: a soc.logic.site.page.Page object which is abstraction that combines 
+      a Django view with sidebar menu info
+    partial_path: the Document's site-unique "path" extracted from the URL,
+      minus the trailing link_name
+    link_name: the last portion of the Document's site-unique "path"
+      extracted from the URL
+    template: the "sibling" template (or a search list of such templates)
+      from which to construct the public.html template name (or names)
+
+  Returns:
+    A subclass of django.http.HttpResponse which either contains the form to
+    be filled out, or a redirect to the correct view in the interface.
+  """
+  # create default template context for use with any templates
+  context = helper.responses.getUniversalContext(request)
+
+  # TODO: there eventually needs to be a call to some controller logic that
+  #   implements some sort of access controls, based on the currently
+  #   logged-in User's Roles, etc.
+
+  # TODO: based on the User's Roles, Documents that the User can edit
+  #   should display a link to a document edit form
+  
+  doc = None
+
+  # try to fetch User entity corresponding to link_name if one exists
+  path = path_link_name.combinePath([partial_path, link_name])
+
+  # try to fetch Document entity corresponding to path if one exists    
+  try:
+    if path:
+      doc = document.logic.getFromFields(partial_path=partial_path,
+                                         link_name=link_name)
+  except out_of_band.ErrorResponse, error:
+    # show custom 404 page when Document path doesn't exist in Datastore
+    return simple.errorResponse(request, page, error, template, context)
+
+  doc.content = helper.templates.unescape(doc.content)
+  context['entity'] = doc
+
+  return helper.responses.respond(request, template, context)
\ No newline at end of file
--- a/app/soc/views/models/docs.py	Wed Nov 12 21:43:15 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,157 +0,0 @@
-#!/usr/bin/python2.5
-#
-# Copyright 2008 the Melange authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Views for Documents.
-"""
-
-__authors__ = [
-    '"Sverre Rabbelier" <sverre@rabbelier.nl>',
-    '"Lennard de Rijk" <ljvderijk@gmail.com>',
-    '"Pawel Solyga" <pawel.solyga@gmail.com>',
-  ]
-
-
-from google.appengine.api import users
-
-from django import forms
-from django.utils.translation import ugettext_lazy
-
-from soc.logic import dicts
-from soc.logic import validate
-from soc.views import helper
-from soc.views.helper import widgets
-from soc.views.models import base
-
-import soc.models.document
-import soc.logic.models.document
-import soc.logic.dicts
-import soc.views.helper
-import soc.views.helper.widgets
-
-class CreateForm(helper.forms.BaseForm):
-  """Django form displayed when Developer creates a Document.
-  """
-
-  content = forms.fields.CharField(widget=helper.widgets.TinyMCE(
-      attrs={'rows':10, 'cols':40}))
-
-  class Meta:
-    model = soc.models.document.Document
-
-    #: list of model fields which will *not* be gathered by the form
-    exclude = ['inheritance_line', 'author', 'created', 'modified']
-
-  def clean_partial_path(self):
-    partial_path = self.cleaned_data.get('partial_path')
-    # TODO(tlarsen): combine path and link_name and check for uniqueness
-    if not validate.isPartialPathFormatValid(partial_path):
-      raise forms.ValidationError("This partial path is in wrong format.")
-    return partial_path
-
-  def clean_link_name(self):
-    link_name = self.cleaned_data.get('link_name')
-    # TODO(tlarsen): combine path and link_name and check for uniqueness
-    if not validate.isLinkNameFormatValid(link_name):
-      raise forms.ValidationError("This link name is in wrong format.")
-    return link_name
-
-
-class EditForm(CreateForm):
-  """Django form displayed a Document is edited.
-  """
-
-  doc_key_name = forms.fields.CharField(widget=forms.HiddenInput)
-  created_by = forms.fields.CharField(widget=helper.widgets.ReadOnlyInput(),
-                                      required=False)
-
-
-class View(base.View):
-  """View methods for the Docs model
-  """
-
-  def __init__(self, original_params=None, original_rights=None):
-    """Defines the fields and methods required for the base View class
-    to provide the user with list, public, create, edit and delete views.
-
-    Params:
-      original_params: a dict with params for this View
-      original_rights: a dict with right definitions for this View
-    """
-
-    self._logic = soc.logic.models.document.logic
-
-    params = {}
-    rights = {}
-
-    params['name'] = "Document"
-    params['name_short'] = "Docs"
-    params['name_plural'] = "Documents"
-
-    params['edit_form'] = EditForm
-    params['create_form'] = CreateForm
-
-    # TODO(tlarsen) Add support for Django style template lookup
-    params['edit_template'] = 'soc/models/edit.html'
-    params['public_template'] = 'soc/docs/public.html'
-    params['list_template'] = 'soc/models/list.html'
-
-    params['lists_template'] = {
-      'list_main': 'soc/list/list_main.html',
-      'list_pagination': 'soc/list/list_pagination.html',
-      'list_row': 'soc/docs/list/docs_row.html',
-      'list_heading': 'soc/docs/list/docs_heading.html',
-    }
-
-    params['delete_redirect'] = '/docs/list'
-    params['create_redirect'] = 'soc/models/edit.html'
-
-    params['save_message'] = [ugettext_lazy('Profile saved.')]
-
-    params['edit_params'] = {
-        self.DEF_SUBMIT_MSG_PARAM_NAME: self.DEF_SUBMIT_MSG_PROFILE_SAVED,
-        }
-
-    rights['list'] = [helper.access.checkIsDeveloper]
-    rights['delete'] = [helper.access.checkIsDeveloper]
-
-    params = dicts.merge(original_params, params)
-    rights = dicts.merge(original_rights, rights)
-
-    base.View.__init__(self, rights=rights, params=params)
-
-  def _editPost(self, request, entity, fields):
-    """See base.View._editPost().
-    """
-
-    id = users.get_current_user()
-    user = soc.logic.models.user.logic.getForFields({'id': id}, unique=True)
-    fields['author'] = user
-
-  def _editGet(self, request, entity, form):
-    """See base.View._editGet().
-    """
-
-    form.fields['created_by'].initial = entity.author.link_name
-    form.fields['doc_key_name'].initial = entity.key().name(),
-
-
-view = View()
-
-create = view.create
-edit = view.edit
-delete = view.delete
-list = view.list
-public = view.public
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/views/models/document.py	Thu Nov 13 16:40:05 2008 +0000
@@ -0,0 +1,157 @@
+#!/usr/bin/python2.5
+#
+# Copyright 2008 the Melange authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Views for Documents.
+"""
+
+__authors__ = [
+    '"Sverre Rabbelier" <sverre@rabbelier.nl>',
+    '"Lennard de Rijk" <ljvderijk@gmail.com>',
+    '"Pawel Solyga" <pawel.solyga@gmail.com>',
+  ]
+
+
+from google.appengine.api import users
+
+from django import forms
+from django.utils.translation import ugettext_lazy
+
+from soc.logic import dicts
+from soc.logic import validate
+from soc.views import helper
+from soc.views.helper import widgets
+from soc.views.models import base
+
+import soc.models.document
+import soc.logic.models.document
+import soc.logic.dicts
+import soc.views.helper
+import soc.views.helper.widgets
+
+class CreateForm(helper.forms.BaseForm):
+  """Django form displayed when Developer creates a Document.
+  """
+
+  content = forms.fields.CharField(widget=helper.widgets.TinyMCE(
+      attrs={'rows':10, 'cols':40}))
+
+  class Meta:
+    model = soc.models.document.Document
+
+    #: list of model fields which will *not* be gathered by the form
+    exclude = ['inheritance_line', 'author', 'created', 'modified']
+
+  def clean_partial_path(self):
+    partial_path = self.cleaned_data.get('partial_path')
+    # TODO(tlarsen): combine path and link_name and check for uniqueness
+    if not validate.isPartialPathFormatValid(partial_path):
+      raise forms.ValidationError("This partial path is in wrong format.")
+    return partial_path
+
+  def clean_link_name(self):
+    link_name = self.cleaned_data.get('link_name')
+    # TODO(tlarsen): combine path and link_name and check for uniqueness
+    if not validate.isLinkNameFormatValid(link_name):
+      raise forms.ValidationError("This link name is in wrong format.")
+    return link_name
+
+
+class EditForm(CreateForm):
+  """Django form displayed a Document is edited.
+  """
+
+  doc_key_name = forms.fields.CharField(widget=forms.HiddenInput)
+  created_by = forms.fields.CharField(widget=helper.widgets.ReadOnlyInput(),
+                                      required=False)
+
+
+class View(base.View):
+  """View methods for the Document model
+  """
+
+  def __init__(self, original_params=None, original_rights=None):
+    """Defines the fields and methods required for the base View class
+    to provide the user with list, public, create, edit and delete views.
+
+    Params:
+      original_params: a dict with params for this View
+      original_rights: a dict with right definitions for this View
+    """
+
+    self._logic = soc.logic.models.document.logic
+
+    params = {}
+    rights = {}
+
+    params['name'] = "Document"
+    params['name_short'] = "Document"
+    params['name_plural'] = "Documents"
+
+    params['edit_form'] = EditForm
+    params['create_form'] = CreateForm
+
+    # TODO(tlarsen) Add support for Django style template lookup
+    params['edit_template'] = 'soc/models/edit.html'
+    params['public_template'] = 'soc/document/public.html'
+    params['list_template'] = 'soc/models/list.html'
+
+    params['lists_template'] = {
+      'list_main': 'soc/list/list_main.html',
+      'list_pagination': 'soc/list/list_pagination.html',
+      'list_row': 'soc/document/list/docs_row.html',
+      'list_heading': 'soc/document/list/docs_heading.html',
+    }
+
+    params['delete_redirect'] = '/document/list'
+    params['create_redirect'] = 'soc/models/edit.html'
+
+    params['save_message'] = [ugettext_lazy('Profile saved.')]
+
+    params['edit_params'] = {
+        self.DEF_SUBMIT_MSG_PARAM_NAME: self.DEF_SUBMIT_MSG_PROFILE_SAVED,
+        }
+
+    rights['list'] = [helper.access.checkIsDeveloper]
+    rights['delete'] = [helper.access.checkIsDeveloper]
+
+    params = dicts.merge(original_params, params)
+    rights = dicts.merge(original_rights, rights)
+
+    base.View.__init__(self, rights=rights, params=params)
+
+  def _editPost(self, request, entity, fields):
+    """See base.View._editPost().
+    """
+
+    id = users.get_current_user()
+    user = soc.logic.models.user.logic.getForFields({'id': id}, unique=True)
+    fields['author'] = user
+
+  def _editGet(self, request, entity, form):
+    """See base.View._editGet().
+    """
+
+    form.fields['created_by'].initial = entity.author.link_name
+    form.fields['doc_key_name'].initial = entity.key().name(),
+
+
+view = View()
+
+create = view.create
+edit = view.edit
+delete = view.delete
+list = view.list
+public = view.public
--- a/app/soc/views/models/home_settings.py	Wed Nov 12 21:43:15 2008 +0000
+++ b/app/soc/views/models/home_settings.py	Thu Nov 13 16:40:05 2008 +0000
@@ -96,7 +96,7 @@
 
 
 class View(base.View):
-  """View methods for the Docs model
+  """View methods for the Document model
   """
 
   def __init__(self, original_params=None, original_rights=None):
--- a/app/soc/views/models/site_settings.py	Wed Nov 12 21:43:15 2008 +0000
+++ b/app/soc/views/models/site_settings.py	Thu Nov 13 16:40:05 2008 +0000
@@ -63,7 +63,7 @@
 
 
 class View(home_settings.View):
-  """View methods for the Docs model
+  """View methods for the Document model
   """
 
   def __init__(self, original_params=None, original_rights=None):