Code Duplication    Length = 21-21 lines in 2 locations

bika/lims/browser/samplinground/printform.py 1 location

@@ 87-107 (lines=21) @@
84
                })
85
        return out
86
87
    def getFormTemplate(self):
88
        """Returns the current samplinground rendered with the template
89
            specified in the request (param 'template').
90
            Moves the iterator to the next samplinground available.
91
        """
92
        templates_dir = self._TEMPLATES_DIR
93
        embedt = self.request.get('template', self._DEFAULT_TEMPLATE)
94
        if embedt.find(':') >= 0:
95
            prefix, embedt = embedt.split(':')
96
            templates_dir = queryResourceDirectory(self._TEMPLATES_ADDON_DIR, prefix).directory
97
        embed = ViewPageTemplateFile(os.path.join(templates_dir, embedt))
98
        reptemplate = ""
99
        try:
100
            reptemplate = embed(self)
101
        except:
102
            tbex = traceback.format_exc()
103
            wsid = self._samplingrounds[self._current_sr_index].id
104
            reptemplate = "<div class='error-print'>%s - %s '%s':<pre>%s</pre></div>" % (wsid, _("Unable to load the template"), embedt, tbex)
105
        if self._current_sr_index < len(self._samplingrounds):
106
            self._current_sr_index += 1
107
        return reptemplate
108
109
    def getCSS(self):
110
        """ Returns the css style to be used for the current template.

bika/lims/browser/worksheet/views/printview.py 1 location

@@ 117-137 (lines=21) @@
114
                })
115
        return out
116
117
    def renderWSTemplate(self):
118
        """ Returns the current worksheet rendered with the template
119
            specified in the request (param 'template').
120
            Moves the iterator to the next worksheet available.
121
        """
122
        templates_dir = self._TEMPLATES_DIR
123
        embedt = self.request.get('template', self._DEFAULT_TEMPLATE)
124
        if embedt.find(':') >= 0:
125
            prefix, embedt = embedt.split(':')
126
            templates_dir = queryResourceDirectory(self._TEMPLATES_ADDON_DIR, prefix).directory
127
        embed = ViewPageTemplateFile(os.path.join(templates_dir, embedt))
128
        reptemplate = ""
129
        try:
130
            reptemplate = embed(self)
131
        except:
132
            tbex = traceback.format_exc()
133
            wsid = self._worksheets[self._current_ws_index].id
134
            reptemplate = "<div class='error-print'>%s - %s '%s':<pre>%s</pre></div>" % (wsid, _("Unable to load the template"), embedt, tbex)
135
        if self._current_ws_index < len(self._worksheets):
136
            self._current_ws_index += 1
137
        return reptemplate
138
139
    def getCSS(self):
140
        """ Returns the css style to be used for the current template.