diff --git a/orchestra/apps/webapps/admin.py b/orchestra/apps/webapps/admin.py index 7e624fcf..a847cdaf 100644 --- a/orchestra/apps/webapps/admin.py +++ b/orchestra/apps/webapps/admin.py @@ -15,10 +15,10 @@ class WebAppOptionInline(admin.TabularInline): model = WebAppOption extra = 1 - OPTIONS_HELP_TEXT = str({ + OPTIONS_HELP_TEXT = { k: str(unicode(v[1])) if len(v) == 3 else '' for k, v in settings.WEBAPPS_OPTIONS.iteritems() - }) + } class Media: css = { @@ -30,6 +30,7 @@ class WebAppOptionInline(admin.TabularInline): if db_field.name == 'value': kwargs['widget'] = forms.TextInput(attrs={'size':'100'}) if db_field.name == 'name': + # Help text based on select widget kwargs['widget'] = forms.Select(attrs={ 'onChange': """ siteoptions = %s; @@ -38,7 +39,7 @@ class WebAppOptionInline(admin.TabularInline): valueelement.parent().append( "
" + siteoptions[this.options[this.selectedIndex].value] + "
" ); - """ % self.OPTIONS_HELP_TEXT, + """ % str(self.OPTIONS_HELP_TEXT), }) return super(WebAppOptionInline, self).formfield_for_dbfield(db_field, **kwargs) @@ -53,6 +54,11 @@ class WebAppAdmin(AccountAdminMixin, ExtendedModelAdmin): change_readonly_fields = ('name', 'type') prefetch_related = ('content_set__website',) + TYPE_HELP_TEXT = { + k: str(unicode(v.get('help_text', ''))) + for k, v in settings.WEBAPPS_TYPES.iteritems() + } + def display_websites(self, webapp): websites = [] for content in webapp.content_set.all(): @@ -68,6 +74,22 @@ class WebAppAdmin(AccountAdminMixin, ExtendedModelAdmin): return '" + siteoptions[this.options[this.selectedIndex].value] + "
" + ); + """ % str(self.TYPE_HELP_TEXT), + }) + kwargs['help_text'] = self.TYPE_HELP_TEXT.get(db_field.default, '') + return super(WebAppAdmin, self).formfield_for_dbfield(db_field, **kwargs) admin.site.register(WebApp, WebAppAdmin) diff --git a/orchestra/apps/webapps/settings.py b/orchestra/apps/webapps/settings.py index fad8cbc4..d4300353 100644 --- a/orchestra/apps/webapps/settings.py +++ b/orchestra/apps/webapps/settings.py @@ -56,7 +56,8 @@ WEBAPPS_TYPES = getattr(settings, 'WEBAPPS_TYPES', { 'webalizer': { 'verbose_name': "Webalizer", 'directive': ('static', '%(app_path)s%(site_name)s'), - 'help_text': _("This creates a Webalizer application under ~/webapps/" + siteoptions[this.options[this.selectedIndex].value] + "
" ); - """ % self.OPTIONS_HELP_TEXT, + """ % str(self.OPTIONS_HELP_TEXT), }) return super(WebsiteOptionInline, self).formfield_for_dbfield(db_field, **kwargs)