Show
Ignore:
Timestamp:
07/24/08 16:16:21 (20 months ago)
Author:
JensDiemer
Message:

blog update 2:

  • nicer "create blog entry" form (existing tags can be selected)
  • some code cleanup
  • try to verify tag slugs
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pylucid/PyLucid/plugins_internal/blog/forms.py

    r1701 r1713  
    2020from django.utils.translation import ugettext as _ 
    2121 
    22 from PyLucid.tools.newforms_utils import StripedCharField 
     22from PyLucid.tools.newforms_utils import StripedCharField, ListCharField 
    2323 
    2424# from blog plugin 
     
    5858        ) 
    5959 
    60  
    6160class BlogEntryForm(forms.ModelForm): 
    6261    """ 
    6362    Form for create/edit a blog entry. 
    6463    """ 
    65     content = forms.CharField( 
    66         widget=forms.Textarea(attrs={'rows': '15'}), 
     64    new_tags = ListCharField( # New field, (no field from BlogEntry model) 
     65        max_length=255, required=False, 
     66        help_text=_( 
     67            "New tags for this entry, if there not in the list above" 
     68            " (separated by spaces.)" 
     69        ), 
     70        widget=forms.TextInput(attrs={'class':'bigger'}), 
    6771    ) 
    6872 
    69     tags = forms.CharField( 
    70         max_length=255, required=False, 
    71         help_text=_("Tags for this entry (separated by spaces.)"), 
    72         widget=forms.TextInput(attrs={'class':'bigger'}), 
    73     ) 
     73    def __init__(self, *args, **kwargs): 
     74        """ 
     75        set some widget attributes 
     76        """ 
     77        super(BlogEntryForm, self).__init__(*args, **kwargs) 
     78 
     79        # Limit the MultipleChoiceField size 
     80        # Is there are a better way to do this? See: 
     81        # http://www.python-forum.de/topic-15503.html (de) 
     82        self.fields['tags'].widget.attrs["size"] = 7 
     83 
     84        # makes the content textarea bigger 
     85        self.fields['content'].widget.attrs["rows"] = 15 
     86 
    7487    class Meta: 
    7588        model = BlogEntry