def make_table(self, view_filter, pagenum): """Make the form for main page""" table = self.session.make_table_name(self.user["users.langid"]) mtable = self.session.get_masterlang_table() langid = self.user["users.langid"] status_sql = self.get_sql_for_view_filter(view_filter, table) template_fields = ["xmlid", "textstring", "status", "remarks", "ref_string", "our_remarks"] dbfields = ["%s.xmlid" % table, "%s.textstring" % table, "%s.status" % table, "%s.remarks" % table, "%s.textstring" % mtable, "%s.remarks" % mtable] request = """SELECT %(fields)s FROM %(table)s, %(mastertable)s WHERE %(table)s.\ xmlid=%(mastertable)s.xmlid AND %(table)s.translate=1 AND \ (%(table)s.role="STRING" OR %(table)s.role="CONTROL" OR \ %(table)s.role="DIALOG" OR %(table)s.role="MENUITEM") \ %(where_flags)s""" % \ {"fields": ",".join(dbfields), "table": table, "where_flags": status_sql, "mastertable": mtable} self.session.execute_query(request) rows = self.session.cursor.fetchall() self.total_num_items = len(rows) start, end = self.calculate_range(pagenum) self.session.trace_msg("Range for page %d: %d, %d" % (pagenum, start, end)) form = "<table>" for i in range(start, end): r = rows[i] data = dict(zip(template_fields, r)) t = tablerow.tablerow(searchList=data) t.instructions = self.instructions t.width = self.textbox_columns t.height = self.textbox_rows t.langid = self.user["users.langid"] t.pagenum = pagenum t.audio_support = self.audio_support t.audiouri = self.get_current_audio_uri(data["xmlid"], self.user["users.langid"]) t.audionotes = "" if self.error != "" and self.error_id == data["xmlid"]: t.error = self.error else: t.error = "" form = form + t.respond() form = form + "</table>" return form, len(rows)
def make_table(self, view_filter, pagenum): """Make the form for main page""" table = self.session.make_table_name(self.user["users.langid"]) mtable = self.session.get_masterlang_table() langid = self.user["users.langid"] status_sql = self.get_sql_for_view_filter(view_filter, table) template_fields = ["xmlid", "textstring", "status", "remarks", "target", "ref_string", "role"] dbfields = ["%s.xmlid" % table, "%s.textstring" % table, "%s.status" % table, "%s.remarks" % table, "%s.target" % table, "%s.textstring" % mtable, "%s.role" % mtable] request = "SELECT DISTINCT mnemonicgroup FROM %s WHERE mnemonicgroup >= 0" % table self.session.execute_query(request) mnem_groups = self.session.cursor.fetchall() form = "" group_number = 1 num_rows = 0 # each mnemonic group gets its own section for g in mnem_groups: request = """SELECT %(fields)s FROM %(table)s, %(mastertable)s WHERE %(table)s.\ xmlid=%(mastertable)s.xmlid AND %(table)s.mnemonicgroup=%(mnem_group)d \ AND %(table)s.role="MNEMONIC" %(where_flags)s""" % \ {"fields": ",".join(dbfields), "table": table, "where_flags": status_sql, "mnem_group": g[0], "mastertable": mtable} self.session.execute_query(request) rows = self.session.cursor.fetchall() num_rows += len(rows) if len(rows) > 0: # the title of each section form += """<h2 id="group_%s">GROUP #%s</h2>""" % (str(g[0]), str(group_number)) form += "<table>" for r in rows: data = dict(zip(template_fields, r)) locallang_ref = self.build_mnemonic_string(table, data["target"], data["textstring"]) masterlang_ref = self.build_mnemonic_string(mtable, data["target"], data["ref_string"]) # override some values data["ref_string"] = locallang_ref data["our_remarks"] = "This is for a %(item)s. In %(masterlangname)s, it is \ used like this: \"%(example)s\"" \ % {"item": self.ROLE_DESCRIPTIONS[data["role"]], "example": masterlang_ref, "masterlangname": self.masterlangname} t = tablerow.tablerow(searchList=data) t.instructions = self.instructions t.width = self.textbox_columns t.height = self.textbox_rows t.langid = self.user["users.langid"] t.audiouri = self.get_current_audio_uri(data["xmlid"], self.user["users.langid"]) t.audio_support = self.audio_support t.audionotes = "Record only the mnemonic letter. E.g. <em>"%s"</em>" % data["textstring"] if self.error != "" and self.error_id == data["xmlid"]: t.error = self.error else: t.error = "" form += t.respond() form += "</table>" group_number += 1 #end for return form, num_rows
def make_table(self, view_filter, pagenum): """Make the form for main page""" table = self.session.make_table_name(self.user["users.langid"]) mtable = self.session.get_masterlang_table() langid = self.user["users.langid"] status_sql = self.get_sql_for_view_filter(view_filter, table) template_fields = ["xmlid", "textstring", "status", "remarks", "target", "ref_string", "role"] dbfields = [ "%s.xmlid" % table, "%s.textstring" % table, "%s.status" % table, "%s.remarks" % table, "%s.target" % table, "%s.textstring" % mtable, "%s.role" % mtable, ] request = "SELECT DISTINCT mnemonicgroup FROM %s WHERE mnemonicgroup >= 0" % table self.session.execute_query(request) mnem_groups = self.session.cursor.fetchall() form = "" group_number = 1 num_rows = 0 # each mnemonic group gets its own section for g in mnem_groups: request = """SELECT %(fields)s FROM %(table)s, %(mastertable)s WHERE %(table)s.\ xmlid=%(mastertable)s.xmlid AND %(table)s.mnemonicgroup=%(mnem_group)d \ AND %(table)s.role="MNEMONIC" %(where_flags)s""" % { "fields": ",".join(dbfields), "table": table, "where_flags": status_sql, "mnem_group": g[0], "mastertable": mtable, } self.session.execute_query(request) rows = self.session.cursor.fetchall() num_rows += len(rows) if len(rows) > 0: # the title of each section form += """<h2 id="group_%s">GROUP #%s</h2>""" % (str(g[0]), str(group_number)) form += "<table>" for r in rows: data = dict(zip(template_fields, r)) locallang_ref = self.build_mnemonic_string(table, data["target"], data["textstring"]) masterlang_ref = self.build_mnemonic_string(mtable, data["target"], data["ref_string"]) # override some values data["ref_string"] = locallang_ref data["our_remarks"] = ( 'This is for a %(item)s. In %(masterlangname)s, it is \ used like this: "%(example)s"' % { "item": self.ROLE_DESCRIPTIONS[data["role"]], "example": masterlang_ref, "masterlangname": self.masterlangname, } ) t = tablerow.tablerow(searchList=data) t.instructions = self.instructions t.width = self.textbox_columns t.height = self.textbox_rows t.langid = self.user["users.langid"] t.audiouri = self.get_current_audio_uri(data["xmlid"], self.user["users.langid"]) t.audio_support = self.audio_support t.audionotes = "Record only the mnemonic letter. E.g. <em>"%s"</em>" % data["textstring"] if self.error != "" and self.error_id == data["xmlid"]: t.error = self.error else: t.error = "" form += t.respond() form += "</table>" group_number += 1 # end for return form, num_rows