251 'metadata', 'hidden'), |
251 'metadata', 'hidden'), |
252 'inlined': ('attributes', 'hidden'), |
252 'inlined': ('attributes', 'hidden'), |
253 'muledit': ('attributes', 'hidden'), |
253 'muledit': ('attributes', 'hidden'), |
254 } |
254 } |
255 |
255 |
|
256 def init(self, schema, check=True): |
|
257 super(AutoformSectionRelationTags, self).init(schema, check) |
|
258 self.apply(schema, self._initfunc_step2) |
|
259 |
256 @staticmethod |
260 @staticmethod |
257 def _initfunc(self, sschema, rschema, oschema, role): |
261 def _initfunc(self, sschema, rschema, oschema, role): |
258 formsections = self.init_get(sschema, rschema, oschema, role) |
262 formsections = self.init_get(sschema, rschema, oschema, role) |
259 if formsections is None: |
263 if formsections is None: |
260 formsections = self.tag_container_cls() |
264 formsections = self.tag_container_cls() |
|
265 if not any(tag.startswith('inlined') for tag in formsections): |
|
266 if not rschema.final: |
|
267 negsects = self.init_get(sschema, rschema, oschema, neg_role(role)) |
|
268 if 'main_inlined' in negsects: |
|
269 formsections.add('inlined_hidden') |
|
270 key = _ensure_str_key( (sschema, rschema, oschema, role) ) |
|
271 self._tagdefs[key] = formsections |
|
272 |
|
273 @staticmethod |
|
274 def _initfunc_step2(self, sschema, rschema, oschema, role): |
|
275 formsections = self.get(sschema, rschema, oschema, role) |
261 sectdict = _formsections_as_dict(formsections) |
276 sectdict = _formsections_as_dict(formsections) |
262 if rschema in META_RTYPES: |
277 if rschema in META_RTYPES: |
263 sectdict.setdefault('main', 'hidden') |
278 sectdict.setdefault('main', 'hidden') |
264 sectdict.setdefault('muledit', 'hidden') |
279 sectdict.setdefault('muledit', 'hidden') |
265 sectdict.setdefault('inlined', 'hidden') |
280 sectdict.setdefault('inlined', 'hidden') |
287 if sectdict['main'] == 'attributes': |
302 if sectdict['main'] == 'attributes': |
288 card, composed = _card_and_comp(sschema, rschema, oschema, role) |
303 card, composed = _card_and_comp(sschema, rschema, oschema, role) |
289 if card in '1+' and not composed: |
304 if card in '1+' and not composed: |
290 sectdict['muledit'] = 'attributes' |
305 sectdict['muledit'] = 'attributes' |
291 if not 'inlined' in sectdict: |
306 if not 'inlined' in sectdict: |
292 sectdict['inlined'] = 'hidden' |
307 sectdict['inlined'] = sectdict['main'] |
293 # recompute formsections and set it to avoid recomputing |
308 # recompute formsections and set it to avoid recomputing |
294 for formtype, section in sectdict.iteritems(): |
309 for formtype, section in sectdict.iteritems(): |
295 formsections.add('%s_%s' % (formtype, section)) |
310 formsections.add('%s_%s' % (formtype, section)) |
296 key = _ensure_str_key( (sschema, rschema, oschema, role) ) |
|
297 self._tagdefs[key] = formsections |
|
298 |
311 |
299 def tag_relation(self, key, formtype, section=None): |
312 def tag_relation(self, key, formtype, section=None): |
300 if section is None: |
313 if section is None: |
301 tag = formtype |
314 tag = formtype |
302 for formtype, section in self.bw_tag_map[tag].iteritems(): |
315 for formtype, section in self.bw_tag_map[tag].iteritems(): |