Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Changelog
[sgeulette]
- Used session from imio.esign.
[sgeulette]
- Added 'imio.annex' and iconified categories to dms files and dms appendix files.
[chris-adam]

3.0 (2021-09-30)
----------------
Expand Down
112 changes: 105 additions & 7 deletions imio/dms/mail/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from collective.dms.mailcontent.dmsmail import internalReferenceOutgoingMailDefaultValue
from collective.dms.mailcontent.dmsmail import mailDateDefaultValue
from collective.dms.mailcontent.dmsmail import receptionDateDefaultValue
from collective.iconifiedcategory.utils import calculate_category_id
from DateTime.DateTime import DateTime
from imio.dms.mail import _tr as _
from imio.dms.mail import BLDT_DIR
Expand Down Expand Up @@ -98,8 +99,10 @@ def add_test_annexes_types(context):
site = context.getSite()
logger.info("Adding annexes types")
ccc = site["annexes_types"]

# Content Category Group for classification folders
if "annexes" not in ccc:
category_group = api.content.create(
annexes_category_group = api.content.create(
type="ContentCategoryGroup",
title="Annexes",
container=ccc,
Expand All @@ -108,10 +111,11 @@ def add_test_annexes_types(context):
# to_be_printed_activated=True,
# signed_activated=True,
# publishable_activated=True,
# approved_activated=True,
)
do_transitions(category_group, ["show_internally"])
do_transitions(annexes_category_group, ["show_internally"])
else:
category_group = ccc["annexes"]
annexes_category_group = ccc["annexes"]
icats = (
("annex", u"Annexe", u"attach.png", True),
("deliberation", u"Délibération", u"deliberation_signed.png", True),
Expand All @@ -129,7 +133,92 @@ def add_test_annexes_types(context):
type="ContentCategory",
title=title,
description=u"",
container=category_group,
container=annexes_category_group,
icon=icon,
id=oid,
predefined_title=title,
# confidential=True,
# to_print=True,
# to_sign=True,
# signed=True,
# publishable=True,
# only_pdf=True,
show_preview=show_pv,
)

# Content Category Group for dms main files and dms appendix files
if "signable_files" not in ccc:
signable_files_category_group = api.content.create(
type="ContentCategoryGroup",
title="Fichiers signables",
container=ccc,
id="signable_files",
# confidentiality_activated=True,
to_be_printed_activated=True,
signed_activated=True,
# publishable_activated=True,
approved_activated=True,
)
do_transitions(signable_files_category_group, ["show_internally"])
else:
signable_files_category_group = ccc["signable_files"]
icats = (
("signable-ged-file", u"Fichier signable", u"attach.png", True),
)
for oid, title, img, show_pv in icats:
if oid in ccc["signable_files"]:
continue
icon_path = os.path.join(context._profile_path, "images", img)
with open(icon_path, "rb") as fl:
icon = NamedBlobImage(fl.read(), filename=img)
api.content.create(
type="ContentCategory",
title=title,
description=u"",
container=signable_files_category_group,
icon=icon,
id=oid,
predefined_title=title,
# confidential=True,
# to_print=True,
# to_sign=True,
# signed=True,
# publishable=True,
# only_pdf=True,
# approved=False,
show_preview=show_pv,
)

# Content Category Group for dms main files and dms appendix files
if "classic_files" not in ccc:
classic_files_category_group = api.content.create(
type="ContentCategoryGroup",
title="Fichiers classiques",
container=ccc,
id="classic_files",
# confidentiality_activated=True,
# to_be_printed_activated=True,
# signed_activated=True,
# publishable_activated=True,
# approved_activated=True,
)
do_transitions(classic_files_category_group, ["show_internally"])
else:
classic_files_category_group = ccc["classic_files"]
icats = (
("classic-ged-file", u"Fichier classique", u"attach.png", True),
)
for oid, title, img, show_pv in icats:
if oid in ccc["classic_files"]:
continue
icon_path = os.path.join(context._profile_path, "images", img)
with open(icon_path, "rb") as fl:
icon = NamedBlobImage(fl.read(), filename=img)
api.content.create(
type="ContentCategory",
title=title,
description=u"",
container=classic_files_category_group,
icon=icon,
id=oid,
predefined_title=title,
Expand All @@ -139,6 +228,7 @@ def add_test_annexes_types(context):
# signed=True,
# publishable=True,
# only_pdf=True,
# approved=False,
show_preview=show_pv,
)

Expand Down Expand Up @@ -467,6 +557,7 @@ def add_test_mails(context):
file=file_object,
scan_id="0509999000000%02d" % i,
scan_date=scan_date,
content_category=calculate_category_id(api.portal.get()["annexes_types"]["signable_files"]["signable-ged-file"]),
)

