aboutsummaryrefslogtreecommitdiff
path: root/src/web
diff options
context:
space:
mode:
Diffstat (limited to 'src/web')
-rw-r--r--src/web/forms.py10
-rw-r--r--src/web/views/bookmark.py7
2 files changed, 13 insertions, 4 deletions
diff --git a/src/web/forms.py b/src/web/forms.py
index 4d44f379..b7a92519 100644
--- a/src/web/forms.py
+++ b/src/web/forms.py
@@ -205,9 +205,13 @@ class CategoryForm(Form):
class BookmarkForm(Form):
- href = TextField(lazy_gettext("URL"))
- title = TextField(lazy_gettext("Title"))
- description = TextField(lazy_gettext("Description"))
+ href = TextField(lazy_gettext("URL"),
+ [validators.Required(
+ lazy_gettext("Please enter an URL."))])
+ title = TextField(lazy_gettext("Title"),
+ [validators.Length(min=0, max=100)])
+ description = TextField(lazy_gettext("Description"),
+ [validators.Length(min=0, max=500)])
tags = TextField(lazy_gettext("Tags"))
to_read = BooleanField(lazy_gettext("To read"), default=False)
shared = BooleanField(lazy_gettext("Shared"), default=False)
diff --git a/src/web/views/bookmark.py b/src/web/views/bookmark.py
index 4e447899..cc43f191 100644
--- a/src/web/views/bookmark.py
+++ b/src/web/views/bookmark.py
@@ -101,9 +101,14 @@ def process_form(bookmark_id=None):
if not form.validate():
return render_template('edit_bookmark.html', form=form)
+ if form.title.data == '':
+ title = form.href.data
+ else:
+ title = form.title.data
+
bookmark_attr = {'href': form.href.data,
'description': form.description.data,
- 'title': form.title.data,
+ 'title': title,
'shared': form.shared.data,
'to_read': form.to_read.data}
bgstack15