Rename the confusing Tossed Model class to PresenceWithToS.
authorTodd Larsen <tlarsen@google.com>
Wed, 28 Jan 2009 21:01:37 +0000
changeset 1053 3b9552cf748a
parent 1052 cd6d6034b6e9
child 1054 1a802e5183b9
Rename the confusing Tossed Model class to PresenceWithToS. Patch by: Todd Larsen Review by: to-be-reviewed
app/soc/logic/models/presence_with_tos.py
app/soc/logic/models/program.py
app/soc/logic/models/site.py
app/soc/logic/models/tossed.py
app/soc/models/presence_with_tos.py
app/soc/models/program.py
app/soc/models/site.py
app/soc/models/tossed.py
app/soc/views/models/presence_with_tos.py
app/soc/views/models/program.py
app/soc/views/models/site.py
app/soc/views/models/tossed.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/logic/models/presence_with_tos.py	Wed Jan 28 21:01:37 2009 +0000
@@ -0,0 +1,44 @@
+#!/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.
+
+"""PresenceWithToS (Model) query functions.
+"""
+
+__authors__ = [
+  '"Sverre Rabbelier" <sverre@rabbelier.nl>',
+  ]
+
+
+from soc.logic.models import presence
+from soc.logic.models import presence as presence_logic
+
+import soc.models.presence_with_tos
+
+
+class Logic(presence.Logic):
+  """Logic methods for the PresenceWithToS model.
+  """
+
+  def __init__(self, model=soc.models.presence_with_tos.PresenceWithToS,
+               base_model=None, scope_logic=presence_logic):
+    """Defines the name, key_name and model for this entity.
+    """
+
+    super(Logic, self).__init__(model=model, base_model=base_model,
+                                scope_logic=scope_logic)
+
+
+logic = Logic()
--- a/app/soc/logic/models/program.py	Wed Jan 28 20:27:16 2009 +0000
+++ b/app/soc/logic/models/program.py	Wed Jan 28 21:01:37 2009 +0000
@@ -23,15 +23,15 @@
   ]
 
 
-from soc.logic.models import tossed
-from soc.logic.models import tossed as tossed_logic
+from soc.logic.models import presence_with_tos
+from soc.logic.models import presence_with_tos as tos_logic
 
 import gsoc.logic.models.timeline
 import soc.logic.models.timeline
 import soc.models.program
 
 
-class Logic(tossed.Logic):
+class Logic(presence_with_tos.Logic):
   """Logic methods for the Program model.
   """
 
@@ -39,7 +39,7 @@
                     'ghop' : soc.logic.models.timeline.logic}
 
   def __init__(self, model=soc.models.program.Program, 
-               base_model=None, scope_logic=tossed_logic):
+               base_model=None, scope_logic=tos_logic):
     """Defines the name, key_name and model for this entity.
     """
 
--- a/app/soc/logic/models/site.py	Wed Jan 28 20:27:16 2009 +0000
+++ b/app/soc/logic/models/site.py	Wed Jan 28 21:01:37 2009 +0000
@@ -22,20 +22,20 @@
   ]
 
 
-from soc.logic.models import tossed
+from soc.logic.models import presence_with_tos
 
-import soc.models.tossed
+import soc.models.presence_with_tos
 import soc.models.site
 
 
-class Logic(tossed.Logic):
+class Logic(presence_with_tos.Logic):
   """Logic methods for the Site model.
   """
 
   DEF_SITE_LINK_ID = 'site'
 
   def __init__(self, model=soc.models.site.Site,
-               base_model=soc.models.tossed.Tossed):
+               base_model=soc.models.presence_with_tos.PresenceWithToS):
     """Defines the name, key_name and model for this entity.
     """
 
