-
-
Notifications
You must be signed in to change notification settings - Fork 152
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
Improved Email Publication #1413
Merged
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
6f8fc56
Better translation string
ramonski d4dab25
Publish samples first
ramonski 1ea4a8d
Refactored to properties
ramonski c97aca9
Use email API to send email
ramonski cea5233
Refactored to properties
ramonski 89b0600
Make send toggle editable
ramonski 39ccd66
Moved property up
ramonski 41aac28
Added plone.protect
ramonski eee4741
Refcatored emailview to use email API and improved logic
ramonski 7f8818b
Fixed doctests
ramonski 25ce7bd
Make analyses attachments addable to email
ramonski 4376d80
Lookup max email size from registry
ramonski 78d6098
Better icons for metadata + sendlog
ramonski 9fca018
Formatting and comments
ramonski 08974c4
Changelog updated
ramonski 8cf4f31
Disable xvflb start to fix travis CI
ramonski 46fb4d2
Handle unicode in email addresses
ramonski 57cb2a6
Added icons for ARReport
ramonski b5b4944
Manually take a snapshot instead of calling processForm
ramonski fcc20fa
Publish the primary sample first in case the contained samples was no…
ramonski 7c1b69c
Comments only
ramonski 52035bb
Show the logline independently from other metadata
ramonski f52943d
Keep track of the Email text on submission
ramonski 2b9a4c3
Merge branch 'master' into emailview2
ramonski f6f507b
Added info popup for reports
ramonski dbedebb
Make sendlog a records field
ramonski 5f84825
Remove inline auditlog
ramonski 02c46a7
Handle sendlog records in info popup
ramonski 48b2945
Show send history in info popup
ramonski b9fc473
minor changes
ramonski 515e706
Changed Actor to "Sender"
ramonski 20fc972
Formatting only
ramonski eb78771
Removed form authenticator
ramonski ed10e4d
Use security API to get the current user and userid
ramonski 7c2df67
Handle deleted Attachments
ramonski 93c301c
Added UID as image title
ramonski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ Changelog | |
|
||
**Changed** | ||
|
||
- #1413 Improved Email Publication | ||
|
||
|
||
**Removed** | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This file is part of SENAITE.CORE. | ||
# | ||
# SENAITE.CORE is free software: you can redistribute it and/or modify it under | ||
# the terms of the GNU General Public License as published by the Free Software | ||
# Foundation, version 2. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
# details. | ||
# | ||
# You should have received a copy of the GNU General Public License along with | ||
# this program; if not, write to the Free Software Foundation, Inc., 51 | ||
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
# | ||
# Copyright 2018-2019 by it's authors. | ||
# Some rights reserved, see README and LICENSE. | ||
|
||
from bika.lims import api | ||
from bika.lims.browser import BrowserView | ||
from bika.lims.utils import get_image | ||
from plone.memoize import view | ||
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile | ||
from ZODB.POSException import POSKeyError | ||
|
||
|
||
class AnalysisReportInfoView(BrowserView): | ||
"""Show details of the Analysis Report | ||
""" | ||
template = ViewPageTemplateFile("templates/analysisreport_info.pt") | ||
|
||
def __init__(self, context, request): | ||
super(AnalysisReportInfoView, self).__init__(context, request) | ||
|
||
def __call__(self): | ||
# disable the editable border | ||
self.request.set("disable_border", 1) | ||
return self.template() | ||
|
||
@view.memoize | ||
def get_report(self): | ||
report_uid = self.request.form.get("report_uid") | ||
return api.get_object_by_uid(report_uid, None) | ||
|
||
@view.memoize | ||
def get_primary_sample(self): | ||
report = self.get_report() | ||
return report.getAnalysisRequest() | ||
|
||
@view.memoize | ||
def get_metadata(self): | ||
report = self.get_report() | ||
return report.getMetadata() | ||
|
||
@view.memoize | ||
def get_sendlog(self): | ||
report = self.get_report() | ||
records = report.getSendLog() | ||
return list(reversed(records)) | ||
|
||
@view.memoize | ||
def get_contained_samples(self): | ||
metadata = self.get_metadata() | ||
samples = metadata.get("contained_requests", []) | ||
sample_uids = filter(api.is_uid, samples) | ||
return map(api.get_object_by_uid, sample_uids) | ||
|
||
def get_icon_for(self, typename): | ||
"""Returns the big image icon by its (type-)name | ||
""" | ||
image = "{}_big.png".format(typename) | ||
return get_image( | ||
image, width="20px", style="vertical-align: baseline;") | ||
|
||
def get_filesize(self, f): | ||
"""Return the filesize of the PDF as a float | ||
""" | ||
try: | ||
filesize = float(f.get_size()) | ||
return float("%.2f" % (filesize / 1024)) | ||
except (POSKeyError, TypeError, AttributeError): | ||
return 0.0 | ||
|
||
@view.memoize | ||
def get_attachment_data_by_uid(self, uid): | ||
"""Retrieve attachment data by UID | ||
""" | ||
attachment = api.get_object_by_uid(uid, default=None) | ||
# Attachment file not found/deleted | ||
if attachment is None: | ||
return {} | ||
f = attachment.getAttachmentFile() | ||
attachment_type = attachment.getAttachmentType() | ||
attachment_keys = attachment.getAttachmentKeys() | ||
filename = f.filename | ||
filesize = self.get_filesize(f) | ||
mimetype = f.getContentType() | ||
report_option = attachment.getReportOption() | ||
|
||
return { | ||
"obj": attachment, | ||
"attachment_type": attachment_type, | ||
"attachment_keys": attachment_keys, | ||
"file": f, | ||
"uid": uid, | ||
"filesize": filesize, | ||
"filename": filename, | ||
"mimetype": mimetype, | ||
"report_option": report_option, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<configure | ||
xmlns="http://namespaces.zope.org/zope" | ||
xmlns:browser="http://namespaces.zope.org/browser" | ||
xmlns:i18n="http://namespaces.zope.org/i18n" | ||
i18n_domain="senaite.core"> | ||
|
||
<!-- Analysis Report Info View | ||
(used in report listings for Popup Overlays) --> | ||
<browser:page | ||
for="*" | ||
name="analysisreport_info" | ||
class="bika.lims.browser.analysisreport.AnalysisReportInfoView" | ||
permission="zope.Public" | ||
layer="bika.lims.interfaces.IBikaLIMS" | ||
/> | ||
|
||
</configure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 would do
elif
here