-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework SIP Package generation and download #5837
Changes from all commits
d3a4d65
17380d7
7fff73d
4ca9c5f
4843692
1da11eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
from Acquisition import aq_parent | ||
from collective import dexteritytextindexer | ||
from datetime import date | ||
from DateTime import DateTime | ||
from opengever.activity import notification_center | ||
from opengever.activity.roles import DISPOSITION_ARCHIVIST_ROLE | ||
from opengever.activity.roles import DISPOSITION_RECORDS_MANAGER_ROLE | ||
|
@@ -11,31 +12,39 @@ | |
from opengever.base.source import SolrObjPathSourceBinder | ||
from opengever.disposition import _ | ||
from opengever.disposition.appraisal import IAppraisal | ||
from opengever.disposition.ech0160.sippackage import SIPPackage | ||
from opengever.disposition.interfaces import IDisposition | ||
from opengever.disposition.interfaces import IDuringDossierDestruction | ||
from opengever.disposition.interfaces import IHistoryStorage | ||
from opengever.dossier.base import DOSSIER_STATES_OFFERABLE | ||
from opengever.dossier.behaviors.dossier import IDossier | ||
from opengever.ogds.base.utils import get_current_admin_unit | ||
from opengever.ogds.base.utils import ogds_service | ||
from path import Path | ||
from persistent.dict import PersistentDict | ||
from persistent.list import PersistentList | ||
from plone import api | ||
from plone.autoform.directives import write_permission | ||
from plone.dexterity.content import Container | ||
from plone.namedfile.file import NamedBlobFile | ||
from plone.supermodel import model | ||
from pyxb.utils.domutils import BindingDOMSupport | ||
from tempfile import TemporaryFile | ||
from z3c.relationfield.schema import RelationChoice | ||
from z3c.relationfield.schema import RelationList | ||
from zExceptions import Unauthorized | ||
from zipfile import ZIP_DEFLATED | ||
from zipfile import ZipFile | ||
from zope import schema | ||
from zope.annotation import IAnnotations | ||
from zope.annotation.interfaces import IAnnotations | ||
from zope.component import getUtility | ||
from zope.globalrequest import getRequest | ||
from zope.i18n import translate | ||
from zope.interface import alsoProvides | ||
from zope.interface import implements | ||
from zope.intid.interfaces import IIntIds | ||
|
||
import os | ||
|
||
DESTROY_PERMISSION = 'opengever.dossier: Destroy dossier' | ||
|
||
|
@@ -293,3 +302,38 @@ def get_all_archivists(self): | |
archivists.append(principal) | ||
|
||
return archivists | ||
|
||
def store_sip_package(self): | ||
self._sip_package = self.generate_sip_package() | ||
|
||
def remove_sip_package(self): | ||
self._sip_package = None | ||
|
||
def generate_sip_package(self): | ||
package = SIPPackage(self) | ||
zip_file = self.create_zipfile(package) | ||
zip_file.seek(0) | ||
return NamedBlobFile(zip_file.read(), contentType='application/zip') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you could pass a reference to the file instead of reading the file into memory yourself. That triggers an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not found a way to pass in a file in to a NamedBlobFile, we would need to register a IStorage Adapter for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as discussed today, if it does not work by default i'm ok with not changing the current implementation 👍. |
||
|
||
def create_zipfile(self, package): | ||
tmpfile = TemporaryFile() | ||
BindingDOMSupport.SetDefaultNamespace(u'http://bar.admin.ch/arelda/v4') | ||
with ZipFile(tmpfile, 'w', ZIP_DEFLATED, True) as zipfile: | ||
package.write_to_zipfile(zipfile) | ||
|
||
return tmpfile | ||
|
||
def has_sip_package(self): | ||
return bool(self.get_sip_package()) | ||
|
||
def get_sip_package(self): | ||
return getattr(self, '_sip_package', None) | ||
|
||
def get_sip_name(self): | ||
name = u'SIP_{}_{}'.format( | ||
DateTime().strftime('%Y%m%d'), | ||
api.portal.get().getId().upper()) | ||
if self.transfer_number: | ||
name = u'{}_{}'.format(name, self.transfer_number) | ||
|
||
return name |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"POT-Creation-Date: 2018-03-19 12:59+0000\n" | ||
"POT-Creation-Date: 2019-07-25 14:32+0000\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
|
@@ -273,6 +273,16 @@ msgstr "Angebot abgelehnt durch ${user}" | |
msgid "msg_disposition_updated" | ||
msgstr "Aktualisiert durch ${user}" | ||
|
||
#. Default: "No SIP Package generated for this disposition." | ||
#: ./opengever/disposition/browser/ech0160.py | ||
msgid "msg_no_sip_package_generated" | ||
msgstr "Es wurde noch kein SIP Paket generiert für dieses Angebot." | ||
|
||
#. Default: "SIP Package generated successfully." | ||
#: ./opengever/disposition/browser/ech0160.py | ||
msgid "msg_sip_package_sucessfully_generated" | ||
msgstr "SIP Paket erfolgreich generiert." | ||
|
||
#. Default: "Period" | ||
#: ./opengever/disposition/browser/templates/overview.pt | ||
msgid "period" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"POT-Creation-Date: 2018-03-19 12:59+0000\n" | ||
"POT-Creation-Date: 2019-07-25 14:32+0000\n" | ||
"PO-Revision-Date: 2018-05-22 10:09+0000\n" | ||
"Last-Translator: Niklaus Johner <[email protected]>\n" | ||
"Language-Team: French <https://translations.onegovgever.ch/projects/onegov-" | ||
"gever/opengever-disposition/fr/>\n" | ||
"Language: fr\n" | ||
"Language-Team: French <https://translations.onegovgever.ch/projects/onegov-gever/opengever-disposition/fr/>\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=utf-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: nplurals=2; plural=n > 1;\n" | ||
"X-Generator: Weblate 2.13.1\n" | ||
"Language-Code: en\n" | ||
"Language-Name: English\n" | ||
"Preferred-Encodings: utf-8 latin1\n" | ||
"Domain: DOMAIN\n" | ||
"Language: fr\n" | ||
"X-Generator: Weblate 2.13.1\n" | ||
|
||
#: ./opengever/disposition/browser/excel_export.py | ||
msgid "The report could not been generated." | ||
|
@@ -276,6 +275,16 @@ msgstr "Offre refusée par ${user}" | |
msgid "msg_disposition_updated" | ||
msgstr "Actualisé par ${user}" | ||
|
||
#. Default: "No SIP Package generated for this disposition." | ||
#: ./opengever/disposition/browser/ech0160.py | ||
msgid "msg_no_sip_package_generated" | ||
msgstr "" | ||
|
||
#. Default: "SIP Package generated successfully." | ||
#: ./opengever/disposition/browser/ech0160.py | ||
msgid "msg_sip_package_sucessfully_generated" | ||
msgstr "" | ||
|
||
#. Default: "Period" | ||
#: ./opengever/disposition/browser/templates/overview.pt | ||
msgid "period" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"POT-Creation-Date: 2018-03-19 12:59+0000\n" | ||
"POT-Creation-Date: 2019-07-25 14:32+0000\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
|
@@ -276,6 +276,16 @@ msgstr "" | |
msgid "msg_disposition_updated" | ||
msgstr "" | ||
|
||
#. Default: "No SIP Package generated for this disposition." | ||
#: ./opengever/disposition/browser/ech0160.py | ||
msgid "msg_no_sip_package_generated" | ||
msgstr "" | ||
|
||
#. Default: "SIP Package generated successfully." | ||
#: ./opengever/disposition/browser/ech0160.py | ||
msgid "msg_sip_package_sucessfully_generated" | ||
msgstr "" | ||
|
||
#. Default: "Period" | ||
#: ./opengever/disposition/browser/templates/overview.pt | ||
msgid "period" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This view will respond to a
GET
request. do you see a way to create a form which only responds to an i.e.POST
, as it will modify data in the database.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do the maintenance-actions as discussed in a separate PR, I added a checkbox to the Main Issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have added a checkbox to the main issue in #5167.