--- a/app/soc/logic/models/tossed.py	Wed Jan 28 20:27:16 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +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.
-
-"""Tossed (Model) query functions.
-"""
-
-__authors__ = [
-  '"Sverre Rabbelier" <sverre@rabbelier.nl>',
-  ]
-
-
-from soc.logic.models import presence
-from soc.logic.models import presence as presence_logic
-
-import soc.models.tossed
-
-
-class Logic(presence.Logic):
-  """Logic methods for the Tossed model.
-  """
-
-  def __init__(self, model=soc.models.tossed.Tossed,
-               base_model=None, scope_logic=presence_logic):
-    """Defines the name, key_name and model for this entity.
-    """
-
-    super(Logic, self).__init__(model=model, base_model=base_model,
-                                scope_logic=scope_logic)
-
-
-logic = Logic()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/models/presence_with_tos.py	Wed Jan 28 21:01:37 2009 +0000
@@ -0,0 +1,42 @@
+#!/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.
+
+"""This module contains the PresenceWithToS Model.
+"""
+
+__authors__ = [
+  '"Sverre Rabbelier" <sverre@rabbelier.nl>',
+]
+
+from google.appengine.ext import db
+
+from django.utils.translation import ugettext
+
+import soc.models.presence
+
+
+class PresenceWithToS(soc.models.presence.Presence):
+  """Model of a Presence that has a Terms of Service.
+  """
+
+  #: Reference to Document containing optional Terms of Service
+  tos = db.ReferenceProperty(
+    reference_class=soc.models.document.Document,
+    verbose_name=ugettext('Terms of Service'),
+    collection_name='tos')
+  tos.help_text = ugettext(
+      'Document containing optional Terms of Service for participating.')
+  tos.redirect_url = soc.models.document.Document.URL_NAME
--- a/app/soc/models/program.py	Wed Jan 28 20:27:16 2009 +0000
+++ b/app/soc/models/program.py	Wed Jan 28 21:01:37 2009 +0000
@@ -26,11 +26,11 @@
 
 from django.utils.translation import ugettext
 
-import soc.models.tossed
+import soc.models.presence_with_tos
 import soc.models.timeline
 
 
-class Program(soc.models.tossed.Tossed):
+class Program(soc.models.presence_with_tos.PresenceWithToS):
   """The Program model, representing a Program ran by a Sponsor.
   """
 
--- a/app/soc/models/site.py	Wed Jan 28 20:27:16 2009 +0000
+++ b/app/soc/models/site.py	Wed Jan 28 21:01:37 2009 +0000
@@ -26,10 +26,10 @@
 
 from django.utils.translation import ugettext
 
