aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pyaggr3g470r/feedgetter.py2
-rwxr-xr-xpyaggr3g470r/utils.py11
-rw-r--r--pyaggr3g470r/views.py8
3 files changed, 11 insertions, 10 deletions
diff --git a/pyaggr3g470r/feedgetter.py b/pyaggr3g470r/feedgetter.py
index 1c834b88..156c0267 100644
--- a/pyaggr3g470r/feedgetter.py
+++ b/pyaggr3g470r/feedgetter.py
@@ -41,7 +41,7 @@ from sqlalchemy.exc import IntegrityError
import models
import conf
-import search
+#import search
import utils
from flask.ext.mail import Message
diff --git a/pyaggr3g470r/utils.py b/pyaggr3g470r/utils.py
index bb02c4df..16777278 100755
--- a/pyaggr3g470r/utils.py
+++ b/pyaggr3g470r/utils.py
@@ -47,7 +47,8 @@ from collections import Counter
from contextlib import contextmanager
import conf
-import models
+from pyaggr3g470r import db
+from pyaggr3g470r.models import User, Feed
# regular expression to check URL
url_finders = [ \
@@ -76,7 +77,7 @@ def import_opml(email, opml_file):
"""
Import new feeds from an OPML file.
"""
- user = models.User.objects(email=email).first()
+ user = User.query.filter(User.email == email).first()
try:
subscriptions = opml.parse(opml_file)
except Exception as e:
@@ -108,12 +109,12 @@ def import_opml(email, opml_file):
except:
site_link = ""
- new_feed = models.Feed(title=title, description=description, link=link, site_link=site_link, email=False, enabled=True)
+ new_feed = Feed(title=title, description=description, link=link, site_link=site_link, email_notification=False, enabled=True)
+
user.feeds.append(new_feed)
-
nb += 1
- user.save()
+ db.session.commit()
return nb
def open_url(url):
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py
index e25420aa..04d24d95 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -37,7 +37,7 @@ import utils
import export
import feedgetter
import models
-import search as fastsearch
+#import search as fastsearch
from forms import SigninForm, AddFeedForm, ProfileForm
from pyaggr3g470r import app, db
from pyaggr3g470r.models import User, Feed, Article, Role
@@ -377,7 +377,7 @@ def index_database():
Index all the database.
"""
user = models.User.objects(email=g.user.email).first()
- fastsearch.create_index(user.feeds)
+ #fastsearch.create_index(user.feeds)
flash('Database indexed.', 'success')
return redirect(url_for('home'))
@@ -387,7 +387,7 @@ def export_articles():
"""
Export all articles.
"""
- user = models.User.objects(email=g.user.email).first()
+ user = User.query.filter(User.id == g.user.id).first()
try:
archive_file, archive_file_name = export.export_html(user.feeds)
except:
@@ -404,7 +404,7 @@ def export_opml():
"""
Export all feeds to OPML.
"""
- user = models.User.objects(email=g.user.email).first()
+ user = User.query.filter(User.id == g.user.id).first()
response = make_response(render_template('opml.xml', user=user, now=datetime.datetime.now()))
response.headers['Content-Type'] = 'application/xml'
response.headers['Content-Disposition'] = 'attachment; filename=feeds.opml'
bgstack15