Permalink
Browse files

Pretify the admin interface with helper texts.

  • Loading branch information...
Amalia Gherasim
Amalia Gherasim committed Apr 12, 2012
1 parent 683a671 commit a0cb37527dce07c72d0815759981a80658706f71
Showing with 19 additions and 13 deletions.
  1. +10 −5 smartsnippets/admin.py
  2. +9 −8 smartsnippets/models.py
View
@@ -57,7 +57,9 @@ def get_queryset(self):
class SnippetVariablesAdmin(admin.StackedInline):
model = SmartSnippetVariable
extra = 0
-
+ verbose_name = 'Smart Snippet Simple Variable'
+ verbose_name_plural = 'Smart Snippet Simple Variables'
+ SmartSnippetVariable.__unicode__ = lambda x: ''
def formfield_for_dbfield(self, db_field, **kwargs):
if db_field.name == 'widget':
kwargs['widget'] = Select(choices=tuple([(x.__name__, x.name) for x in widget_pool.get_all_widgets()]))
@@ -66,7 +68,8 @@ def formfield_for_dbfield(self, db_field, **kwargs):
class RegularSnippetVariablesAdmin(SnippetVariablesAdmin):
formset = SnippetVariablesFormSet
-
+
+
class SnippetAdmin(admin.ModelAdmin):
inlines = [RegularSnippetVariablesAdmin,]
shared_sites = shared_sites
@@ -128,12 +131,14 @@ def queryset(self, request):
class DropDownVariableAdmin(SnippetVariablesAdmin):
model = DropDownVariable
exclude = ('widget',)
-
-
+ verbose_name = 'Smart Snippet Dropdown Variable'
+ verbose_name_plural = 'Smart Snippet Dropdown Variables'
+ DropDownVariable.__unicode__ = lambda x: ''
+
+
class ExtendedSnippetAdmin(SnippetAdmin):
inlines = [RegularSnippetVariablesAdmin, DropDownVariableAdmin]
-
admin.site.register(SmartSnippet, SnippetAdmin)
admin.site.unregister(SmartSnippet)
admin.site.register(SmartSnippet, ExtendedSnippetAdmin)
View
@@ -42,15 +42,15 @@ def __unicode__(self):
class SmartSnippetVariable(models.Model):
- name = models.CharField(max_length=50)
- widget = models.CharField(max_length=50)
+ name = models.CharField(max_length=50,
+ help_text=_('Enter the name of the variable defined in the smart snippet template.'))
+ widget = models.CharField(max_length=50,
+ help_text=_('Select the type of the variable defined in the smart snippet template.'))
snippet = models.ForeignKey(SmartSnippet, related_name="variables")
class Meta:
unique_together = (('snippet', 'name'))
ordering = ['name']
- verbose_name = 'Smart Snippet Variable'
- verbose_name_plural = 'Smart Snippet Variables'
def save(self, *args, **kwargs):
super(SmartSnippetVariable, self).save(*args, **kwargs)
@@ -91,12 +91,13 @@ def widget(self):
class DropDownVariable(SmartSnippetVariable):
- choices = models.CharField(max_length=512)
-
+ choices = models.CharField(max_length=512,
+ help_text=_('Enter a comma separated list of choices that will be available in the dropdown variable when adding and configuring the smart snippet on a page.'))
+
@property
def choices_list(self):
- return [choice.strip() for choice in self.choices.split(',')]
+ return [choice.strip() for choice in self.choices.split(',')]
def save(self, *args, **kwargs):
self.widget = 'DropDownField'
- super(DropDownVariable, self).save(*args, **kwargs)
+ super(DropDownVariable, self).save(*args, **kwargs)

0 comments on commit a0cb375

Please sign in to comment.