115 for name, util in registry.getUtilitiesFor(IParagraphFactory)], |
115 for name, util in registry.getUtilitiesFor(IParagraphFactory)], |
116 key=lambda x: x.title) |
116 key=lambda x: x.title) |
117 super(ParagraphFactoriesVocabulary, self).__init__(terms) |
117 super(ParagraphFactoriesVocabulary, self).__init__(terms) |
118 |
118 |
119 |
119 |
|
120 @vocabulary_config(name='PyAMS content paragraphs') |
|
121 class ContentParagraphsVocabulary(SimpleVocabulary): |
|
122 """Content paragraphs vocabulary""" |
|
123 |
|
124 def __init__(self, context): |
|
125 request = check_request() |
|
126 if not IParagraphContainerTarget.providedBy(context): |
|
127 context = get_parent(context, IParagraphContainerTarget) |
|
128 if context is not None: |
|
129 terms = [SimpleTerm(para.__name__, |
|
130 title='ยง{0}: {1}'.format(index+1, |
|
131 II18n(para).query_attribute('title', request=request) or |
|
132 '----')) |
|
133 for index, para in enumerate(IParagraphContainer(context).values())] |
|
134 else: |
|
135 terms = [] |
|
136 super(ContentParagraphsVocabulary, self).__init__(terms) |
|
137 |
|
138 |
120 @adapter_config(context=IBaseParagraph, provides=IFormContextPermissionChecker) |
139 @adapter_config(context=IBaseParagraph, provides=IFormContextPermissionChecker) |
121 class BaseParagraphPermissionChecker(ContextAdapter): |
140 class BaseParagraphPermissionChecker(ContextAdapter): |
122 """Paragraph permission checker""" |
141 """Paragraph permission checker""" |
123 |
142 |
124 @property |
143 @property |