# tasks
Expand Down Expand Up @@ -525,7 +616,14 @@ def add_test_mails(context):
filename = next(files_cycle)
with open(u"%s/%s" % (filespath, filename), "rb") as fo:
file_object = NamedBlobFile(fo.read(), filename=filename)
createContentInContainer(mail, "dmsommainfile", id="1", title="", file=file_object)
createContentInContainer(
mail,
"dmsommainfile",
id="1",
title="",
file=file_object,
content_category=calculate_category_id(api.portal.get()["annexes_types"]["signable_files"]["signable-ged-file"]),
)


def add_test_plonegroup_services(context):
Expand Down Expand Up @@ -946,7 +1044,7 @@ def configure_imio_dms_mail(context):
u"transfer_email_pat": u"",
u"original_email_pat": u"",
u"tal_condition_1": u"python: agent_id and 'encodeurs' in modules['imio.dms.mail.utils']."
u"current_user_groups_ids(userid=agent_id)",
u"current_user_groups_ids(userid=agent_id)",
u"user_value": u"_empty_",
u"tal_condition_2": u"",
u"tg_value": u"_empty_",
Expand All @@ -969,7 +1067,7 @@ def configure_imio_dms_mail(context):
u"transfer_email_pat": u"",
u"original_email_pat": u"",
u"tal_condition_1": u"",
u"state_value": u"proposed_to_agent"
u"state_value": u"proposed_to_agent",
},
]

Expand Down
43 changes: 43 additions & 0 deletions imio/dms/mail/migrations/migrate_to_3_1.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
from collective.iconifiedcategory.utils import calculate_category_id
from collective.iconifiedcategory.utils import update_categorized_elements
from collective.messagesviewlet.utils import add_message
from collective.wfadaptations.api import apply_from_registry
from collective.wfadaptations.api import get_applied_adaptations
Expand Down Expand Up @@ -77,6 +79,9 @@ def run(self):
self.runProfileSteps("imio.dms.mail", steps=["catalog", "plone.app.registry"])
load_type_from_package("dmsoutgoingmail", "profile-imio.dms.mail:default") # behavior
load_type_from_package("held_position", "profile-imio.dms.mail:default") # behavior
load_type_from_package("dmsappendixfile", "profile-imio.dms.mail:default") # iconified
load_type_from_package("dmsommainfile", "profile-imio.dms.mail:default") # iconified
self.runProfileSteps('imio.dms.mail', steps=['imiodmsmail-add-test-annexes-types'], profile='examples')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je pense que c'est dupliqué avec mes changements


# Update wf changes
reset = load_workflow_from_package("outgoingmail_workflow", "imio.dms.mail:default")
Expand Down Expand Up @@ -175,6 +180,44 @@ def run(self):
obj = brain._unrestrictedGetObject()
obj.reindexObject(idxs=["markers"])

# imio.annex integration to dms files with iconified category
self.context.runImportStepFromProfile('collective.dms.basecontent:default', 'catalog')
self.context.runImportStepFromProfile('imio.dms.mail:default', 'catalog')
load_type_from_package("dmsmainfile", "imio.dms.mail:default")
load_type_from_package("dmsommainfile", "imio.dms.mail:default")
load_type_from_package("dmsappendixfile", "imio.dms.mail:default")
self.context.runImportStepFromProfile(u'imio.dms.mail:examples', u'imiodmsmail-add-test-annexes-types')
files = self.portal.portal_catalog.unrestrictedSearchResults(portal_type=["dmsmainfile", "dmsommainfile", "dmsappendixfile"])
category = self.portal["annexes_types"]["signable_files"]["signable-ged-file"]
for f in files:
obj = f.getObject()
if not hasattr(obj, "approved"):
obj.approved = False
if not hasattr(obj, "to_print"):
obj.to_print = False
if not hasattr(obj, "content_category"):
obj.content_category = calculate_category_id(category)
update_categorized_elements(obj.aq_parent, obj, category)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Est-ce qu'il me faudrait pas aussi mettre à jour imio.zamqp.dms pour ajouter une catégorie sur les emails entrants ? Et est-ce que ces catégories sont pertinentes sur les courriers entrants ? Si non, est-ce qu'on doit avoir des iconified catégories pour les annexes des courriers sortants mais pas les courriers entrants ?

catalog = self.portal.portal_catalog
indexes = catalog.indexes()
wanted = [
('to_print', 'BooleanIndex'),
('to_be_signed', 'BooleanIndex'),
('signed', 'BooleanIndex'),
('approved', 'BooleanIndex'),
]
added = set()
for name, meta_type in wanted:
if name not in indexes:
catalog.addIndex(name, meta_type)
added.add(name)
if added:
self.reindexIndexes(idxs=list(added),
portal_types=["dmsmainfile", "dmsommainfile", "dmsappendixfile"],
update_metadata=True)

# END

# END

