Added program_logic parameter to checkCanEditTimeline access check and corresponding changes in timeline views.
authorMadhusudan.C.S <madhusudancs@gmail.com>
Thu, 17 Sep 2009 14:41:15 +0530
changeset 2936 75f9c945ed8a
parent 2935 0b8b82b6764e
child 2937 2252dc0be5db
Added program_logic parameter to checkCanEditTimeline access check and corresponding changes in timeline views. Reviewed by: Lennard de Rijk
app/soc/modules/ghop/views/models/timeline.py
app/soc/views/helper/access.py
app/soc/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
--- 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)
--- 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/(?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'] = {