Created
January 17, 2009 21:07
-
-
Save mihasya/48454 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Copyright (c) 2009 Mikhail Panchenko | |
#MIT License http://www.opensource.org/licenses/mit-license.php | |
class AddBmarkForm(forms.Form): | |
name = forms.CharField(max_length=50, required=False) | |
description = forms.CharField(max_length=255, required=True) | |
def clean_description(self): | |
desc = self.cleaned_data['description'] | |
name = slugify(desc).decode() | |
q = db.Query(Bmark) | |
q.filter('name =', name) | |
q.filter('user =', users.get_current_user()) | |
if (q.get()): | |
raise forms.ValidationError(_("A bookmark with that \ | |
name exists already")) | |
else: | |
self.cleaned_data['name'] = name | |
return desc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment