Commit ab687aaf authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

Skip intermediary SEDAContent entity

In SEDA 2.1, only one Content node is permitted per archive unit (2.0 allow
multiple ones). This allows to skip the SEDAContent entity in our model and to
attach all its children to its parent
(SEDASeqAltArchiveUnitArchiveUnitRefIdManagement).

This patch replaces occurences of SEDAContent/seda_content and should have test
to green but there is still some work to do on the UI side.

Related to #16684017
parent 5afe55a39449
......@@ -138,19 +138,6 @@ class SEDAAltArchiveUnitArchiveUnitRefId(generated.SEDAAltArchiveUnitArchiveUnit
class SEDASeqAltArchiveUnitArchiveUnitRefIdManagement(
generated.SEDASeqAltArchiveUnitArchiveUnitRefIdManagement):
@property
def contents(self):
return self.reverse_seda_content
class SEDAContent(generated.SEDAContent):
def dc_title(self):
seda_descr_lvl = self.seda_description_level
title = (seda_descr_lvl[0].label() if seda_descr_lvl
else self._cw._('<no description level specified>'))
return u'{0} ({1})'.format(title, self.title.title or self._cw._('<no title specified>'))
@property
def title(self):
return self.reverse_seda_title[0]
......
# copyright 2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# copyright 2016-2017 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr -- mailto:contact@logilab.fr
#
# This program is free software: you can redistribute it and/or modify it under
......@@ -378,11 +378,6 @@ class SEDANeedReassessingAuthorization(SEDAAnyEntity):
fetch_attrs, cw_fetch_order = fetch_config(['user_cardinality', 'need_reassessing_authorization', 'user_annotation'])
value_attr = 'need_reassessing_authorization'
class SEDAContent(SEDAAnyEntity):
__regid__ = 'SEDAContent'
fetch_attrs, cw_fetch_order = fetch_config(['user_cardinality'])
value_attr = None
class SEDADataObjectReference(SEDAAnyEntity):
__regid__ = 'SEDADataObjectReference'
fetch_attrs, cw_fetch_order = fetch_config(['user_cardinality'])
......
......@@ -77,7 +77,7 @@ class ITreeBaseArchiveUnitAdapter(IContainedToITreeBase):
__select__ = is_instance('SEDAArchiveUnit')
_children_relations = [('seda_content', 'object'), ('seda_archive_unit', 'object')]
_children_relations = [('seda_archive_unit', 'object')]
def parent(self):
parent = self.entity.cw_adapt_to('IContained').parent
......@@ -116,15 +116,6 @@ class ITreeBaseSimplifiedArchiveUnitAdapter(ITreeBaseArchiveUnitAdapter):
yield do
class ITreeBaseContentAdapter(IContainedToITreeBase):
"""Adapt Content entities to ITreeBase."""
__select__ = is_instance('SEDAContent')
def parent(self):
return parent_archive_unit(self.entity.cw_adapt_to('IContained').parent)
class ITreeBaseDataObjectAdapter(IContainedToITreeBase):
"""Adapt BinaryDataObject and PhysicalDataObject entities to ITreeBase."""
......
......@@ -1041,8 +1041,7 @@ class SEDA1XSDExport(SEDA2XSDExport):
data_object.eid, data_object.container[0].eid, references))
seq = references[0]
self.element_schema(parent, 'Type', 'qdt:CodeDocumentType',
fixed_value=_safe_concept_value(seq.contents[0].type,
self.concepts_language),
fixed_value=_safe_concept_value(seq.type, self.concepts_language),
xsd_attributes=[LIST_VERSION_ID_2009])
system_id_tag_name = 'ArchivalAgencyDocumentIdentifier'
......@@ -1124,9 +1123,6 @@ class SEDA1XSDExport(SEDA2XSDExport):
def xsd_content_description(self, parent, content):
"""Append XSD elements for a description content to the given parent node"""
cd_node = self.element_schema(parent, 'ContentDescription',
# XXX should always be 1
# cardinality=content.user_cardinality,
documentation=content.user_annotation,
xsd_attributes=[XAttr('Id', 'xsd:ID')])
self.xsd_description_level(cd_node, content.description_level_concept)
self.xsd_language(cd_node, content)
......@@ -1255,7 +1251,7 @@ class SEDA1XSDExport(SEDA2XSDExport):
def archive_unit_name(self, archive_unit):
seq = archive_unit.first_level_choice.content_sequence
return seq.contents[0].title
return seq.title
def archive_unit_appraisal_rule(self, archive_unit):
for rule_holder in climb_rule_holders(archive_unit):
......@@ -1270,12 +1266,11 @@ class SEDA1XSDExport(SEDA2XSDExport):
return text_type(agency.agency.eid) if agency and agency.agency else None
def archive_unit_content(self, archive_unit):
seq = archive_unit.first_level_choice.content_sequence
return seq.contents[0]
return archive_unit.first_level_choice.content_sequence
def system_id(self, data_object):
return (data_object.cw_adapt_to('ITreeBase').parent().first_level_choice.content_sequence
.contents[0].system_id)
.system_id)
@staticmethod
def cwuri_url(entity):
......@@ -1359,7 +1354,6 @@ class SEDA02XSDExport(SEDA1XSDExport):
def xsd_content_description(self, parent, content):
"""Append XSD elements for a description content to the given parent node"""
cd_node = self.element_schema(parent, 'ContentDescription',
documentation=content.user_annotation,
xsd_attributes=[XAttr('Id', 'xsd:ID')])
self.xsd_custodial_history(cd_node, content)
self.xsd_language(cd_node, content)
......
......@@ -120,8 +120,8 @@ class CheckRefNonRuleIdCodeListOp(hook.LateOperation):
{role_name('seda_ref_non_rule_id_to', 'subject'): msg})
class EnsureArchiveUnitHasAContentOp(hook.DataOperationMixIn, hook.Operation):
"""Make sure that a SEDAArchiveUnit has at least one related SEDAContent."""
class EnsureArchiveUnitHasATitleOp(hook.DataOperationMixIn, hook.Operation):
"""Make sure that a SEDAArchiveUnit has a title."""
def precommit_event(self):
for entity in self.get_data():
......@@ -130,21 +130,20 @@ class EnsureArchiveUnitHasAContentOp(hook.DataOperationMixIn, hook.Operation):
if seq is None:
# 'reference' archive unit
continue
if seq.reverse_seda_content:
# content is already set
if seq.reverse_seda_title:
# title is already set
continue
content = self.cnx.create_entity('SEDAContent', seda_content=seq)
self.cnx.create_entity('SEDATitle', seda_title=content)
self.cnx.create_entity('SEDATitle', seda_title=seq)
class EnsureArchiveUnitHasAContentHook(hook.Hook):
"""Make sure that a SEDAArchiveUnit has at least one related SEDAContent."""
"""Hook triggering an operation that will make sure that a SEDAArchiveUnit has a title."""
__regid__ = 'seda.archive-unit.ensure-content'
__select__ = hook.Hook.__select__ & is_instance('SEDAArchiveUnit')
events = ('before_add_entity', 'before_update_entity')
def __call__(self):
EnsureArchiveUnitHasAContentOp.get_instance(self._cw).add_data(self.entity)
EnsureArchiveUnitHasATitleOp.get_instance(self._cw).add_data(self.entity)
class EnsureChoiceNotEmptyOp(hook.DataOperationMixIn, hook.Operation):
......
This diff is collapsed.
This diff is collapsed.
from cubicweb.schema import META_RTYPES
scheme = cnx.find('ConceptScheme', title=u'SEDA : Niveaux de description').one()
for concept in scheme.reverse_in_scheme:
seda_label = concept.labels['seda']
......@@ -19,3 +21,22 @@ commit()
for etype in ('SEDAArchiveUnit', 'SEDABinaryDataObject', 'SEDAPhysicalDataObject'):
drop_attribute(etype, 'id')
sync_schema_props_perms((etype, 'user_annotation', 'String'))
SKIP_RTYPES = set(('seda_content', 'container')) | META_RTYPES
for rschema, targets, role in schema.eschema('SEDAContent').relation_definitions():
if rschema.type in SKIP_RTYPES:
continue
for target in targets:
if role == 'subject':
add_relation_definition('SEDASeqAltArchiveUnitArchiveUnitRefIdManagement',
rschema.type, target)
else:
add_relation_definition(target, rschema.type,
'SEDASeqAltArchiveUnitArchiveUnitRefIdManagement')
with cnx.deny_all_hooks_but():
if role == 'subject':
rql('SET SEQ {0} X WHERE C seda_content SEQ, C {0} X'.format(rschema))
else:
rql('SET X {0} SEQ WHERE C seda_content SEQ, X {0} C'.format(rschema))
commit()
drop_entity_type('SEDAContent')
This diff is collapsed.
......@@ -92,23 +92,24 @@ class CompatAnalyzerTC(CubicWebTC):
user_cardinality=u'1',
seda_start_date=access_rule_seq)
content = create('SEDAContent', seda_content=unit_alt_seq)
create('SEDATitle', seda_title=content)
history_item = create('SEDACustodialHistoryItem', seda_custodial_history_item=content)
create('SEDATitle', seda_title=unit_alt_seq)
history_item = create('SEDACustodialHistoryItem',
seda_custodial_history_item=unit_alt_seq)
doctor = transfer.cw_adapt_to('ISEDACompatAnalyzer')
cnx.commit()
self.assertDiagnostic(doctor, ['SEDA 2.0', 'SEDA 1.0', 'SEDA 0.2', 'simplified'])
history_item2 = create('SEDACustodialHistoryItem', seda_custodial_history_item=content)
content.cw_clear_all_caches()
history_item2 = create('SEDACustodialHistoryItem',
seda_custodial_history_item=unit_alt_seq)
unit_alt_seq.cw_clear_all_caches()
cnx.commit()
self.assertDiagnostic(doctor, ['SEDA 2.0', 'SEDA 1.0', 'simplified'],
'seda02_custodial_history_items')
history_item2.cw_delete()
create('SEDAwhen', seda_when=history_item)
content.cw_clear_all_caches()
unit_alt_seq.cw_clear_all_caches()
history_item.cw_clear_all_caches()
cnx.commit()
self.assertDiagnostic(doctor, ['SEDA 2.0', 'SEDA 1.0', 'simplified'],
......
# copyright 2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# copyright 2016-2017 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr -- mailto:contact@logilab.fr
#
# This program is free software: you can redistribute it and/or modify it under
......@@ -177,12 +177,11 @@ class ITreeTC(CubicWebTC):
bdo = create_data_object(transfer,
reverse_seda_data_object_reference_id=do_ref)
cnx.commit()
content = seq.reverse_seda_content[0]
au.cw_clear_all_caches()
bdo.cw_clear_all_caches()
self.assertChildren(transfer, [bdo.eid, au.eid])
self.assertChildren(au, [content.eid])
self.assertChildren(au, [])
self.assertParent(transfer, None)
self.assertParent(au, transfer.eid)
self.assertParent(bdo, transfer.eid)
......
......@@ -61,32 +61,25 @@ class ValidationHooksTC(CubicWebTC):
class ArchiveUnitContentTC(CubicWebTC):
"""Test case checking hook creating SEDAContent after SEDAArchiveUnit."""
"""Test case checking hook creating title for SEDAArchiveUnit."""
def test_content_created(self):
"""Check that a SEDAContent entity is created when an empty ArchiveUnit is created."""
"""Check that a title entity is created when an empty ArchiveUnit is created."""
with self.admin_access.client_cnx() as cnx:
transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
au, alt, seq = create_archive_unit(transfer)
cnx.commit()
# Check that a SEDAContent and its title have been created
self.assertTrue(au.first_level_choice.content_sequence.reverse_seda_content)
content = au.first_level_choice.content_sequence.reverse_seda_content[0]
self.assertTrue(content.reverse_seda_title)
self.assertTrue(au.first_level_choice.content_sequence.reverse_seda_title)
def test_no_new_content_create(self):
"""Check that a SEDAContent entity is not created when an ArchiveUnit with one is created.
"""Check that a title entity is not created when an ArchiveUnit with one is created.
"""
with self.admin_access.client_cnx() as cnx:
transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
au, alt, seq = create_archive_unit(transfer)
content = cnx.create_entity('SEDAContent', seda_content=seq)
cnx.create_entity('SEDATitle', seda_title=content)
cnx.create_entity('SEDATitle', seda_title=seq)
cnx.commit()
# Check that no new SEDAContent has been created
self.assertEqual(len(au.first_level_choice.content_sequence.reverse_seda_content), 1)
related_content = au.first_level_choice.content_sequence.reverse_seda_content[0]
self.assertEqual(related_content.eid, content.eid)
self.assertEqual(len(seq.reverse_seda_title), 1)
def test_archive_unit_deletion(self):
"""Check that hook does nothing when an ArchiveUnit is deleted.
......@@ -94,8 +87,7 @@ class ArchiveUnitContentTC(CubicWebTC):
with self.admin_access.client_cnx() as cnx:
transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
au, alt, seq = create_archive_unit(transfer)
content = cnx.create_entity('SEDAContent', seda_content=seq)
cnx.create_entity('SEDATitle', seda_title=content)
cnx.create_entity('SEDATitle', seda_title=seq)
cnx.commit()
# Check that everything goes fine when the hook is called
au.cw_delete()
......@@ -199,9 +191,8 @@ class SetDefaultHooksTC(CubicWebTC):
with self.admin_access.client_cnx() as cnx:
transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
unit, unit_alt, unit_alt_seq = create_archive_unit(transfer)
content = cnx.create_entity('SEDAContent', seda_content=unit_alt_seq)
cnx.create_entity('SEDATitle', seda_title=content)
version_of = cnx.create_entity('SEDAIsVersionOf', seda_is_version_of=content)
cnx.create_entity('SEDATitle', seda_title=unit_alt_seq)
version_of = cnx.create_entity('SEDAIsVersionOf', seda_is_version_of=unit_alt_seq)
alt2 = cnx.create_entity('SEDAAltIsVersionOfArchiveUnitRefId',
reverse_seda_alt_is_version_of_archive_unit_ref_id=version_of)
do_ref = cnx.create_entity('SEDADataObjectReference', seda_data_object_reference=alt2)
......
......@@ -293,14 +293,14 @@ class PathTargetValuesTC(CubicWebTC):
element_defs = iter(XSDMMapping('Content'))
with self.admin_access.client_cnx() as cnx:
create = cnx.create_entity
content = create('SEDAContent')
content = create('SEDASeqAltArchiveUnitArchiveUnitRefIdManagement')
restr_value = create('SEDArestrictionValue', seda_restriction_value=content)
restr_end_date = create('SEDArestrictionEndDate', seda_restriction_end_date=content)
edef = next(element_defs)
# readable_edef(edef)
# ('Content',
# 'SEDAContent',
# 'SEDASeqAltArchiveUnitArchiveUnitRefIdManagement',
# [('id', [('seda_id', 'object', 'SEDAid'), ('id', 'subject', 'String')]),
# ('href',
# [('seda_href', 'object', 'SEDAhref'), ('href', 'subject', 'String')]),
......@@ -447,8 +447,8 @@ class SEDA2ExportTCMixIn(object):
transfer = create('SEDAArchiveTransfer', title=u'test profile')
unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(
transfer, user_cardinality=u'0..n')
content = create('SEDAContent', seda_content=unit_alt_seq)
kw = create('SEDAKeyword', seda_keyword=content)
kw = create('SEDAKeyword', seda_keyword=unit_alt_seq)
create('SEDAKeywordContent', reverse_seda_keyword_content=kw,
keyword_content=u'kwick')
kwr_e = create('SEDAKeywordReference', seda_keyword_reference_from=kw)
......@@ -593,8 +593,7 @@ class SEDA2RNGExportTC(SEDA2ExportTCMixIn, RelaxNGTestMixin, CubicWebTC):
transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(
transfer, user_cardinality=u'0..n')
content = cnx.create_entity('SEDAContent', seda_content=unit_alt_seq)
cnx.create_entity('SEDATitle', seda_title=content)
cnx.create_entity('SEDATitle', seda_title=unit_alt_seq)
profile = self.profile_etree(transfer)
title = self.get_element(profile, 'Title')
self.assertEqual(len(self.xpath(title, 'rng:data')), 1)
......@@ -638,27 +637,27 @@ class SEDAExportFuncTCMixIn(object):
create('SEDAReuseRule', seda_reuse_rule=unit_alt_seq)
create('SEDANeedAuthorization', seda_need_authorization=unit_alt_seq)
# content
content = create('SEDAContent', seda_content=unit_alt_seq)
kw = create('SEDAKeyword', user_cardinality=u'0..n', seda_keyword=content)
kw = create('SEDAKeyword', user_cardinality=u'0..n', seda_keyword=unit_alt_seq)
create('SEDAKeywordType', seda_keyword_type_from=kw)
create('SEDAKeywordReference', seda_keyword_reference_from=kw)
create('SEDAKeywordContent', reverse_seda_keyword_content=kw)
history_item = create('SEDACustodialHistoryItem', seda_custodial_history_item=content)
history_item = create('SEDACustodialHistoryItem',
seda_custodial_history_item=unit_alt_seq)
create('SEDAwhen', seda_when=history_item)
version_of = create('SEDAIsVersionOf', seda_is_version_of=content)
version_of = create('SEDAIsVersionOf', seda_is_version_of=unit_alt_seq)
alt2 = create('SEDAAltIsVersionOfArchiveUnitRefId',
reverse_seda_alt_is_version_of_archive_unit_ref_id=version_of)
create('SEDADataObjectReference', seda_data_object_reference=alt2)
create('SEDAOriginatingAgencyArchiveUnitIdentifier',
seda_originating_agency_archive_unit_identifier=content)
seda_originating_agency_archive_unit_identifier=unit_alt_seq)
create('SEDATransferringAgencyArchiveUnitIdentifier',
seda_transferring_agency_archive_unit_identifier=content)
create('SEDATitle', seda_title=content)
create('SEDADescription', seda_description=content)
create('SEDALanguage', seda_language_from=content)
create('SEDADescriptionLanguage', seda_description_language_from=content)
create('SEDACreatedDate', seda_created_date=content)
create('SEDAEndDate', seda_end_date=content)
seda_transferring_agency_archive_unit_identifier=unit_alt_seq)
create('SEDATitle', seda_title=unit_alt_seq)
create('SEDADescription', seda_description=unit_alt_seq)
create('SEDALanguage', seda_language_from=unit_alt_seq)
create('SEDADescriptionLanguage', seda_description_language_from=unit_alt_seq)
create('SEDACreatedDate', seda_created_date=unit_alt_seq)
create('SEDAEndDate', seda_end_date=unit_alt_seq)
create('SEDADataObjectReference', user_cardinality=u'0..n',
seda_data_object_reference=unit_alt_seq,
seda_data_object_reference_id=bdo)
......@@ -787,20 +786,17 @@ class OldSEDAExportMixin(object):
_, _, unit_alt_seq = testutils.create_archive_unit(transfer,
user_cardinality=u'1..n')
content = create('SEDAContent',
user_cardinality=u'1',
seda_content=unit_alt_seq,
seda_description_level=concepts['file'],
reverse_seda_start_date=create('SEDAStartDate',
user_cardinality=u'0..1'),
reverse_seda_end_date=create('SEDAEndDate'),
# XXX, value=date(2015, 2, 24)),
reverse_seda_description=create('SEDADescription'))
create('SEDATitle', seda_title=content)
unit_alt_seq.cw_set(seda_description_level=concepts['file'],
reverse_seda_start_date=create('SEDAStartDate',
user_cardinality=u'0..1'),
reverse_seda_end_date=create('SEDAEndDate'),
# XXX, value=date(2015, 2, 24)),
reverse_seda_description=create('SEDADescription'))
create('SEDATitle', seda_title=unit_alt_seq)
kw = create('SEDAKeyword',
user_cardinality=u'0..n',
seda_keyword=content,
seda_keyword=unit_alt_seq,
seda_keyword_content=create('SEDAKeywordContent')) # XXX
create('SEDAKeywordReference',
seda_keyword_reference_from=kw,
......@@ -810,20 +806,19 @@ class OldSEDAExportMixin(object):
seda_keyword_type_from=kw,
user_cardinality=u'0..1')
create('SEDAOriginatingAgency', seda_originating_agency_from=content,
create('SEDAOriginatingAgency', seda_originating_agency_from=unit_alt_seq,
seda_originating_agency_to=agent)
create('SEDAType', seda_type_from=content,
create('SEDAType', seda_type_from=unit_alt_seq,
seda_type_to=concepts['CDO'])
create('SEDACustodialHistoryItem', seda_custodial_history_item=content,
create('SEDACustodialHistoryItem', seda_custodial_history_item=unit_alt_seq,
reverse_seda_when=create('SEDAwhen'))
# Add sub archive unit
_, _, subunit_alt_seq = testutils.create_archive_unit(unit_alt_seq,
user_cardinality=u'1..n')
content = create('SEDAContent', seda_content=subunit_alt_seq)
create('SEDATitle', seda_title=content)
create('SEDATitle', seda_title=subunit_alt_seq)
create('SEDAAppraisalRule',
seda_appraisal_rule=subunit_alt_seq,
......@@ -856,8 +851,7 @@ class OldSEDAExportMixin(object):
# Add another sub archive unit
_, _, subunit2_alt_seq = testutils.create_archive_unit(unit_alt_seq,
user_cardinality=u'1..n')
content = create('SEDAContent', seda_content=subunit2_alt_seq)
create('SEDATitle', seda_title=content)
create('SEDATitle', seda_title=subunit2_alt_seq)
cnx.commit()
......@@ -933,13 +927,12 @@ class OldSEDARNGExportTC(RelaxNGTestMixin, OldSEDAExportMixin, CubicWebTC):
create('SEDAComment', seda_comment=transfer)
unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(transfer)
content = create('SEDAContent', seda_content=unit_alt_seq)
create('SEDATitle', seda_title=content)
create('SEDATitle', seda_title=unit_alt_seq)
create('SEDAArchivalAgreement', seda_archival_agreement=transfer)
create('SEDATransferringAgencyArchiveUnitIdentifier',
seda_transferring_agency_archive_unit_identifier=content)
create('SEDAStartDate', seda_start_date=content)
create('SEDAEndDate', seda_end_date=content)
seda_transferring_agency_archive_unit_identifier=unit_alt_seq)
create('SEDAStartDate', seda_start_date=unit_alt_seq)
create('SEDAEndDate', seda_end_date=unit_alt_seq)
appraisal_rule = create('SEDAAppraisalRule', seda_appraisal_rule=unit_alt_seq)
appraisal_rule_seq = create('SEDASeqAppraisalRuleRule',
reverse_seda_seq_appraisal_rule_rule=appraisal_rule)
......@@ -951,17 +944,16 @@ class OldSEDARNGExportTC(RelaxNGTestMixin, OldSEDAExportMixin, CubicWebTC):
subunit, subunit_alt, subunit_alt_seq = testutils.create_archive_unit(
unit_alt_seq)
subcontent = create('SEDAContent', seda_content=subunit_alt_seq)
create('SEDATitle', seda_title=subcontent)
create('SEDATitle', seda_title=subunit_alt_seq)
create('SEDATransferringAgencyArchiveUnitIdentifier',
seda_transferring_agency_archive_unit_identifier=subcontent)
create('SEDAStartDate', seda_start_date=subcontent)
create('SEDAEndDate', seda_end_date=subcontent)
kw = create('SEDAKeyword', user_cardinality=u'0..n', seda_keyword=subcontent)
seda_transferring_agency_archive_unit_identifier=subunit_alt_seq)
create('SEDAStartDate', seda_start_date=subunit_alt_seq)
create('SEDAEndDate', seda_end_date=subunit_alt_seq)
kw = create('SEDAKeyword', user_cardinality=u'0..n', seda_keyword=subunit_alt_seq)
create('SEDAKeywordContent', reverse_seda_keyword_content=kw)
create('SEDAKeywordReference', seda_keyword_reference_from=kw)
create('SEDASystemId', seda_system_id=subcontent)
create('SEDASystemId', seda_system_id=subunit_alt_seq)
bdo = testutils.create_data_object(transfer)
create('SEDADataObjectReference',
......
......@@ -166,7 +166,8 @@ class SchemaTC(CubicWebTC):
rqlexpr, = [p for p in rdef.permissions[action] if isinstance(p, RRQLExpression)]
self.assertEqual(rqlexpr.expression, 'U has_update_permission O')
# Parent is contained in container
rdef = self.schema['seda_tag'].rdef('SEDATag', 'SEDAContent')
rdef = self.schema['seda_tag'].rdef('SEDATag',
'SEDASeqAltArchiveUnitArchiveUnitRefIdManagement')
rqlexpr, = [p for p in rdef.permissions[action] if isinstance(p, RRQLExpression)]
self.assertEqual(rqlexpr.expression, 'U has_update_permission C, O container C')
# Parent is subject
......@@ -219,8 +220,7 @@ class SchemaTC(CubicWebTC):
with self.admin_access.client_cnx() as cnx:
transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'Profile')
unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(transfer)
content = cnx.create_entity('SEDAContent', seda_content=unit_alt_seq)
cnx.create_entity('SEDATitle', seda_title=content, title=u'transfer name'[::-1])
cnx.create_entity('SEDATitle', seda_title=unit_alt_seq, title=u'transfer name'[::-1])
cnx.create_entity('SEDAAccessRule', seda_access_rule=unit_alt_seq,
user_annotation=u'some annotation'[::-1])
testutils.create_data_object(transfer, filename=u'fixed.txt'[::-1])
......@@ -296,8 +296,7 @@ class SecurityTC(CubicWebTC):
def test_archive_unit(self):
with self.admin_access.repo_cnx() as cnx:
unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(None, cnx=cnx)
content = cnx.create_entity('SEDAContent', seda_content=unit_alt_seq)
title = cnx.create_entity('SEDATitle', seda_title=content)
title = cnx.create_entity('SEDATitle', seda_title=unit_alt_seq)
cnx.commit()
# unit has no parent, modifications are allowed.
......@@ -313,9 +312,7 @@ class SecurityTC(CubicWebTC):
with self.assertUnauthorized(cnx):
unit.cw_set(user_annotation=u'zorglub')
with self.assertUnauthorized(cnx):
cnx.create_entity(
'SEDATitle', seda_title=cnx.create_entity(
'SEDAContent', seda_content=unit_alt_seq))
cnx.create_entity('SEDATitle', seda_title=unit_alt_seq)
with self.assertUnauthorized(cnx):
title.cw_delete()
with self.assertUnauthorized(cnx):
......
......@@ -218,7 +218,7 @@ class XSIterateTC(unittest.TestCase):
readable_edef(seq_edef),
('Sequence', 'SEDASeqAltArchiveUnitArchiveUnitRefIdManagement', [
('Management', []),
('Content', [('seda_content', 'object', 'SEDAContent')]),
('Content', []),
('ArchiveUnit', [('seda_archive_unit', 'object', 'SEDAArchiveUnit')]),
('DataObjectReference',
[('seda_data_object_reference', 'object', 'SEDADataObjectReference')])
......
......@@ -29,6 +29,9 @@ from ..xsd2uicfg import FIRST_LEVEL_ETYPES
from .widgets import SEDAMetaField
CONTENT_ETYPE = 'SEDASeqAltArchiveUnitArchiveUnitRefIdManagement'
pvs = cwuicfg.primaryview_section
afs = cwuicfg.autoform_section
aff = cwuicfg.autoform_field
......
......@@ -17,7 +17,7 @@
from six import text_type
from logilab.common.registry import objectify_predicate, yes
from logilab.common.registry import objectify_predicate
from cubicweb import tags, _
from cubicweb.predicates import is_instance
......@@ -29,7 +29,7 @@ from cubes.relationwidget import views as rwdg
from ..entities import simplified_profile, parent_and_container
from ..entities.itree import parent_archive_unit
from . import (add_subobject_link, add_subobjects_button, dropdown_button,
from . import (CONTENT_ETYPE, add_subobject_link, add_subobjects_button, dropdown_button,
rtags_from_rtype_role_targets, copy_rtag, has_rel_perm)
from . import clone, viewlib, widgets, content
from . import uicfg as sedauicfg # noqa - ensure those rules are defined first
......@@ -172,18 +172,6 @@ class RefArchiveUnitSimpleLinkToEntityAttributeView(EntityView):
w=self.w)
class TitleBusinessValueEntityView(viewlib.BusinessValueEntityView):
"""Entity view for SEDAContent entities that will display value of the SEDATitle related
element.
"""
# add yes(1) to overtake BusinessValueLinkEntityView
__select__ = is_instance('SEDAContent') & yes(1)
no_value_msg = _('<no title specified>')
def entity_value(self, entity):
return tags.a(entity.dc_title(), href=entity.absolute_url())
class ArchiveUnitManagementTab(viewlib.PrimaryTabWithoutBoxes):
"""Display management information about an archive unit."""
......@@ -242,41 +230,24 @@ class ArchiveUnitSubObjectsTab(viewlib.SubObjectsTab):
return parent_archive_unit(entity)
class ArchiveUnitContentTab(ArchiveUnitSubObjectsTab):
"""Display content information about an archive unit."""
__regid__ = 'seda_au_content_tab'
rtype_role_targets = [('seda_content', 'object', None)]
_('creating SEDAContent (SEDAContent seda_content '
'SEDASeqAltArchiveUnitArchiveUnitRefIdManagement %(linkto)s)')
def display_subobjects_list(self, entity):
rset = entity.related('seda_content', 'object')
self._cw.view('list', rset=rset, parent=self.parent(entity), w=self.w,
subvid=self.subvid, tabid=self.__regid__, delete=len(rset) > 1)