-
-
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
Create an Analysis Request from Sample View #594
Conversation
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.
Thanks Pau, I like the idea with the adapter to fetch the default value – nicely decoupled.
I just have some change request according to formatting and PEP8-ing, sorry for being nerving with that, but these small things are important for my little coders heart ;)
def get_sample(self): | ||
""" | ||
Returns the Sample | ||
""" |
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 know, it might sound pedantic, but stick to the same docstring style as the other methods, e.g.
def get_sample(self):
"""Returns the Sample
"""
from . import SampleAnalysesView | ||
from . import SamplePartitionsView |
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.
Try to put PEP8 changes into a separate commit
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.
Done!
<span tal:replace="python:add_item"/> | ||
</a> | ||
</tal:add_actions> | ||
</h1> | ||
</metal: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.
Try to format also HTML files nicely, e.g. with an indendation of 2 spaces to safe some space. Also avoid whenever possible inline styles
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.
Done, pycharm was using tabs as default
from bika.lims import bikaMessageFactory as _ | ||
from bika.lims import logger | ||
from bika.lims.interfaces import IGetDefaultFieldValueARAddHook | ||
from bika.lims.utils import tmpID | ||
from bika.lims.utils.analysisrequest import create_analysisrequest as crar |
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.
Here also a separate commit please
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.
Ok
name=hook_name, | ||
interface=IGetDefaultFieldValueARAddHook) | ||
if adapter is not None: | ||
default = adapter(self.context) |
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.
Nice!
field = $("#DateSampled-#{arnum}") | ||
value = sample.date_sampled | ||
field.val value | ||
|
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.
Try to keep your commits consistent. E.g. this change is independent of the hook you introduced above
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.
Got it
Conflicts: bika/lims/interfaces/__init__.py
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.
Added entry to CHANGES.rst, removed duplicate code and merged master into
Description of the issue/feature this PR addresses
This PR adds a button in Sample Views to create analysis requests from them.
An “Add Analysis Request” button will be added in Sample's view. Once the button is pressed, the user will be redirected to the Analysis Request Add form, and the data already assigned to the Sample will be filled automatically
Since some AnalysisRequest object fields can be overridden or extended in addons, a marker interface and an adapters query has been added to
get_default_value
. The process is as follows:Default data for AR Add form fields are filed through
get_default_value
method that give them a value using some logic. In some cases those fields can be defined in addons. Nowget_default_value
queries for hooks adaptingIGetDefaultFieldValueARAddHook
, those hooks should return a default value for the extended fields.Current behavior before PR
The only way to create an analysis request is from an analysis request view. If a user is checking a sample and wants to create an analysis request for it, he/she has to move to analysis requests view, open a new AR Add form and introduce the sample ID in the AR Add form field.
Desired behavior after PR is merged
An analysis request for a sample can be created from the same Sample View, easing the process.
--
I confirm I have tested this PR thoroughly and coded it according to PEP8
and Plone's Python styleguide standards.