Skip to content

Instantly share code, notes, and snippets.

@mihasya
Created January 17, 2009 21:07
Show Gist options
  • Save mihasya/48454 to your computer and use it in GitHub Desktop.
Save mihasya/48454 to your computer and use it in GitHub Desktop.
#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