Added timeline view for GHOP.
Moved the method _createTimelineForType from Views to Logic for both core
Program and GHOPProgram. Added default values parameter to apps_tasks_limit
and slots in Program model. Registered timeline view for the sitemap in GHOP
callback.py. Added timeline view module and class which overrides the edit
method. Overriding the params['edit_form'] to accommodate dynainclude and
dynaexclude fields.
--- a/app/index.yaml Sat Aug 22 03:56:14 2009 +0530
+++ b/app/index.yaml Sat Aug 22 03:56:25 2009 +0530
@@ -80,3 +80,55 @@
# manually, move them above the marker line. The index.yaml file is
# automatically uploaded to the admin console when you next deploy
# your application using appcfg.py.
+
+# Used 265 times in query history.
+- kind: GHOPComment
+ ancestor: yes
+ properties:
+ - name: created_on
+
+# Used 248 times in query history.
+- kind: GHOPWorkSubmission
+ ancestor: yes
+ properties:
+ - name: submitted_on
+
+# Used 3 times in query history.
+- kind: TaskArbitraryTag
+ properties:
+ - name: scope
+ - name: order
+ direction: desc
+
+# Used 168 times in query history.
+- kind: TaskDifficultyTag
+ properties:
+ - name: scope
+ - name: order
+
+# Used 3 times in query history.
+- kind: TaskDifficultyTag
+ properties:
+ - name: scope
+ - name: order
+ direction: desc
+
+# Used 67 times in query history.
+- kind: TaskTypeTag
+ properties:
+ - name: mandatory
+ - name: scope
+ - name: order
+
+# Used 70 times in query history.
+- kind: TaskTypeTag
+ properties:
+ - name: scope
+ - name: order
+
+# Used 14 times in query history.
+- kind: TaskTypeTag
+ properties:
+ - name: scope
+ - name: order
+ direction: desc
--- a/app/soc/logic/models/program.py Sat Aug 22 03:56:14 2009 +0530
+++ b/app/soc/logic/models/program.py Sat Aug 22 03:56:25 2009 +0530
@@ -46,5 +46,18 @@
super(Logic, self).__init__(model=model, base_model=base_model,
scope_logic=scope_logic)
+ def createTimelineForType(self, fields):
+ """Creates and stores a timeline model for the given type of program.
+ """
+
+ properties = self.timeline_logic.getKeyFieldsFromFields(fields)
+ key_name = self.timeline_logic.getKeyNameFromFields(properties)
+
+ properties['scope'] = fields['scope']
+
+ timeline = self.timeline_logic.updateOrCreateFromKeyName(properties,
+ key_name)
+ return timeline
+
logic = Logic()
--- a/app/soc/models/program.py Sat Aug 22 03:56:14 2009 +0530
+++ b/app/soc/models/program.py Sat Aug 22 03:56:25 2009 +0530
@@ -77,7 +77,7 @@
'<small><i>(rich text formatting is supported)</i></small>')
#: Required field storing application/tasks limit of the program.
- apps_tasks_limit = db.IntegerProperty(required=True,
+ apps_tasks_limit = db.IntegerProperty(required=True, default=20,
verbose_name=ugettext('Application/Tasks Limit'))
apps_tasks_limit.example_text = ugettext(
'<small><i>e.g.</i></small> '
@@ -98,7 +98,7 @@
'The amount of slots each organization should get at most')
#: Required field storing slots limit of the program.
- slots = db.IntegerProperty(required=True,
+ slots = db.IntegerProperty(required=True, default=0,
verbose_name=ugettext('Slots'))
slots.example_text = ugettext(
'<small><i>e.g.</i></small> '
--- a/app/soc/modules/ghop/callback.py Sat Aug 22 03:56:14 2009 +0530
+++ b/app/soc/modules/ghop/callback.py Sat Aug 22 03:56:25 2009 +0530
@@ -22,6 +22,7 @@
from soc.modules.ghop.views.models import program
+from soc.modules.ghop.views.models import timeline
class Callback(object):
@@ -43,6 +44,7 @@
self.core.requireUniqueService('registerWithSitemap')
self.core.registerSitemapEntry(program.view.getDjangoURLPatterns())
+ self.core.registerSitemapEntry(timeline.view.getDjangoURLPatterns())
def registerWithSidebar(self):
"""Called by the server when sidebar entries should be registered.
--- a/app/soc/modules/ghop/logic/models/program.py Sat Aug 22 03:56:14 2009 +0530
+++ b/app/soc/modules/ghop/logic/models/program.py Sat Aug 22 03:56:25 2009 +0530
@@ -41,10 +41,23 @@
"""Defines the name, key_name and model for this entity.
"""
- self.timeline_logic = soc.modules.ghop.logic.models.timeline.logic
-
super(Logic, self).__init__(model, base_model=base_model,
scope_logic=scope_logic)
+ self.timeline_logic = soc.modules.ghop.logic.models.timeline.logic
+
+ def createTimelineForType(self, fields):
+ """Creates and stores a timeline model for the given type of program.
+ """
+
+ properties = self.timeline_logic.getKeyFieldsFromFields(fields)
+ key_name = self.timeline_logic.getKeyNameFromFields(properties)
+
+ properties['scope'] = fields['scope']
+
+ timeline = self.timeline_logic.updateOrCreateFromKeyName(properties,
+ key_name)
+ return timeline
+
logic = Logic()
--- a/app/soc/modules/ghop/views/models/program.py Sat Aug 22 03:56:14 2009 +0530
+++ b/app/soc/modules/ghop/views/models/program.py Sat Aug 22 03:56:25 2009 +0530
@@ -34,6 +34,7 @@
import soc.cache.logic
+from soc.modules.ghop.logic.models import program as ghop_program_logic
import soc.modules.ghop.logic.models.program
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/modules/ghop/views/models/timeline.py Sat Aug 22 03:56:25 2009 +0530
@@ -0,0 +1,91 @@
+#!/usr/bin/python2.5
+#
+# Copyright 2009 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.
+
+"""GHOP specific views for Timeline.
+"""
+
+__authors__ = [
+ '"Madhusudan.C.S" <madhusudancs@gmail.com>'
+ ]
+
+
+from soc.logic import dicts
+from soc.views.helper import decorators
+from soc.views.helper import dynaform
+from soc.views.helper import params as params_helper
+from soc.views.models import timeline
+from soc.views.sitemap import sidebar
+
+import soc.cache.logic
+
+from soc.modules.ghop.logic.models import program as ghop_program_logic
+
+import soc.modules.ghop.logic.models.timeline
+
+
+class View(timeline.View):
+ """View methods for the GHOP Timeline model.
+ """
+
+ def __init__(self, params=None):
+ """Defines the fields and methods required for the program 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.modules.ghop.logic.models.timeline.logic
+
+ new_params['name'] = "GHOP Timeline"
+ new_params['module_name'] = "timeline"
+
+ new_params['module_package'] = 'soc.modules.ghop.views.models'
+ new_params['url_name'] = 'ghop/timeline'
+
+ params = dicts.merge(params, new_params, sub_merge=True)
+
+ super(View, self).__init__(params=params)
+
+ def edit(self, request, access_type,
+ page_name=None, params=None, seed=None, **kwargs):
+ """See base.View.edit.
+ """
+
+ params = dicts.merge(params, self._params)
+
+ key_fields = ghop_program_logic.logic.getKeyFieldsFromFields(kwargs)
+
+ program = ghop_program_logic.logic.getFromKeyFields(key_fields)
+ if program:
+ params['logic'] = ghop_program_logic.logic.timeline_logic
+
+ timeline_model = ghop_program_logic.logic.timeline_logic
+
+ return super(View, self).edit(request, access_type, page_name=page_name,
+ params=params, seed=seed, **kwargs)
+
+
+view = View()
+
+admin = decorators.view(view.admin)
+create = decorators.view(view.create)
+delete = decorators.view(view.delete)
+edit = decorators.view(view.edit)
+list = decorators.view(view.list)
+public = decorators.view(view.public)
+export = decorators.view(view.export)
--- a/app/soc/views/models/program.py Sat Aug 22 03:56:14 2009 +0530
+++ b/app/soc/views/models/program.py Sat Aug 22 03:56:25 2009 +0530
@@ -588,27 +588,11 @@
if not entity:
# there is no existing entity so create a new timeline
- fields['timeline'] = self._createTimelineForType(fields)
+ fields['timeline'] = self._params['logic'].createTimelineForType(fields)
else:
# use the timeline from the entity
fields['timeline'] = entity.timeline
- def _createTimelineForType(self, fields):
- """Creates and stores a timeline model for the given type of program.
- """
-
- workflow = fields['workflow']
-
- timeline_logic = program_logic.logic.TIMELINE_LOGIC[workflow]
-
- properties = timeline_logic.getKeyFieldsFromFields(fields)
- key_name = timeline_logic.getKeyNameFromFields(properties)
-
- properties['scope'] = fields['scope']
-
- timeline = timeline_logic.updateOrCreateFromKeyName(properties, key_name)
- return timeline
-
@decorators.merge_params
def getExtraMenus(self, id, user, params=None):
"""Returns the extra menu's for this view.
--- a/app/soc/views/models/timeline.py Sat Aug 22 03:56:14 2009 +0530
+++ b/app/soc/views/models/timeline.py Sat Aug 22 03:56:25 2009 +0530
@@ -58,7 +58,7 @@
new_params['name'] = "Timeline"
patterns = [(r'^%(url_name)s/(?P<access_type>edit)/%(key_fields)s$',
- 'soc.views.models.%(module_name)s.edit',
+ '%(module_package)s.%(module_name)s.edit',
"Edit %(name_short)s")]
new_params['create_extra_dynaproperties'] = {
@@ -72,16 +72,15 @@
super(View, self).__init__(params=params)
- for name, logic_value in program_logic.logic.TIMELINE_LOGIC.iteritems():
- create_form = params_helper.getCreateForm(self._params,
- logic_value.getModel())
- edit_form = dynaform.extendDynaForm(
- dynaform = create_form,
- dynainclude = self._params['edit_dynainclude'],
- dynaexclude = self._params['edit_dynaexclude'],
- )
+ create_form = params_helper.getCreateForm(self._params,
+ program_logic.logic.timeline_logic.getModel())
+ edit_form = dynaform.extendDynaForm(
+ dynaform = create_form,
+ dynainclude = self._params['edit_dynainclude'],
+ dynaexclude = self._params['edit_dynaexclude'],
+ )
- self._params['edit_form_%s' % name] = edit_form
+ self._params['edit_form'] = edit_form
def edit(self, request, access_type,
page_name=None, params=None, seed=None, **kwargs):
@@ -97,9 +96,7 @@
program = program_logic.logic.getFromKeyFields(key_fields)
if program:
- workflow = program.workflow
- params['edit_form'] = params["edit_form_%s" % workflow]
- params['logic'] = program_logic.logic.TIMELINE_LOGIC[workflow]
+ params['logic'] = program_logic.logic.timeline_logic
return super(View, self).edit(request, access_type, page_name=page_name,
params=params, seed=seed, **kwargs)