Changeset 2515

Show
Ignore:
Timestamp:
07/23/07 14:13:55 (1 year ago)
Author:
ant_39
Message:

CalendarPlugin:

  • First shot on permission handling. Patch by jc at vfnet.de, thanks!
  • Related: #1585
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • calendarplugin/0.10/azcalendar/azcalendar.py

    r2510 r2515  
    2929 
    3030    def get_navigation_items(self, req): 
    31         yield 'mainnav', 'azcalendar', Markup('<a href="%s">Azcalendar</a>', 
    32                 self.env.href.azcalendar()) 
     31        if req.perm.has_permission('CAL_VIEW'): 
     32            yield ('mainnav', 'azcalendar', 
     33                   Markup('<a href="%s">Azcalendar</a>', self.env.href.azcalendar())) 
    3334 
    3435 
     
    3940 
    4041    def process_add(self, req): 
     42        req.perm.assert_permission('CAL_EDIT') 
    4143        add_stylesheet (req, 'hw/css/azcalendar.css') 
    4244 
     
    6365 
    6466    def process_show(self, req): 
     67        req.perm.assert_permission('CAL_VIEW') 
     68 
    6569        def get_week(date): 
    6670            # If there is a simpler way to do this, let me know.  For now... 
     
    8387            return week_start, week_end 
    8488 
    85         def get_month(date): 
     89        def get_month_range(date): 
    8690            d_year, d_month = date[0], date[1] 
    8791            month_start = tuple([d_year, d_month, 1] + [0 for _ in date[3:]]) 
     
    179183 
    180184        display_months = [] 
    181         dm_year, dm_month = get_month (week_start)[0][:2] 
     185        dm_year, dm_month = get_month_range (week_start)[0][:2] 
    182186 
    183187        prev_year, prev_month, prev_day = date[:3] 
     
    196200 
    197201        for i in range(3): 
    198             month_range = get_month (tuple([dm_year, dm_month, 1] + [0 for i in range(6)])) 
     202            month_range = get_month_range (tuple([dm_year, dm_month, 1] + [0 for i in range(6)])) 
    199203            interesting_days = {} 
    200204 
     
    255259 
    256260    def process_delete(self, req): 
     261        req.perm.assert_permission('CAL_ADMIN') 
     262 
    257263        if req.args.has_key('id'): 
    258264            import re 
     
    266272 
    267273    def process_event(self, req): 
     274        req.perm.assert_permission('CAL_VIEW') 
     275 
    268276        add_stylesheet (req, 'hw/css/azcalendar.css') 
    269277        if req.method == 'GET' and req.args.has_key('id'): 
     
    280288 
    281289        elif req.method == 'GET' and req.args.has_key('update_event'): 
     290            req.perm.assert_permission('CAL_EDIT') 
     291 
    282292            begin_time, end_time, begin_stamp, end_stamp \ 
    283293              = caltools.parse_time_begin_end(req.args['time_begin'], req.args['time_end']) 
     
    296306 
    297307        elif req.method == 'GET' and req.args.has_key('delete_event'): 
     308            req.perm.assert_permission('CAL_ADMIN') 
    298309            begin_time, end_time, begin_stamp, end_stamp \ 
    299310              = caltools.parse_time_begin_end(req.args['time_begin'], req.args['time_end']) 
     
    311322 
    312323    def process_request(self, req): 
     324        req.perm.assert_permission('CAL_VIEW') 
     325 
    313326        KEY = "/azcalendar" 
    314327        query = req.path_info[req.path_info.index (KEY):]