Mercurial > agora-palash
changeset 99:d858aae811d0
Move choices for lexer field from SnippetForm to Snippet
The choices should be on the model, because it's more logical and because
now we can print out the human-readable value of the field directly from
the model, using snippet.get_FIELD_display() (e.g. get_lexer_display()).
author | dellsystem <ilostwaldo@gmail.com> |
---|---|
date | Fri, 31 Aug 2012 02:28:57 -0400 |
parents | 5a8f1dece263 |
children | 365144dad9d1 |
files | apps/snippet/forms.py apps/snippet/models.py |
diffstat | 2 files changed, 4 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/apps/snippet/forms.py Fri Aug 31 02:26:22 2012 -0400 +++ b/apps/snippet/forms.py Fri Aug 31 02:28:57 2012 -0400 @@ -20,11 +20,6 @@ class SnippetForm(forms.ModelForm): - lexer = forms.ChoiceField( - choices=LEXER_LIST, - initial=LEXER_DEFAULT, - label=_(u'Lexer'), - ) expire_options = forms.ChoiceField( choices=EXPIRE_CHOICES, initial=EXPIRE_DEFAULT,
--- a/apps/snippet/models.py Fri Aug 31 02:26:22 2012 -0400 +++ b/apps/snippet/models.py Fri Aug 31 02:28:57 2012 -0400 @@ -20,7 +20,10 @@ content = models.TextField(_(u'Content'), ) content_highlighted = models.TextField(_(u'Highlighted Content'), blank=True) - lexer = models.CharField(_(u'Lexer'), max_length=30, default=LEXER_DEFAULT) + lexer = models.CharField(_(u'Lexer'), + max_length=30, + choices=LEXER_LIST, + default=LEXER_DEFAULT) published = models.DateTimeField(_(u'Published'), blank=True) expires = models.DateTimeField(_(u'Expires'), blank=True, help_text='asdf') parent = models.ForeignKey('self', null=True, blank=True,