-
-
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
Remove deprecation warnings. #353
Remove deprecation warnings. #353
Conversation
I refactored some usages of deprecated functions that were used, and I removed a lot of deprecated functions entirely. I also removed the @deprecated warnings from the workflow functions in content/* as I know we will remember to remove them when we merge the workflow branch!
7166608
to
334d860
Compare
issue #341 |
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.
Don't be afraid of too many comments. Three important things:
- comment re
sortable_title
inbika/lims/browser/worksheet/workflow.py
Remove deprecation warnings. #353 (comment) - comment re
bika/lims/browser/referenceanalysis.py
Remove deprecation warnings. #353 (comment) - Since you've changed the indexes from analysis catalog, this PR requires an upgrade step. ;)
@@ -43,8 +43,8 @@ def __init__(self, context, request): | |||
|
|||
self.columns = {'Analysis': {'title': _('Analysis'), | |||
'index': 'sortable_title'}, | |||
'RequestID': {'title': _('Request ID'), | |||
'index': 'getRequestID'}, | |||
'getRequestID': {'title': _('Request ID'), |
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.
Heads up!! this is a column name!. Don't think is necessary to change it.
@@ -59,7 +59,7 @@ def __init__(self, context, request): | |||
'title': _('All'), | |||
'contentFilter':{}, | |||
'columns':['Analysis', | |||
'RequestID', | |||
'getRequestID', |
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.
Column name!
items[x]['RequestID'] = '' | ||
items[x]['replace']['RequestID'] = "<a href='%s'>%s</a>" % \ | ||
items[x]['getRequestID'] = '' | ||
items[x]['replace']['getRequestID'] = "<a href='%s'>%s</a>" % \ |
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.
Column name in both cases!
@@ -37,7 +37,7 @@ def __call__(self): | |||
getPointOfCapture=poc, | |||
sort_on='title', | |||
show_categories=show_cats, | |||
getAnalysisRequestUID=ar.UID()) | |||
getRequestUID=ar.UID()) |
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.
Wait, getRequestUID
is used in AnalysesView
as a content filter key-value: https://github.com/senaite/bika.lims/blob/senaite-integration/bika/lims/browser/analyses.py#L45
But there is no index getRequestUID
in bika_analysis_catalog
. Keep the old one getAnalysisRequestUID
instead: https://github.com/senaite/bika.lims/blob/senaite-integration/bika/lims/catalog/analysis_catalog.py#L26
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.
Please note there is an index getRequestID
though (note ID
not UID
): https://github.com/senaite/bika.lims/blob/senaite-integration/bika/lims/catalog/analysis_catalog.py#L36 .... ummm.... mental note for future @xispa we need to avoid missunderstandings here and better to only have two indexes with the same pattern getRequestUID
+ getRequestID
instead of getAnalysisRequestUID
+ getRequestID
.... confusing story
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.
Forget about this... I've seen now you already changed the index names in catalog.
@@ -1265,7 +1264,7 @@ def _analyses_data(self, ar, analysis_states=None): | |||
showhidden = self.isHiddenAnalysesVisible() | |||
|
|||
catalog = get_tool(CATALOG_ANALYSIS_LISTING) | |||
brains = catalog({'getAnalysisRequestUID': ar.UID(), | |||
brains = catalog({'getRequestUID': ar.UID(), |
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.
There is no index getRequestUID
in bika_analysis_catalog
. Keep the old one getAnalysisRequestUID
instead: https://github.com/senaite/bika.lims/blob/senaite-integration/bika/lims/catalog/analysis_catalog.py#L26
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.
Please note there is an index getRequestID
though (note ID
not UID
): https://github.com/senaite/bika.lims/blob/senaite-integration/bika/lims/catalog/analysis_catalog.py#L36 .... ummm.... mental note for future @xispa we need to avoid missunderstandings here and better to only have two indexes with the same pattern getRequestUID
+ getRequestID
instead of getAnalysisRequestUID
+ getRequestID
.... confusing story
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.
Forget about this... I've seen now you already changed the index names in catalog.
item['ar_id'] = an.aq_parent.getRequestID() | ||
item['ar'] = an.getRequest() | ||
item['ar_url'] = an.getRequest().absolute_url() | ||
item['ar_id'] = an.getRequest().getId() |
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 think would be better like this:
if IRequestAnalysis.providedBy(an):
ar = an.getRequest()
item['ar'] = ar
item['ar_url'] = ar.absolute_url()
item['ar_id'] = ar.getId()
Otherwise, duplicate analyses will not be considered
@@ -30,7 +30,7 @@ def __init__(self, context, request): | |||
'toggle': True}, | |||
'samplingRoundTemplate': {'title': _('Sampling Round Template'), | |||
'toggle': True}, | |||
'getRequestID': {'title': _('Request ID'), | |||
'getId': {'title': _('Request ID'), |
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.
A column name again... but seems ok to me
bika/lims/browser/worksheet/ajax.py
Outdated
elif analysis.portal_type == 'ReferenceAnalysis': | ||
if review_state not in attachable_states: | ||
continue | ||
parent = analysis.aq_parent.Title() | ||
else: | ||
raise RuntimeError("Requires Duplicate/Analysis/Reference") |
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.
Is ok, but now you are here... all this loop full of ifelses can be simplified a lot:
for analysis in analyses:
review_state = workflow.getCurrentState(analysis)
if review_state not in attachable_states:
continue
parent = analysis.getParentTitle()
...
'replace_url': 'getAnalysisRequestURL', | ||
'index': 'getRequestID'}, | ||
'attr': 'getId', | ||
'replace_url': 'getRequestURL', |
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 see getAnalysisRequetURL
is labelled as deprecated here https://github.com/senaite/bika.lims/blob/senaite-integration/bika/lims/content/abstractroutineanalysis.py#L338 in favour of getRequestURL
https://github.com/senaite/bika.lims/blob/senaite-integration/bika/lims/content/abstractroutineanalysis.py#L174 , but in the catalog, the metadata column is still getAnalysisRequestURL
https://github.com/senaite/bika.lims/blob/senaite-integration/bika/lims/catalog/analysis_catalog.py#L65 . As per the same reason discussed above (re UID vs ID), I think that indeed, is better to be coherent everywhere, so I'd use getRequestURL
instead of getAnalysisRequestURL
in the catalog
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.
Forget about this... I've seen now you already changed the index names in catalog.
@@ -109,7 +109,7 @@ def __call__(self): | |||
# consistent with the order of the ARs | |||
catalog = get_tool(CATALOG_ANALYSIS_LISTING) | |||
brains = catalog({'UID': analysis_uids, | |||
'sort_on': 'getRequestID'}) | |||
'sort_on': 'sortable_title'}) |
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.
Wrong. this should be getRequestID
. Otherwise, the manage_results view from worksheet will appear wrong, like described in #302 . We only sort analyses here for adding them in the worksheet, not for displaying them in a list.
The reason is that we need the Analyses to be sorted in AR blocks (cause there is some logic there that mix them otherwise). Also AR slots need to be sorted with the same natural order as were registered.
I refactored some usages of deprecated functions that were used,
and I removed a lot of deprecated functions entirely.
I also removed the @deprecated warnings from the workflow functions
in content/* as I know we will remember to remove them when we merge
the workflow branch!