def final_status_report(self): actions_result_labels = {'delete': 'deleted', 'update': 'updated', 'add': 'added', '-': '-', 'skip-update': 'skipped', 'order changed': 'order changed', 'fail': 'update/add failed', 'block-update': 'update blocked'} orders = sorted(list(set([article.order for article in self.previous_registered_articles.values()] + [article.order for article in self.db.registered_articles.values()] + [article.order if article.tree is not None else 'None' for article in self.pkg.articles.values()]))) sorted_previous_registered = pkg_reports.articles_sorted_by_order(self.previous_registered_articles) sorted_registered = pkg_reports.articles_sorted_by_order(self.db.registered_articles) sorted_package = pkg_reports.articles_sorted_by_order(self.pkg.articles) items = [] for order in orders: if order in sorted_registered.keys(): # documento na base for article in sorted_registered[order]: action = self.actions[article.xml_name] result = actions_result_labels[action] _notes = '' if action == 'update': if article.last_update_display is None: result = 'error' elif self.previous_registered_articles.get(article.xml_name).last_update_display == article.last_update_display: result = 'error' name = article.xml_name if name in self.changed_orders.keys(): previous_order, new_order = self.changed_orders[name] _notes = previous_order + '=>' + new_order if result == 'error': _notes = validation_status.STATUS_ERROR + ': ' + _('Unable to replace ') + _notes labels, values = complete_issue_items_row(article, action, result, 'registered', _notes, True) items.append(pkg_reports.label_values(labels, values)) elif order in sorted_package.keys(): # documento no pacote mas nao na base for article in sorted_package[order]: action = self.actions[article.xml_name] name = article.xml_name _notes = '' if name in self.changed_orders.keys(): previous_order, new_order = self.changed_orders[name] _notes = previous_order + '=>' + new_order _notes = validation_status.STATUS_ERROR + ': ' + _('Unable to replace ') + _notes labels, values = complete_issue_items_row(article, action, 'error', 'package', _notes, True) items.append(pkg_reports.label_values(labels, values)) elif order in sorted_previous_registered.keys(): # documento anteriormente na base for article in sorted_previous_registered[order]: action = 'delete' name = article.xml_name _notes = '' if name in self.changed_orders.keys(): previous_order, new_order = self.changed_orders[name] _notes = 'deleted ' + previous_order + '=> new: ' + new_order labels, values = complete_issue_items_row(article, '?', 'deleted', 'excluded', _notes, True) items.append(pkg_reports.label_values(labels, values)) after_conversion_report = html_reports.tag('h4', _('Documents status in the package/database - after conversion')) after_conversion_report += html_reports.sheet(labels, items, 'dbstatus', 'result') return after_conversion_report
def initial_status_report(self): report = html_reports.tag('h4', _('Documents status in the package/database - before conversion')) orders = [article.order for article in self.previous_registered_articles.values()] for article in self.pkg.articles.values(): if article.tree is None: orders.append('None') else: orders.append(article.order) orders = sorted(list(set([order for order in orders if order is not None]))) sorted_registered = pkg_reports.articles_sorted_by_order(self.previous_registered_articles) sorted_package = pkg_reports.articles_sorted_by_order(self.pkg.articles) items = [] for order in orders: action = '' if order in sorted_registered.keys(): for article in sorted_registered[order]: action = self.actions[article.xml_name] _notes = '' if action == 'update': if self.previous_registered_articles[article.xml_name].order != self.pkg.articles[article.xml_name].order: action = 'delete' _notes = 'new order=' + self.pkg.articles[article.xml_name].order labels, values = complete_issue_items_row(article, '', '', 'registered', _notes) items.append(pkg_reports.label_values(labels, values)) if order in sorted_package.keys(): for article in sorted_package[order]: action = self.actions[article.xml_name] _notes = '' if self.previous_registered_articles.get(article.xml_name) is not None: if self.previous_registered_articles[article.xml_name].order != self.pkg.articles[article.xml_name].order: _notes = _('replacing ') + self.previous_registered_articles[article.xml_name].order labels, values = complete_issue_items_row(article, action, '', 'package', _notes) items.append(pkg_reports.label_values(labels, values)) return report + html_reports.sheet(labels, items, 'dbstatus', 'action')