def list_bundles(self): """Displays a list of all the resource bundles.""" bundles = list(ResourceBundle.all().order('-created')) rows = [] for bundle in bundles: bundle_name = bundle.key().name() bundle_name_html = html(bundle_name) is_default = bundle_name == self.env.default_resource_bundle is_in_preview = bundle_name == self.env.resource_bundle if is_default: bundle_name_html = '<b>%s</b> (default)' % bundle_name_html elif is_in_preview: bundle_name_html += ' (in preview)' rows.append( ''' <tr class="%(class)s"> <td><a class="bundle" href="%(link)s">%(bundle_name_html)s</a></td> <td>%(created)s</td> <td><a href="%(preview)s"><input type="button" value="Preview"></a></td> <td><input type="radio" name="resource_bundle_default" value="%(bundle_name)s" %(default_checked)s></td> </tr>''' % { 'class': is_in_preview and 'active' or '', 'link': self.get_admin_url(bundle_name), 'bundle_name': bundle_name, 'bundle_name_html': bundle_name_html, 'default_checked': is_default and 'checked' or '', 'created': format_datetime(bundle.created), 'preview': self.get_admin_url(bundle_name, operation='set_preview') }) self.write( ''' <form method="post"> <input type="hidden" name="operation" value="set_default"> <table cellpadding=0 cellspacing=0> <tr><th>Bundle name</th><th>Created</th> <th><a href="%(reset)s"><input type="button" value="Reset to default" ></a></th> <th><input type="submit" value="Set to default"></th></tr> %(rows)s </table> </form> <div class="add"> <form method="post"> <input type="hidden" name="operation" value="add_bundle"> <input name="resource_bundle" size="18" placeholder="bundle name"> <input type="submit" value="Add bundle"> </form> </div>''' % { 'reset': self.get_admin_url(operation='set_preview'), 'rows': ''.join(rows) })
def list_bundles(self): """Displays a list of all the resource bundles.""" bundles = list(ResourceBundle.all().order('-created')) rows = [] for bundle in bundles: bundle_name = bundle.key().name() bundle_name_html = html(bundle_name) is_default = bundle_name == self.env.default_resource_bundle is_in_preview = bundle_name == self.env.resource_bundle if is_default: bundle_name_html = '<b>%s</b> (default)' % bundle_name_html elif is_in_preview: bundle_name_html += ' (in preview)' rows.append(''' <tr class="%(class)s"> <td><a class="bundle" href="%(link)s">%(bundle_name_html)s</a></td> <td>%(created)s</td> <td><a href="%(preview)s"><input type="button" value="Preview"></a></td> <td><input type="radio" name="resource_bundle_default" value="%(bundle_name)s" %(default_checked)s></td> </tr>''' % { 'class': is_in_preview and 'active' or '', 'link': self.get_admin_url(bundle_name), 'bundle_name': bundle_name, 'bundle_name_html': bundle_name_html, 'default_checked': is_default and 'checked' or '', 'created': format_datetime(bundle.created), 'preview': self.get_admin_url(bundle_name, operation='set_preview')}) self.write(''' <form method="post"> <input type="hidden" name="operation" value="set_default"> <table cellpadding=0 cellspacing=0> <tr><th>Bundle name</th><th>Created</th> <th><a href="%(reset)s"><input type="button" value="Reset to default" ></a></th> <th><input type="submit" value="Set to default"></th></tr> %(rows)s </table> </form> <div class="add"> <form method="post"> <input type="hidden" name="operation" value="add_bundle"> <input name="resource_bundle" size="18" placeholder="bundle name"> <input type="submit" value="Add bundle"> </form> </div>''' % {'reset': self.get_admin_url(operation='set_preview'), 'rows': ''.join(rows)})