Always return a site singleton and fix Edit Site Settings
Patch by: Sverre Rabbelier
--- a/app/soc/logic/models/site.py Sat Feb 07 20:37:28 2009 +0000
+++ b/app/soc/logic/models/site.py Sat Feb 07 20:39:08 2009 +0000
@@ -83,7 +83,13 @@
'link_id': self.DEF_SITE_LINK_ID,
}
- return self.getFromKeyFields(fields)
+ key_name = self.getKeyNameFromFields(fields)
+ singleton = self.getFromKeyName(key_name)
+ # if there is no site singleton yet, create it
+ if not singleton:
+ singleton = self.updateOrCreateFromKeyName(fields, key_name)
+
+ return singleton
logic = Logic()
--- a/app/soc/views/models/site.py Sat Feb 07 20:37:28 2009 +0000
+++ b/app/soc/views/models/site.py Sat Feb 07 20:39:08 2009 +0000
@@ -23,11 +23,13 @@
from django import forms
+from django.utils.translation import ugettext
from soc.logic import accounts
from soc.logic import dicts
from soc.views.helper import access
from soc.views.helper import redirects
+from soc.views.helper import widgets
from soc.views.models import document as document_view
from soc.views.models import presence_with_tos
@@ -70,7 +72,17 @@
new_params['create_extra_dynafields'] = {
'link_id': forms.CharField(widget=forms.HiddenInput, required=True),
}
- new_params['edit_dynafields'] = []
+ new_params['edit_extra_dynafields'] = {
+ 'link_id': forms.CharField(widget=forms.HiddenInput, required=True),
+ 'home_link_id': widgets.ReferenceField(
+ reference_url='document',
+ required=False, label=ugettext('Home page Document link ID'),
+ help_text=soc.models.work.Work.link_id.help_text),
+ 'tos_link_id': widgets.ReferenceField(
+ reference_url='document',
+ required=False, label=ugettext('Terms of Service Document link ID'),
+ help_text=soc.models.work.Work.link_id.help_text),
+ }
patterns = []