# finished = True # can be eventually returned and set by batched method
Expand Down
3 changes: 3 additions & 0 deletions imio/dms/mail/profiles/default/types/dmsappendixfile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@
<element value="view"/>
<element value="documentviewer"/>
</property>
<property name="behaviors" purge="False">
<element value="collective.iconifiedcategory.behaviors.iconifiedcategorization.IIconifiedCategorization" />
</property>
</object>
5 changes: 3 additions & 2 deletions imio/dms/mail/profiles/default/types/dmsmainfile.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0"?>
<object name="dmsmainfile" meta_type="Dexterity FTI">
<property name="behaviors" purge="False">
<element value="plone.app.lockingbehavior.behaviors.ILocking" />
<element value="collective.dms.scanbehavior.behaviors.behaviors.IScanFields"/>
<element value="collective.dexteritytextindexer.behavior.IDexterityTextIndexer" />
<element value="collective.dms.scanbehavior.behaviors.behaviors.IScanFields" />
<element value="plone.app.content.interfaces.INameFromTitle" />
<element value="plone.app.lockingbehavior.behaviors.ILocking" />
</property>
<property name="default_view">documentviewer</property>
<property name="view_methods">
Expand Down
1 change: 1 addition & 0 deletions imio/dms/mail/profiles/default/types/dmsommainfile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<element value="plone.app.lockingbehavior.behaviors.ILocking" />
<element value="collective.dms.scanbehavior.behaviors.behaviors.IScanFields"/>
<element value="collective.dexteritytextindexer.behavior.IDexterityTextIndexer" />
<element value="collective.iconifiedcategory.behaviors.iconifiedcategorization.IIconifiedCategorization" />
</property>
<property name="schema" />
<!-- DO NOT use a model_source or it removes manually added fields while reapplying the profile -->
Expand Down
11 changes: 11 additions & 0 deletions imio/dms/mail/setuphandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,17 @@ def postInstall(context):
# hide plone.portalheader message viewlet
site.portal_setup.runImportStepFromProfile("profile-plonetheme.imioapps:default", "viewlets")

# Annexes Types
portal = api.portal.get()
if 'annexes_types' not in portal:
api.content.create(
container=portal,
id='annexes_types',
title=_(u"Annexes Types"),
type="ContentCategoryConfiguration",
exclude_from_nav=True
)


def blacklistPortletCategory(obj, category=CONTEXT_CATEGORY, utilityname=u"plone.leftcolumn", value=True):
"""
Expand Down
21 changes: 21 additions & 0 deletions imio/dms/mail/vocabularies.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from collective.contact.plonegroup.utils import get_organizations
from collective.contact.plonegroup.utils import get_person_from_userid
from collective.contact.plonegroup.utils import organizations_with_suffixes
from collective.iconifiedcategory.vocabularies import CategoryVocabulary
from ftw.labels.interfaces import ILabelJar
from imio.dms.mail import _
from imio.dms.mail import _tr
Expand Down Expand Up @@ -710,3 +711,23 @@ def __call__(self, context):
return SimpleVocabulary(
[SimpleTerm("active", title=pmf(u"Active")), SimpleTerm("deactivated", title=pmf(u"Deactivated"))]
)


class DmsFilesCategoryVocabulary(CategoryVocabulary):
""""""

implements(IVocabularyFactory)

def _get_categories(self, context, only_enabled=True):
if context.portal_type in ("dmsmainfile", "dmsommainfile", "dmsappendixfile", "dmsincomingmail", "dmsoutgoingmail"):
catalog = api.portal.get_tool('portal_catalog')
query = {
'object_provides': 'collective.iconifiedcategory.content.category.ICategory',
'enabled': True,
'path': [
'/{}/annexes_types/signable_files'.format(api.portal.get().getId()),
'/{}/annexes_types/classic_files'.format(api.portal.get().getId()),
],
}
return [b.getObject() for b in catalog.unrestrictedSearchResults(**query)]
return super(DmsFilesCategoryVocabulary, self)._get_categories(context, only_enabled)
11 changes: 11 additions & 0 deletions imio/dms/mail/vocabularies.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,15 @@
factory="imio.dms.mail.vocabularies.ActiveInactiveStatesVocabulary"
/>

<unconfigure package="collective.iconifiedcategory">
<utility
name="collective.iconifiedcategory.categories"
provides="zope.schema.interfaces.IVocabularyFactory"
/>
</unconfigure>
<utility
name="collective.iconifiedcategory.categories"
factory="imio.dms.mail.vocabularies.DmsFilesCategoryVocabulary"
/>

</configure>
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"collective.externaleditor",
"collective.fontawesome",
"collective.iconifieddocumentactions",
"collective.iconifiedcategory",
"collective.js.fancytree",
"collective.js.tooltipster",
"collective.messagesviewlet",
Expand Down