def run(self): """Override base class to add action for new button.""" if self.request == self.ADD_NEW_USER: navigateTo(self.EDIT_USER, self.session.name) else: Controller.run(self)
def run(self): """Override to handle routing to Mailers menu.""" if self.request == self.SUBMENU: navigateTo("Mailers.py", self.session.name) else: Controller.run(self)
def run(self): """Override the base class version, as this isn't a standard report.""" if not self.doc or self.request == self.FILTERS: navigateTo("EditFilters.py", self.session.name) elif not self.request or self.request in (self.VIEW, self.COMPARE): self.show_form() else: Controller.run(self)
def run(self): """Override the base class method to handle additional buttons.""" if self.request == self.GLOSSARY: self.redirect("glossary-translation-jobs.py") elif self.request == self.SUMMARY: self.redirect("translation-jobs.py") else: Controller.run(self)
def run(self): """Override router.""" if self.id: sys.stdout.buffer.write(b"Content-type: text/plain;charset=utf-8") sys.stdout.buffer.write(b"\n\n") sys.stdout.buffer.write(self.doc.xml.encode("utf-8")) sys.exit(0) Controller.run(self)
def run(self): """Override base class to add action for new button.""" if self.request == self.ADD_NEW_LINK_TYPE: opts = dict(linkact="addlink") navigateTo(self.EDIT_LINK_TYPE, self.session.name, **opts) elif self.request == self.SHOW_ALL: navigateTo(self.SHOW_ALL_LINK_TYPES, self.session.name) else: Controller.run(self)
def run(self): """Override base class to add action for new button.""" if self.request == self.ADD: navigateTo(self.EDIT_FILTER_SET, self.session.name) elif self.request == self.DEEP: navigateTo(self.SHOW_SETS, self.session.name) elif self.request == self.REPORT: navigateTo(self.SHOW_SETS, self.session.name, depth="shallow") else: Controller.run(self)
def run(self): """Override the base class version: no menu and no tables.""" if not self.request: try: self.show_report() except Exception as e: self.logger.exception("Report failed") self.bail(e) else: Controller.run(self)
def run(self): """Provide routing to our custom commands.""" if self.request == self.DEEP: navigateTo(self.script, self.session.name) elif self.request == self.SHALLOW: navigateTo(self.script, self.session.name, depth="shallow") elif self.request == self.FILTER_SETS: navigateTo(self.EDIT_FILTER_SETS, self.session.name) else: Controller.run(self)
def run(self): """Override base class version as this is not a standard report.""" if not (self.request and self.old and self.new): self.show_form() elif self.request == self.SUBMIT: self.confirm() elif self.request == self.CONFIRM: self.replace() else: Controller.run(self)
def run(self): """Override base class method, as we support extra buttons/tasks.""" if not self.session.can_do("MANAGE TRANSLATION QUEUE"): self.bail("not authorized") if self.request == self.ADD: navigateTo("glossary-translation-job.py", self.session.name) elif self.request == self.SUMMARY: navigateTo("translation-jobs.py", self.session.name) elif self.request == self.MEDIA: navigateTo("media-translation-jobs.py", self.session.name) elif self.request == self.PURGE: if not self.session.can_do("PRUNE TRANSLATION QUEUE"): self.bail("not authorized") self.cursor.execute( "DELETE FROM glossary_translation_job" " WHERE state_id = (" " SELECT value_id" " FROM glossary_translation_state" " WHERE value_name = 'Translation Made Publishable')" ) count = self.cursor.rowcount self.conn.commit() self.message = f"Purged jobs for {count:d} published translations." elif self.request == self.ASSIGN: count = 0 fields = "state_id", "comments", "assigned_to" history_fields = fields + ("doc_id", "state_date") placeholders = ", ".join(["?"] * len(history_fields)) table = "glossary_translation_job_history" args = table, ", ".join(history_fields), placeholders insert = "INSERT INTO {} ({}) VALUES ({})".format(*args) table = "glossary_translation_job" args = table, "assigned_to = ?, state_date = ?", "doc_id" update = "UPDATE {} SET {} WHERE {} = ?".format(*args) for job in self.fields.getlist("assignments"): query = self.Query("glossary_translation_job", *fields) query.where(query.Condition("doc_id", job)) row = query.execute(self.cursor).fetchone() if not row: self.bail() if row.assigned_to == self.assignee: continue params = [getattr(row, name) for name in fields[:-1]] params.append(self.assignee) params.append(job) params.append(self.started) self.cursor.execute(insert, params) params = self.assignee, self.started, job self.cursor.execute(update, params) self.conn.commit() count += 1 self.message = f"Re-assigned {count:d} jobs" Controller.run(self)
def run(self): """Add some custom routing.""" if not self.request: if self.id or self.name or self.age or self.status: self.request = self.SUBMIT elif self.request == self.BACK: return navigateTo(self.script, self.session.name) elif self.request == self.REFRESH: self.request = self.SUBMIT Controller.run(self)
def run(self): """Override so we can handle some custom commands.""" if not self.session.can_do("SET_SYS_VALUE"): bail("Not authorized to manage control values") if self.request == self.SAVE: self.save() elif self.request == self.DELETE: self.inactivate() else: Controller.run(self)
def run(self): """Support our custom commands and bypass a form.""" if not self.request: self.show_report() elif self.request == self.COMPARE: navigateTo("FilterDiffs.py", self.session.name) elif self.request == self.PARAMS: navigateTo("GetXsltParams.py", self.session.name) else: Controller.run(self)
def run(self): """Override to bypass form.""" if not self.request: self.show_report() try: self.show_report() except Exception as e: self.logger.exception("Report failed") self.bail(e) else: Controller.run(self)
def run(self): """Provide routing for our custom actions.""" try: if self.request == self.SAVE: self.save() elif self.request == self.FILTER: self.show_report() except Exception as e: self.logger.exception("failure") self.bail(str(e)) Controller.run(self)
def run(self): """Overload to check permissions and to handle the publish command.""" if not self.session.can_do("USE PUBLISHING SYSTEM"): self.bail("You are not authorized to use the publishing system") elif self.request == self.MANAGE_STATUSES: navigateTo("ManagePubStatus.py", self.session.name) elif self.request == self.PUBLISH: self.publish() elif self.request == self.SUBMIT: self.show_form() else: Controller.run(self)
def run(self): """Override base class logic for some custom routing.""" if self.request in (self.ADMINMENU, self.REPORTS_MENU, self.LOG_OUT): Controller.run(self) if self.request == self.TESTS: self.show_form() elif self.text: self.show_file() elif self.docs: self.show_report() else: Controller.run(self)
def run(self): """Customize the routing.""" try: if self.email and self.types and self.id: if not self.request or self.request == self.SUBMIT: return self.show_report() elif self.request == self.SUBMIT: return self.show_form() except Exception as e: self.logger.exception("Report ailure") self.bail(e) Controller.run(self)
def run(self): """Override base class so we can handle the extra buttons.""" try: if self.request == self.INACTIVATE: return self.inactivate() elif self.request in (self.SAVE_CHANGES, self.SAVE_NEW): return self.save() elif self.request == self.SUBMENU: return self.return_to_users_menu() except Exception as e: bail(f"Failure: {e}") Controller.run(self)
def run(self): """Override base class so we can handle the extra buttons.""" try: if self.request == self.DELETE: return self.delete() elif self.request == self.SAVE: return self.save() elif self.request == self.SUBMENU: return self.return_to_groups_menu() except Exception as e: bail(f"Failure: {e}") Controller.run(self)
def run(self): """Override to provide custom routing, bypassing forms.""" if self.request == self.SUBMENU: navigateTo(self.LINK_URL, self.session.name) elif not self.request: try: self.show_report() except Exception as e: self.logger.exception("Report failure") self.bail(e) else: Controller.run(self)
def run(self): """Override the top-level entry point, as this isn't a report.""" if not self.session.can_do("SET_SYS_VALUE"): bail("You are not authorized to use this tool") if self.request == self.SAVE: try: self.save() except Exception as e: self.logger.exception("Failure saving") bail(str(e)) else: Controller.run(self)
def run(self): """Add some extra routing.""" try: if self.request == self.COMPARE: return self.compare() elif self.request == self.ADD: return self.add() elif self.request == self.REMOVE: return self.remove() except Exception as e: self.logger.exception("Failure of %s command", self.request) self.bail(e) Controller.run(self)
def run(self): """Override base version to support custom actions.""" if not self.session.can_do(self.ACTION): self.bail("Unauthorized") try: if self.request == self.CONFIRM: return self.replace() elif self.request == self.CANCEL: return self.show_form() except Exception as e: self.logger.exception("replacement failure") self.bail(e) Controller.run(self)
def run(self): """Override the base class method to customize routing.""" try: if self.request == self.SUBMIT and not (self.start and self.end): self.show_form() elif self.request == self.DETAILS: self.show_report() elif not self.request and (self.id or self.start and self.end): self.show_report() else: Controller.run(self) except Exception as e: self.logger.exception("Status failure") self.bail(e)
def run(self): """Override the top-level entry point, as this isn't a report.""" try: if self.request == self.SAVE: self.save() elif self.request == self.CANCEL: navigateTo("EditLinkControl.py", self.session.name) elif self.request == self.DELETE: self.delete() else: Controller.run(self) except Exception as e: self.logger.exception("link type editing failure") self.bail(str(e))
def run(self): """Override base class method because we have multiple forms.""" if not self.session.can_do("MANAGE DB TABLES"): self.bail("not authorized") if self.request in (self.ADD, self.SUBMIT): self.show_form() elif self.request == self.DROP: self.drop() elif self.request == self.SAVE: self.save() elif self.request == self.CANCEL: navigateTo(self.script, self.session.name, table=self.table) else: Controller.run(self)
def run(self): """ Override the base class method to handle additional buttons. """ if not self.session or not self.session.can_do(self.ACTION): self.bail("not authorized") if self.request == self.JOBS: navigateTo("translation-jobs.py", self.session.name) elif self.request == self.DELETE: self.delete_job() elif self.request == self.GLOSSARY: navigateTo("glossary-translation-jobs.py", self.session.name) elif self.request == self.MEDIA: navigateTo("media-translation-jobs.py", self.session.name) Controller.run(self)
def run(self): """Provide custom routing.""" args = self.request, self.name, self.id self.logger.debug("request=%s name=%s, id=%s", *args) try: if self.book: return self.send_book() if self.mp3: return self.send_mp3() elif self.request == self.SAVE: return self.save() except Exception as e: self.logger.exception("Failure") self.bail(e) Controller.run(self)