-import soc.models.tossed
+import soc.models.presence_with_tos
 
 
-class Site(soc.models.tossed.Tossed):
+class Site(soc.models.presence_with_tos.PresenceWithToS):
   """Model of a Site, which stores per site configuration.
 
   The Site Model stores configuration information unique to the Melange
--- a/app/soc/models/tossed.py	Wed Jan 28 20:27:16 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +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.
-
-"""This module contains the Tossed Model.
-"""
-
-__authors__ = [
-  '"Sverre Rabbelier" <sverre@rabbelier.nl>',
-]
-
-from google.appengine.ext import db
-
-from django.utils.translation import ugettext
-
-import soc.models.presence
-
-
-class Tossed(soc.models.presence.Presence):
-  """Model of a Presence that has a Terms of Service.
-  """
-
-  #: Reference to Document containing optional Terms of Service
-  tos = db.ReferenceProperty(
-    reference_class=soc.models.document.Document,
-    verbose_name=ugettext('Terms of Service'),
-    collection_name='tos')
-  tos.help_text = ugettext(
-      'Document containing optional Terms of Service for participating.')
-  tos.redirect_url = soc.models.document.Document.URL_NAME
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/views/models/presence_with_tos.py	Wed Jan 28 21:01:37 2009 +0000
@@ -0,0 +1,90 @@
+#!/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 PresenceWithToS.
+"""
+
+__authors__ = [
+    '"Sverre Rabbelier" <sverre@rabbelier.nl>',
+  ]
+
+
+from google.appengine.ext import db
+
+from django import forms
+from django.utils.translation import ugettext
+
+from soc.logic import dicts
+from soc.logic.models import document as document_logic
+from soc.views.models import presence
+
+import soc.logic.models.presence_with_tos
+import soc.models.work
+
+
+class View(presence.View):
+  """View methods for the PresenceWithToS model.
+  """
+
+  def __init__(self, params=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:
+      params: a dict with params for this View
+    """
+
+    new_params = {}
+    new_params['logic'] = soc.logic.models.presence_with_tos.logic
+
+    new_params['create_extra_dynafields'] = {
+        'tos_link_id': forms.CharField(required=False,
+            label=ugettext('Terms of Service Document link ID'),
+            help_text=soc.models.work.Work.link_id.help_text),
+        }
+
+    params = dicts.merge(params, new_params, sub_merge=True)
+
+    super(View, self).__init__(params=params)
+
+  def _editGet(self, request, entity, form):
+    """See base.View._editGet().
+    """
+
+    try:
+      if entity.tos:
+        form.fields['tos_link_id'].initial = entity.tos.link_id
+    except db.Error:
+      pass
+
+    super(View, self)._editGet(request, entity, form)
+
+  def _editPost(self, request, entity, fields):
+    """See base.View._editPost().
+    """
+
+    key_fields = self._logic.getKeyFieldsFromDict(fields)
+    scope_path = self._logic.getKeyNameForFields(key_fields)
+
+    tos_link_id = fields['tos_link_id']
+
+    # TODO notify the user if tos_doc is not found
+    tos_doc = document_logic.logic.getFromFields(
+      scope_path=scope_path, link_id=tos_link_id)
+
+    fields['tos'] = tos_doc
+
+    super(View, self)._editPost(request, entity, fields)
--- a/app/soc/views/models/program.py	Wed Jan 28 20:27:16 2009 +0000
+++ b/app/soc/views/models/program.py	Wed Jan 28 21:01:37 2009 +0000
@@ -33,7 +33,7 @@
 from soc.views.helper import decorators
 from soc.views.helper import redirects
 from soc.views.helper import widgets
-from soc.views.models import tossed
+from soc.views.models import presence_with_tos
 from soc.views.models import document as document_view
 from soc.views.models import sponsor as sponsor_view
 from soc.views.sitemap import sidebar
@@ -41,7 +41,7 @@
 import soc.logic.models.program
 
 
-class View(tossed.View):
+class View(presence_with_tos.View):
   """View methods for the Program model.
   """
 
--- a/app/soc/views/models/site.py	Wed Jan 28 20:27:16 2009 +0000
+++ b/app/soc/views/models/site.py	Wed Jan 28 21:01:37 2009 +0000
@@ -27,14 +27,14 @@
 from soc.logic import dicts
 from soc.views.helper import access
 from soc.views.models import document as document_view
-from soc.views.models import tossed
+from soc.views.models import presence_with_tos
 
 import soc.models.site
 import soc.logic.models.site
 import soc.logic.dicts
 
 
-class View(tossed.View):
+class View(presence_with_tos.View):
   """View methods for the Document model.
   """
 
--- a/app/soc/views/models/tossed.py	Wed Jan 28 20:27:16 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +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 Tossed.
-"""
-
-__authors__ = [
-    '"Sverre Rabbelier" <sverre@rabbelier.nl>',
-  ]
-
-
-from google.appengine.ext import db
-
-from django import forms
-from django.utils.translation import ugettext
-
-from soc.logic import dicts
-from soc.logic.models import document as document_logic
-from soc.views.models import presence
-
-import soc.logic.models.tossed
-import soc.models.work
-
-
-class View(presence.View):
-  """View methods for the Tossed model.
-  """
-
-  def __init__(self, params=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:
-      params: a dict with params for this View
-    """
-
-    new_params = {}
-    new_params['logic'] = soc.logic.models.tossed.logic
-
-    new_params['create_extra_dynafields'] = {
-        'tos_link_id': forms.CharField(required=False,
-            label=ugettext('Terms of Service Document link ID'),
-            help_text=soc.models.work.Work.link_id.help_text),
-        }
-
-    params = dicts.merge(params, new_params, sub_merge=True)
-
-    super(View, self).__init__(params=params)
-
-  def _editGet(self, request, entity, form):
-    """See base.View._editGet().
-    """
-
-    try:
-      if entity.tos:
-        form.fields['tos_link_id'].initial = entity.tos.link_id
-    except db.Error:
-      pass
-
-    super(View, self)._editGet(request, entity, form)
-
-  def _editPost(self, request, entity, fields):
-    """See base.View._editPost().
-    """
-
-    key_fields = self._logic.getKeyFieldsFromDict(fields)
-    scope_path = self._logic.getKeyNameForFields(key_fields)
-
-    tos_link_id = fields['tos_link_id']
-
-    # TODO notify the user if tos_doc is not found
-    tos_doc = document_logic.logic.getFromFields(
-      scope_path=scope_path, link_id=tos_link_id)
-
-    fields['tos'] = tos_doc
-
-    super(View, self)._editPost(request, entity, fields)