schema.py
changeset 3369 7b88d12b4ee2
parent 3293 69c0ba095536
parent 3347 428f95118556
child 3401 f893f4f199fc
equal deleted inserted replaced
3300:c7c4775a5619 3369:7b88d12b4ee2
   956 # translation
   956 # translation
   957 PERM_USE_TEMPLATE_FORMAT = _('use_template_format')
   957 PERM_USE_TEMPLATE_FORMAT = _('use_template_format')
   958 NEED_PERM_FORMATS = [_('text/cubicweb-page-template')]
   958 NEED_PERM_FORMATS = [_('text/cubicweb-page-template')]
   959 
   959 
   960 @monkeypatch(FormatConstraint)
   960 @monkeypatch(FormatConstraint)
   961 def vocabulary(self, entity=None, req=None):
   961 def vocabulary(self, entity=None, form=None):
   962     if req is None and entity is not None:
   962     req = None
       
   963     if form is None and entity is not None:
   963         req = entity.req
   964         req = entity.req
       
   965     elif form is not None:
       
   966         req = form.req
   964     if req is not None and req.user.has_permission(PERM_USE_TEMPLATE_FORMAT):
   967     if req is not None and req.user.has_permission(PERM_USE_TEMPLATE_FORMAT):
   965         return self.regular_formats + tuple(NEED_PERM_FORMATS)
   968         return self.regular_formats + tuple(NEED_PERM_FORMATS)
   966     return self.regular_formats
   969     return self.regular_formats
   967 
   970 
   968 # XXX monkey patch PyFileReader.import_erschema until bw_normalize_etype is
   971 # XXX monkey patch PyFileReader.import_erschema until bw_normalize_etype is