# HG changeset patch # User Madhusudan.C.S # Date 1253178675 -19800 # Node ID 75f9c945ed8a51dfea88356d52c77ebcbcf069d9 # Parent 0b8b82b6764ee032a3a9c931a4ebd54029b6b859 Added program_logic parameter to checkCanEditTimeline access check and corresponding changes in timeline views. Reviewed by: Lennard de Rijk diff -r 0b8b82b6764e -r 75f9c945ed8a app/soc/modules/ghop/views/models/timeline.py --- a/app/soc/modules/ghop/views/models/timeline.py Thu Sep 17 12:50:14 2009 +0530 +++ b/app/soc/modules/ghop/views/models/timeline.py Thu Sep 17 14:41:15 2009 +0530 @@ -28,7 +28,6 @@ from soc.views.models import timeline from soc.modules.ghop.logic.models import program as ghop_program_logic -from soc.modules.ghop.logic.models import timeline as ghop_timeline_logic from soc.modules.ghop.views.helper import access as ghop_access import soc.modules.ghop.logic.models.timeline @@ -47,8 +46,7 @@ """ rights = ghop_access.GHOPChecker(params) - rights['edit'] = [('checkCanEditTimeline', - [ghop_program_logic.logic, ghop_timeline_logic.logic])] + rights['edit'] = [('checkCanEditTimeline', [ghop_program_logic.logic])] new_params = {} new_params['logic'] = soc.modules.ghop.logic.models.timeline.logic diff -r 0b8b82b6764e -r 75f9c945ed8a app/soc/views/helper/access.py --- a/app/soc/views/helper/access.py Thu Sep 17 12:50:14 2009 +0530 +++ b/app/soc/views/helper/access.py Thu Sep 17 14:41:15 2009 +0530 @@ -1989,19 +1989,18 @@ get_args.setlist('read_access', roles) get_args._mutable = mutable - def checkCanEditTimeline(self, django_args): + def checkCanEditTimeline(self, django_args, program_logic): """Checks whether this program's timeline may be edited. Args: django_args: a dictionary with django's arguments + program_logic: Program Logic instance """ - - time_line_keyname = timeline_logic.getKeyFieldsFromFields(django_args) - timeline_entity = timeline_logic.getFromKeyName(time_line_keyname) - if not timeline_entity: - # timeline does not exists so deny - self.deny(django_args) + time_line_keyname = program_logic.timeline_logic.getKeyNameFromFields( + django_args) + timeline_entity = program_logic.timeline_logic.getFromKeyNameOr404( + time_line_keyname) fields = program_logic.getKeyFieldsFromFields(django_args) self.checkIsHostForProgram(fields) diff -r 0b8b82b6764e -r 75f9c945ed8a app/soc/views/models/timeline.py --- a/app/soc/views/models/timeline.py Thu Sep 17 12:50:14 2009 +0530 +++ b/app/soc/views/models/timeline.py Thu Sep 17 14:41:15 2009 +0530 @@ -50,7 +50,7 @@ """ rights = access.Checker(params) - rights['edit'] = ['checkCanEditTimeline'] + rights['edit'] = [('checkCanEditTimeline', [program_logic.logic])] new_params = {} new_params['rights'] = rights @@ -60,7 +60,7 @@ new_params['name'] = "Timeline" patterns = [(r'^%(url_name)s/(?Pedit)/%(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'] = {