Permalink
Browse files

added proper template overrides for admin controller index page.

  • Loading branch information...
percious17
percious17 committed Jan 16, 2009
1 parent 7f9156e commit 3936d9f942ba818c1915e034fab934f2b61c54d5
Showing with 14 additions and 10 deletions.
  1. +13 −9 tgext/admin/controller.py
  2. +1 −1 tgext/admin/tgadminconfig.py
View
@@ -3,7 +3,7 @@
import inspect
from tg.controllers import TGController, expose
-from tg.decorators import with_trailing_slash
+from tg.decorators import with_trailing_slash, override_template
try:
import tw.dojo
@@ -52,24 +52,28 @@ def __init__(self, models, session, translations=None, config_type=None):
else:
config = config_type(models, translations)
- if config.index_template:
- engines = engines = self.index.decoration.engines
- text_engine = engines.get('text/html')
- template = config.index_template.split(':')
- template.extend(text_engine[2:])
- engines['text/html'] = template
+
if config.allow_only:
self.allow_only = config.allow_only
self.config = config
self.session = session
+ self.default_index_template = ':'.join(self.index.decoration.engines.get('text/html')[:2])
+ if self.config.default_index_template:
+ self.default_index_template = self.config.default_index_template
+
@with_trailing_slash
@expose(engine+':tgext.admin.templates.index')
def index(self):
- return dict(page='index', models=[model.__name__ for model in self.config.models.values()])
-
+ #overrides the template for this method
+ original_index_template = self.index.decoration.engines['text/html']
+ new_engine = self.default_index_template.split(':')
+ new_engine.extend(original_index_template[2:])
+ self.index.decoration.engines['text/html'] = new_engine
+ return dict(models=[model.__name__ for model in self.config.models.values()])
+
def _make_controller(self, config, session):
m = config.model
class ModelController(CrudRestController):
@@ -26,7 +26,7 @@ def _do_init_with_translations(self, translations):
class Table(TableBase):
__entity__ = self.model
- __omit_fields__ = [user_id_field, '_password', password_field, 'lastName']
+ __omit_fields__ = [user_id_field, '_password', password_field]
__url__ = '../users.json'
self.table_type = Table

0 comments on commit 3936d9f

Please sign in to comment.