From cd5acda0300193a80a96bef687f0403417ad42ee Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Fri, 1 Nov 2013 16:59:27 +0100 Subject: Improved sort of feeds. --- pyaggr3g470r/models.py | 2 +- pyaggr3g470r/views.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pyaggr3g470r/models.py b/pyaggr3g470r/models.py index 017ecd4f..629cc4c2 100644 --- a/pyaggr3g470r/models.py +++ b/pyaggr3g470r/models.py @@ -14,7 +14,7 @@ class User(Document, UserMixin): lastname = StringField(required = True) email = EmailField(required=True, unique=True) pwdhash = StringField(required=True) - feeds = SortedListField(EmbeddedDocumentField('Feed'), ordering='title', reverse=False) + feeds = ListField(EmbeddedDocumentField('Feed')) created_at = DateTimeField(required=True, default=datetime.now) def get_id(self): diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index 9c816990..0d6fcf21 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -175,6 +175,7 @@ def add_feed(): new_feed = models.Feed(title=form.title.data, link=form.link.data, site_link=form.site_link.data) user.feeds.append(new_feed) + user.feeds = sorted(user.feeds, key=lambda t: t.title.lower()) user.save() return redirect(url_for('home')) return render_template('management.html', form=form) \ No newline at end of file -- cgit