Skip to content
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

Allow to extend Add Sample behavior with adapters #1462

Merged
merged 26 commits into from
Oct 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
05c3919
Adapters support for Client field filter in Add2
xispa Oct 16, 2019
5798d6c
Remove pdb
xispa Oct 16, 2019
76226c9
Support in Add Sample view for fields flush
xispa Oct 17, 2019
d9b50ba
Generalize on_changed event for reference input fields in Add Sample
xispa Oct 17, 2019
53f3a80
Flush the uid of reference fields when empty in generic on_change han…
xispa Oct 17, 2019
b6275bc
Generic function for applying search filters
xispa Oct 17, 2019
1afd3bd
Generalize set_value function (e.g. set_client) to apply_field_value
xispa Oct 17, 2019
bc72f9d
set_contact --> apply_field_value
xispa Oct 17, 2019
f3a474f
set_sampletype --> apply_field_value
xispa Oct 17, 2019
b2715f1
Refactor set_sample --> apply_field_value
xispa Oct 17, 2019
200667a
Support for field-specific metadata in recalculate (Add Sample)
xispa Oct 17, 2019
46be897
Refactor ajax_recalculate_records function
xispa Oct 19, 2019
99f90cf
Apply values generically on form updated after records recalculation
xispa Oct 19, 2019
f4d9d11
autofill dependent default values when a field changes
xispa Oct 19, 2019
228661c
Imports cleanup
xispa Oct 19, 2019
708dc80
Restore the search query of reference field on flush
xispa Oct 20, 2019
b3ca1af
Cleanup
xispa Oct 20, 2019
e7fac45
Update changelog
xispa Oct 20, 2019
4758ee1
Added cache for get_object_info
xispa Oct 20, 2019
95ddef4
Better cache key
xispa Oct 20, 2019
759ed42
Template metadata is handled differently in js
xispa Oct 20, 2019
6ecfd07
If there is no specific func for get_*_info, call get_base_info
xispa Oct 20, 2019
3d6e667
Autofill Client Contact in Sample Add form when current user is a client
xispa Oct 20, 2019
3772789
viewcache for self.get_object_by_uid
xispa Oct 20, 2019
e82cf1e
Improved comment
ramonski Oct 20, 2019
e5828cf
Merge branch 'master' into adapters-for-add-fields
ramonski Oct 20, 2019
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 @@ -6,6 +6,7 @@ Changelog

**Added**

- #1462 Allow to extend the behavior of fields from AddSample view with adapters
- #1455 Added support for adapters in guard handler
- #1436 Setting in setup for auto-reception of samples upon creation
- #1433 Added Submitter column in Sample's analyses listing
Expand Down Expand Up @@ -35,6 +36,7 @@ Changelog

**Fixed**

- #1462 Autofill Client Contact in Sample Add form when current user is a client
- #1461 Allow unassign transition for cancelled/rejected/retracted analyses
- #1449 sort_limit was not considered in ReferenceWidget searches
- #1449 Fix Clients were unable to add batches
Expand Down
52 changes: 52 additions & 0 deletions bika/lims/adapters/addsample.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# -*- 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 zope.component import adapts

from bika.lims import api
from bika.lims.interfaces import IAddSampleObjectInfo


class AddSampleObjectInfoAdapter(object):
"""Base implementation of an adapter for reference fields used in Sample
Add form
"""
adapts(IAddSampleObjectInfo)

def __init__(self, context):
self.context = context

def get_base_info(self):
"""Returns the basic dictionary structure for the current object
"""
return {
"id": api.get_id(self.context),
"uid": api.get_uid(self.context),
"title": api.get_title(self.context),
"field_values": {},
"filter_queries": {},
}

def get_object_info(self):
"""Returns the dict representation of the context object for its
correct consumption by Sample Add form.
See IAddSampleObjectInfo for further details
"""
raise NotImplementedError("get_object_info not implemented")
Loading