Add prefix filtering and refactored program field generation
Patch by: Sverre Rabbelier
--- a/app/soc/views/models/club.py Fri Feb 13 21:52:38 2009 +0000
+++ b/app/soc/views/models/club.py Fri Feb 13 21:53:15 2009 +0000
@@ -75,6 +75,7 @@
new_params['rights'] = rights
new_params['name'] = "Club"
new_params['url_name'] = "club"
+ new_params['document_prefix'] = "club"
new_params['sidebar_grouping'] = 'Clubs'
patterns = []
--- a/app/soc/views/models/organization.py Fri Feb 13 21:52:38 2009 +0000
+++ b/app/soc/views/models/organization.py Fri Feb 13 21:53:15 2009 +0000
@@ -76,6 +76,7 @@
new_params['name'] = "Organization"
new_params['url_name'] = "org"
+ new_params['document_prefix'] = "org"
new_params['sidebar_grouping'] = 'Organizations'
new_params['public_template'] = 'soc/organization/public.html'
--- a/app/soc/views/models/presence.py Fri Feb 13 21:52:38 2009 +0000
+++ b/app/soc/views/models/presence.py Fri Feb 13 21:53:15 2009 +0000
@@ -49,7 +49,7 @@
"""View methods for the Presence model.
"""
- def __init__(self, params=None):
+ def __init__(self, params):
"""Defines the fields and methods required for the base View class
to provide the user with list, public, create, edit and delete views.
@@ -75,6 +75,7 @@
new_params['edit_extra_dynafields'] = {
'home_link_id': widgets.ReferenceField(
reference_url='document', filter=['scope_path'],
+ filter_fields={'prefix': params['document_prefix']},
required=False, label=ugettext('Home page Document link ID'),
help_text=soc.models.work.Work.link_id.help_text),
}
--- a/app/soc/views/models/presence_with_tos.py Fri Feb 13 21:52:38 2009 +0000
+++ b/app/soc/views/models/presence_with_tos.py Fri Feb 13 21:53:15 2009 +0000
@@ -40,7 +40,7 @@
"""View methods for the PresenceWithToS model.
"""
- def __init__(self, params=None):
+ def __init__(self, params):
"""Defines the fields and methods required for the base View class
to provide the user with list, public, create, edit and delete views.
@@ -55,8 +55,9 @@
new_params['edit_extra_dynafields'] = {
'tos_link_id': widgets.ReferenceField(
- reference_url='document', filter=['scope_path'],
- required=False, label=ugettext('Terms of Service Document link ID'),
+ reference_url='document', filter=['scope_path'], required=False,
+ filter_fields={'prefix': params['document_prefix']},
+ label=ugettext('Terms of Service Document link ID'),
help_text=soc.models.work.Work.link_id.help_text),
}
--- a/app/soc/views/models/program.py Fri Feb 13 21:52:38 2009 +0000
+++ b/app/soc/views/models/program.py Fri Feb 13 21:53:15 2009 +0000
@@ -74,6 +74,8 @@
new_params['name'] = "Program"
new_params['sidebar_grouping'] = 'Programs'
+ new_params['document_prefix'] = "program"
+
new_params['extra_dynaexclude'] = ['timeline', 'org_admin_agreement',
'mentor_agreement', 'student_agreement']
@@ -87,31 +89,32 @@
('ghop','Task-based')], required=True),
}
- new_params['edit_extra_dynafields'] = {
- 'workflow': forms.CharField(widget=widgets.ReadOnlyInput(),
- required=True),
- 'org_admin_agreement_link_id': widgets.ReferenceField(
- reference_url='document', filter=['__scoped__'],
- required=False, label=ugettext(
- 'Organization Admin Agreement Document link ID'),
- help_text=soc.models.work.Work.link_id.help_text),
- 'mentor_agreement_link_id': widgets.ReferenceField(
- reference_url='document', filter=['__scoped__'],
- required=False, label=ugettext('Mentor Agreement Document link ID'),
- help_text=soc.models.work.Work.link_id.help_text),
- 'student_agreement_link_id': widgets.ReferenceField(
- reference_url='document', filter=['__scoped__'],
- required=False, label=ugettext('Student Agreement Document link ID'),
- help_text=soc.models.work.Work.link_id.help_text),
- 'home_link_id': widgets.ReferenceField(
- reference_url='document', filter=['__scoped__'],
- 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', filter=['__scoped__'],
- required=False, label=ugettext('Terms of Service Document link ID'),
- help_text=soc.models.work.Work.link_id.help_text),
- }
+ reference_fields = [
+ ('org_admin_agreement_link_id', soc.models.work.Work.link_id.help_text,
+ ugettext('Organization Admin Agreement Document link ID')),
+ ('mentor_agreement_link_id', soc.models.work.Work.link_id.help_text,
+ ugettext('Mentor Agreement Document link ID')),
+ ('student_agreement_link_id', soc.models.work.Work.link_id.help_text,
+ ugettext('Student Agreement Document link ID')),
+ ('home_link_id', soc.models.work.Work.link_id.help_text,
+ ugettext('Home page Document link ID')),
+ ('tos_link_id', soc.models.work.Work.link_id.help_text,
+ ugettext('Terms of Service Document link ID'))
+ ]
+
+ result = {}
+
+ for key, help_text, label in reference_fields:
+ result[key] = widgets.ReferenceField(
+ reference_url='document', filter=['__scoped__'],
+ filter_fields={'prefix': new_params['document_prefix']},
+ required=False, label=label, help_text=help_text)
+
+ result['workflow'] = forms.CharField(widget=widgets.ReadOnlyInput(),
+ required=True)
+
+ new_params['edit_extra_dynafields'] = result
+
references = [
('org_admin_agreement_link_id', 'org_admin_agreement', document_logic,
--- a/app/soc/views/models/site.py Fri Feb 13 21:52:38 2009 +0000
+++ b/app/soc/views/models/site.py Fri Feb 13 21:53:15 2009 +0000
@@ -61,6 +61,7 @@
new_params['name'] = "Site Settings"
new_params['name_plural'] = new_params['name']
+ new_params['document_prefix'] = 'site'
new_params['name_short'] = "Site"
new_params['sidebar_defaults'] = [('/%s/edit', 'Edit %(name)s', 'edit')]
@@ -75,12 +76,14 @@
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'),
+ reference_url='document', required=False,
+ filter_fields={'prefix': new_params['document_prefix']},
+ 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'),
+ reference_url='document', required=False,
+ filter_fields={'prefix': new_params['document_prefix']},
+ label=ugettext('Terms of Service Document link ID'),
help_text=soc.models.work.Work.link_id.help_text),
}
--- a/app/soc/views/models/sponsor.py Fri Feb 13 21:52:38 2009 +0000
+++ b/app/soc/views/models/sponsor.py Fri Feb 13 21:53:15 2009 +0000
@@ -64,6 +64,7 @@
new_params['name'] = "Program Owner"
new_params['module_name'] = "sponsor"
+ new_params['document_prefix'] = "sponsor"
new_params['sidebar_grouping'] = 'Programs'
params = dicts.merge(params, new_params)