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

Remove senaite.instruments dependency for instrument import form #1482

Merged
merged 2 commits into from
Nov 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Changelog

**Removed**

- #1482 Remove `senaite.instruments` dependency for instrument import form
- #1478 Remove AcquireFieldDefaults (was used for CCEmails field only)

**Fixed**
Expand Down
26 changes: 5 additions & 21 deletions bika/lims/exportimport/dataimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,15 @@ class ajaxGetImportTemplate(BrowserView):

def __call__(self):
plone.protect.CheckAuthenticator(self.request)
exim = self.request.get('exim')
core_instrument = self.is_exim_in_core(exim)
exim = exim.replace(".", "/")
exim = self.request.get('exim').replace(".", "/")
# If a specific template for this instrument doesn't exist yet,
# use the default template for instrument results file import located
# at bika/lims/exportimport/instruments/instrument.pt
# if exim.startswith('senaite/instruments'):
if core_instrument:
instrpath = os.path.join("exportimport", "instruments")
templates_dir = resource_filename("bika.lims", instrpath)
fname = "%s/%s_import.pt" % (templates_dir, exim)
else:
instrpath = '/'.join(exim.split('/')[2:-2])
templates_dir = resource_filename("senaite.instruments", instrpath)
fname = "{}/{}_import.pt".format(templates_dir, exim.split('/')[-1])
instrpath = os.path.join("exportimport", "instruments")
templates_dir = resource_filename("bika.lims", instrpath)
fname = "%s/%s_import.pt" % (templates_dir, exim)
if os.path.isfile(fname):
return ViewPageTemplateFile(fname)(self)
return ViewPageTemplateFile("instruments/%s_import.pt" % exim)(self)
else:
return ViewPageTemplateFile("instruments/instrument.pt")(self)

Expand All @@ -152,14 +144,6 @@ def getAnalysisServicesDisplayList(self):
items.sort(lambda x, y: cmp(x[1].lower(), y[1].lower()))
return DisplayList(list(items))

def is_exim_in_core(self, exim):
portal_tool = plone.api.portal.get_tool('portal_setup')
profiles = portal_tool.listProfileInfo()
for profile in profiles:
if exim.startswith(profile['product']):
return False
return True


class ajaxGetImportInterfaces(BrowserView):
""" Returns a json list with the interfaces assigned to the instrument
Expand Down