equal
deleted
inserted
replaced
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 |