Remove bogus scope from Site
authorSverre Rabbelier <srabbelier@gmail.com>
Sun, 07 Dec 2008 15:29:10 +0000
changeset 702 e3b91b6955ff
parent 701 d6f5d34cff5a
child 703 c4f3997becd9
Remove bogus scope from Site This makes Site an unscoped entity (similar to how User and Sponsor do not have a scope). Patch by: Sverre Rabbelier
app/soc/logic/models/site.py
app/soc/views/helper/responses.py
app/soc/views/models/site.py
--- a/app/soc/logic/models/site.py	Sun Dec 07 15:28:36 2008 +0000
+++ b/app/soc/logic/models/site.py	Sun Dec 07 15:29:10 2008 +0000
@@ -33,9 +33,7 @@
   """Logic methods for the Site model.
   """
 
-  DEF_SITE_SCOPE_PATH = 'site'
-  DEF_SITE_LINK_ID = 'home'
-  DEF_SITE_HOME_DOC_LINK_ID = 'home'
+  DEF_SITE_LINK_ID = 'site'
 
   def __init__(self, model=soc.models.site.Site,
                base_model=soc.models.presence.Presence):
@@ -44,15 +42,38 @@
 
     super(Logic, self).__init__(model=model, base_model=base_model)
 
-  def getKeyValues(self, unused_entity):
-    """Returns the default key values for the site settings.
+  def getKeyValues(self, entity):
+    """Returns the key values for the site settings.
 
-    The Site entity is always expected to be a singleton, so this method
-    returns the hard-coded scope and link_id.
+    The Site entity is a singleton, so this method returns a
+    hard-coded link_id.
+
+    Args:
+      entity: unused
     """
 
-    return [self.DEF_SITE_SCOPE_PATH, 
-            self.DEF_SITE_LINK_ID]
+    return [self.DEF_SITE_LINK_ID]
+
+  def getKeyValuesFromFields(self, fields):
+    """Extracts the key values from a dict and returns them.
+
+    The Site entity is a singleton, so this method returns a
+    hard-coded link_id.
+
+    Args:
+      fields: unused
+    """
+
+    return [self.DEF_SITE_LINK_ID]
+
+  def getKeyFieldNames(self):
+    """Returns an array with the names of the Key Fields.
+
+    The Site entity is an unscoped singleton, it's key fields consist
+    of just the link_id.
+    """
+
+    return ['link_id']
 
 
 logic = Logic()
--- a/app/soc/views/helper/responses.py	Sun Dec 07 15:28:36 2008 +0000
+++ b/app/soc/views/helper/responses.py	Sun Dec 07 15:29:10 2008 +0000
@@ -112,9 +112,7 @@
   context['soc_release'] = release.RELEASE_TAG
   context['gae_version'] = system.getAppVersion()
 
-  settings = site.logic.getFromFields(
-      scope_path=site.logic.DEF_SITE_SCOPE_PATH,
-      link_id=site.logic.DEF_SITE_LINK_ID)
+  settings = site.logic.getFromFields(link_id=site.logic.DEF_SITE_LINK_ID)
   
   if settings:
     context['ga_tracking_num'] = settings.ga_tracking_num
--- a/app/soc/views/models/site.py	Sun Dec 07 15:28:36 2008 +0000
+++ b/app/soc/views/models/site.py	Sun Dec 07 15:29:10 2008 +0000
@@ -46,8 +46,6 @@
     #: list of model fields which will *not* be gathered by the form
     exclude = ['home', 'scope', 'scope_path', 'link_id']
 
-  scope_path = forms.CharField(widget=forms.HiddenInput)
-
   link_id = forms.CharField(widget=forms.HiddenInput)
 
 
@@ -101,7 +99,7 @@
     patterns += [(r'^$', 'soc.views.models.%(module_name)s.main_public', 
                   page_name)]
 
-    page_name = "Edit Site Settings"
+    page_name = "Edit Site"
     patterns += [(r'^%(url_name)s/edit$',
                   'soc.views.models.%(module_name)s.main_edit',
                   page_name)]