diff --git a/CHANGES.rst b/CHANGES.rst index d098127502..511c2afafe 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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** diff --git a/bika/lims/exportimport/dataimport.py b/bika/lims/exportimport/dataimport.py index 763acd98cc..6d5358d0c0 100644 --- a/bika/lims/exportimport/dataimport.py +++ b/bika/lims/exportimport/dataimport.py @@ -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) @@ -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