Break the error block into functions
authorKarl O. Pinc <kop@karlpinc.com>
Tue, 5 Jan 2021 21:01:34 +0000 (15:01 -0600)
committerKarl O. Pinc <kop@karlpinc.com>
Mon, 18 Jan 2021 00:28:18 +0000 (18:28 -0600)
src/pgwui_common/templates/auth_base.mak

index 243030e81ebac8400e5a108c32d7ac479ccfe779..132055fd74799383aba772c74d61bfde8f789632 100644 (file)
   % endif
 </%block>
 
-<%block name="error_report">
+<%doc> Error reporting </%doc>
+
+<%def name="error_file_summary(e_cnt, lines, filepath, relation)">
   % if e_cnt:
       <p><em class="error">${e_cnt} errors</em>
       % if lines == UNDEFINED or lines == 0:
           found.
       % else:
-          found in a file of ${lines} lines.  (Including column headings.)
+          found
+        % if relation is None:
+          in
+        % else:
+          while inserting data into ${relation} from
+        % endif
+        % if filepath is None:
+          a file of
+        % else:
+          file ${filepath}, containing
+        % endif
+        ${lines} lines.  (Including column headings.)
       % endif
       </p>
   % endif
+</%def>
 
+<%def name="error_items(errors)">
   % for error in errors:
 
       ## Get error attributes
       % endif
 
   % endfor
+</%def>
+
+<%block name="error_report">
+  <% self.error_file_summary(e_cnt, lines, None, None) %>
+  <% self.error_items(errors) %>
 </%block>
 
 <%def name="upload_form(extra_rows=[], upload_nulls=True)">