# HG changeset patch # User Todd Larsen # Date 1227264375 0 # Node ID c31cfbf1a20f940fef342338d965c44859928cc2 # Parent ba3309b2fd30b6a65b0efa52e6f7a3f6a018302e Replace HomeSettings with Presence Model class. Replace SiteSettings with Site Model class. Derive Group Model class from Presence, adding the "home page settings" properties in a Melange site presence to every Group. Patch by: Todd Larsen diff -r ba3309b2fd30 -r c31cfbf1a20f app/soc/logic/models/base.py --- a/app/soc/logic/models/base.py Fri Nov 21 08:41:23 2008 +0000 +++ b/app/soc/logic/models/base.py Fri Nov 21 10:46:15 2008 +0000 @@ -468,10 +468,6 @@ supplied key_name and properties. """ - import logging - logging.info(key_name) - logging.info(properties) - entity = self.getFromKeyName(key_name) if not entity: diff -r ba3309b2fd30 -r c31cfbf1a20f app/soc/logic/models/home_settings.py --- a/app/soc/logic/models/home_settings.py Fri Nov 21 08:41:23 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +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. - -"""HomeSettings (Model) query functions. -""" - -__authors__ = [ - '"Sverre Rabbelier" ', - '"Lennard de Rijk" ' - ] - - -from soc.logic.models import base - -import soc.models.home_settings - - -class Logic(base.Logic): - """Logic methods for the HomeSettings model. - """ - - def __init__(self): - """Defines the name, key_name and model for this entity. - """ - base.Logic.__init__(self, soc.models.home_settings.HomeSettings) - - def getKeyValues(self, entity): - """See base.Logic.getKeyNameValues. - """ - - return [entity.scope_path, entity.link_id] - - def getKeyValuesFromFields(self, fields): - """See base.Logic.getKeyValuesFromFields. - """ - - return [fields['scope_path'], fields['link_id']] - - def getKeyFieldNames(self): - """See base.Logic.getKeyFieldNames. - """ - - return ['scope_path', 'link_id'] - -logic = Logic() diff -r ba3309b2fd30 -r c31cfbf1a20f app/soc/logic/models/presence.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/soc/logic/models/presence.py Fri Nov 21 10:46:15 2008 +0000 @@ -0,0 +1,58 @@ +#!/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. + +"""Presence (Model) query functions. +""" + +__authors__ = [ + '"Sverre Rabbelier" ', + '"Lennard de Rijk" ' + ] + + +from soc.logic.models import base + +import soc.models.presence + + +class Logic(base.Logic): + """Logic methods for the Presence model. + """ + + def __init__(self): + """Defines the name, key_name and model for this entity. + """ + base.Logic.__init__(self, soc.models.presence.Presence) + + def getKeyValues(self, entity): + """See base.Logic.getKeyNameValues. + """ + + return [entity.scope_path, entity.link_id] + + def getKeyValuesFromFields(self, fields): + """See base.Logic.getKeyValuesFromFields. + """ + + return [fields['scope_path'], fields['link_id']] + + def getKeyFieldNames(self): + """See base.Logic.getKeyFieldNames. + """ + + return ['scope_path', 'link_id'] + +logic = Logic() diff -r ba3309b2fd30 -r c31cfbf1a20f app/soc/logic/models/site.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/soc/logic/models/site.py Fri Nov 21 10:46:15 2008 +0000 @@ -0,0 +1,54 @@ +#!/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. + +"""Site (Model) query functions. +""" + +__authors__ = [ + '"Sverre Rabbelier" ', + ] + + +from soc.logic.models import base +from soc.logic.models import presence + +import soc.models.presence +import soc.models.site + + +class Logic(presence.Logic): + """Logic methods for the Site model. + """ + + DEF_SITE_SCOPE_PATH = 'site' + DEF_SITE_LINK_ID = 'home' + DEF_SITE_HOME_DOC_LINK_ID = 'home' + + def __init__(self): + """Defines the name, key_name and model for this entity. + """ + base.Logic.__init__(self, soc.models.site.Site, + base_model=soc.models.presence.Presence) + + def getMainKeyValues(self): + """Returns the default key values for the site settings. + """ + + return [self.DEF_SITE_SCOPE_PATH, + self.DEF_SITE_LINK_ID] + + +logic = Logic() diff -r ba3309b2fd30 -r c31cfbf1a20f app/soc/logic/models/site_settings.py --- a/app/soc/logic/models/site_settings.py Fri Nov 21 08:41:23 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +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. - -"""SiteSettings (Model) query functions. -""" - -__authors__ = [ - '"Sverre Rabbelier" ', - ] - - -from soc.logic.models import base -from soc.logic.models import home_settings - -import soc.models.home_settings -import soc.models.site_settings - - -class Logic(home_settings.Logic): - """Logic methods for the SiteSettings model. - """ - - DEF_SITE_SETTINGS_SCOPE_PATH = 'site' - DEF_SITE_SETTINGS_LINK_ID = 'home' - DEF_SITE_HOME_DOC_LINK_ID = 'home' - - def __init__(self): - """Defines the name, key_name and model for this entity. - """ - base.Logic.__init__(self, soc.models.site_settings.SiteSettings, - base_model=soc.models.home_settings.HomeSettings) - - def getMainKeyValues(self): - """Returns the default key values for the site settings. - """ - - return [self.DEF_SITE_SETTINGS_SCOPE_PATH, - self.DEF_SITE_SETTINGS_LINK_ID] - - -logic = Logic() diff -r ba3309b2fd30 -r c31cfbf1a20f app/soc/models/group.py --- a/app/soc/models/group.py Fri Nov 21 08:41:23 2008 +0000 +++ b/app/soc/models/group.py Fri Nov 21 10:46:15 2008 +0000 @@ -28,11 +28,11 @@ from soc.models import countries -import soc.models.linkable +import soc.models.presence import soc.models.user -class Group(soc.models.linkable.Linkable): +class Group(soc.models.presence.Presence): """Common data fields for all groups. """ diff -r ba3309b2fd30 -r c31cfbf1a20f app/soc/models/home_settings.py --- a/app/soc/models/home_settings.py Fri Nov 21 08:41:23 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +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 HomeSettings Model.""" - -__authors__ = [ - '"Pawel Solyga" ', - '"Todd Larsen" ', -] - - -from google.appengine.ext import db - -from django.utils.translation import ugettext_lazy - -import soc.models.document -import soc.models.linkable - - -class HomeSettings(soc.models.linkable.Linkable): - """Model that stores settings for various Home pages. - - This Model is the basis for more specific "/home" view settings, such as - SiteSettings, ProgramSettings, etc. - """ - - #: Reference to Document containing the contents of the "/home" page - home = db.ReferenceProperty( - reference_class=soc.models.document.Document, - collection_name='home') - home.help_text = ugettext_lazy( - 'Document to be used as the "/home" page static contents.') - - #: Valid ATOM or RSS feed url or None if unused. Feed entries are shown - #: on the site page using Google's JavaScript blog widget - feed_url = db.LinkProperty(verbose_name=ugettext_lazy('Feed URL')) - feed_url.help_text = ugettext_lazy( - 'The URL should be a valid ATOM or RSS feed. ' - 'Feed entries are shown on the home page.') diff -r ba3309b2fd30 -r c31cfbf1a20f app/soc/models/presence.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/soc/models/presence.py Fri Nov 21 10:46:15 2008 +0000 @@ -0,0 +1,58 @@ +#!/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 Presence Model.""" + +__authors__ = [ + '"Pawel Solyga" ', + '"Todd Larsen" ', +] + + +from google.appengine.ext import db + +from django.utils.translation import ugettext_lazy + +import soc.models.document +import soc.models.linkable + + +class Presence(soc.models.linkable.Linkable): + """Model for anything that has a "presence" on a Melange site. + + A "presence" is (currently) defined as: + * having a "home" page with contents set by selecting a Document + * displaying an (optional) ATOM or RSS feed + + Models that have a "presence" on a Melange web site are (currently): + * any Group (Organization, Club, etc.) + * any Program + * the site itself, which is a singleton Presence + """ + + #: Reference to Document containing the contents of the "/home" page + home = db.ReferenceProperty( + reference_class=soc.models.document.Document, + collection_name='home') + home.help_text = ugettext_lazy( + 'Document to be used as the "/home" page static contents.') + + #: Valid ATOM or RSS feed url or None if unused. Feed entries are shown + #: on the site page using Google's JavaScript blog widget + feed_url = db.LinkProperty(verbose_name=ugettext_lazy('Feed URL')) + feed_url.help_text = ugettext_lazy( + 'The URL should be a valid ATOM or RSS feed. ' + 'Feed entries are shown on the home page.') diff -r ba3309b2fd30 -r c31cfbf1a20f app/soc/models/site.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/soc/models/site.py Fri Nov 21 10:46:15 2008 +0000 @@ -0,0 +1,54 @@ +#!/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 Site Model.""" + +__authors__ = [ + '"Pawel Solyga" ', + '"Lennard de Rijk" ', +] + + +from google.appengine.ext import db + +from django.utils.translation import ugettext_lazy + +import soc.models.presence + + +class Site(soc.models.presence.Presence): + """Model of a Site, which stores per site configuration. + + The Site Model stores configuration information unique to the Melange + web site as a whole (in addition to any configuration that is common to + any "presence" on the site, such as a Group or Program). + """ + + #: Valid Google Analytics tracking number, if entered every page + #: is going to have Google Analytics JS initialization code in + #: the footer with the given tracking number. + ga_tracking_num = db.StringProperty( + verbose_name=ugettext_lazy('Google Analytics')) + ga_tracking_num.help_text = ugettext_lazy( + 'Valid Google Analytics tracking number. If the number is ' + 'entered every page is going to have Google Analytics ' + 'initialization code in footer.') + + #: Valid Google Maps API Key. Used to embed Google Maps. + gmaps_api_key = db.StringProperty(verbose_name=ugettext_lazy('Google Maps')) + gmaps_api_key.help_text = ugettext_lazy( + 'Valid Google Maps API Key. This key is used for ' + 'embedding Google Maps into the website.') diff -r ba3309b2fd30 -r c31cfbf1a20f app/soc/models/site_settings.py --- a/app/soc/models/site_settings.py Fri Nov 21 08:41:23 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +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 SiteSettings Model.""" - -__authors__ = [ - '"Pawel Solyga" ', - '"Lennard de Rijk" ', -] - - -from google.appengine.ext import db - -from django.utils.translation import ugettext_lazy - -import soc.models.home_settings - - -class SiteSettings(soc.models.home_settings.HomeSettings): - """Model of a SiteSettings, which stores per site configuration.""" - - #: Valid Google Analytics tracking number, if entered every page - #: is going to have Google Analytics JS initialization code in - #: the footer with the given tracking number. - ga_tracking_num = db.StringProperty(verbose_name=ugettext_lazy('Google Analytics')) - ga_tracking_num.help_text = ugettext_lazy( - 'Valid Google Analytics tracking number. If the number is ' - 'entered every page is going to have Google Analytics ' - 'initialization code in footer.') - - #: Valid Google Maps API Key. Used to embed Google Maps. - gmaps_api_key = db.StringProperty(verbose_name=ugettext_lazy('Google Maps')) - gmaps_api_key.help_text = ugettext_lazy( - 'Valid Google Maps API Key. This key is used for ' - 'embedding Google Maps into the website.') diff -r ba3309b2fd30 -r c31cfbf1a20f app/soc/templates/soc/base.html --- a/app/soc/templates/soc/base.html Fri Nov 21 08:41:23 2008 +0000 +++ b/app/soc/templates/soc/base.html Fri Nov 21 10:46:15 2008 +0000 @@ -152,7 +152,7 @@