aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2016-09-26 07:47:25 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2016-09-26 07:47:25 +0200
commitb049532adfda00de1ab56e9a0869bfed050f632c (patch)
tree8f4f143a601ca43fa890d5c8e0a64a5460ed1907 /src
parentUpdated about page. (diff)
downloadnewspipe-b049532adfda00de1ab56e9a0869bfed050f632c.tar.gz
newspipe-b049532adfda00de1ab56e9a0869bfed050f632c.tar.bz2
newspipe-b049532adfda00de1ab56e9a0869bfed050f632c.zip
Minor improvements.
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap.py2
-rw-r--r--src/conf.py5
-rwxr-xr-xsrc/manager.py3
-rwxr-xr-xsrc/runserver.py1
-rw-r--r--src/web/forms.py3
-rw-r--r--src/web/views/__init__.py1
-rw-r--r--src/web/views/admin.py2
-rw-r--r--src/web/views/user.py1
-rw-r--r--src/web/views/views.py2
9 files changed, 11 insertions, 9 deletions
diff --git a/src/bootstrap.py b/src/bootstrap.py
index 146d9176..8aaba976 100644
--- a/src/bootstrap.py
+++ b/src/bootstrap.py
@@ -9,6 +9,7 @@ import logging
import flask_restless
from urllib.parse import urlsplit
+
def set_logging(log_path, log_level=logging.INFO,
log_format='%(asctime)s %(levelname)s %(message)s'):
formater = logging.Formatter(log_format)
@@ -55,6 +56,7 @@ db = SQLAlchemy(application)
# Create the Flask-Restless API manager.
manager = flask_restless.APIManager(application, flask_sqlalchemy_db=db)
+
def populate_g():
from flask import g
g.db = db
diff --git a/src/conf.py b/src/conf.py
index 8546e3cc..7c573e94 100644
--- a/src/conf.py
+++ b/src/conf.py
@@ -49,10 +49,7 @@ DEFAULTS = {"platform_url": "https://jarr.herokuapp.com/",
}
if not ON_HEROKU:
- try:
- import configparser as confparser
- except:
- import ConfigParser as confparser
+ import configparser as confparser
# load the configuration
config = confparser.SafeConfigParser(defaults=DEFAULTS)
config.read(os.path.join(BASE_DIR, "conf/conf.cfg"))
diff --git a/src/manager.py b/src/manager.py
index 98161555..82a71cc6 100755
--- a/src/manager.py
+++ b/src/manager.py
@@ -9,7 +9,7 @@ from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
import web.models
-from web.controllers import FeedController, UserController
+from web.controllers import UserController
logger = logging.getLogger(__name__)
@@ -54,7 +54,6 @@ def fetch_asyncio(user_id, feed_id):
import asyncio
with application.app_context():
- from flask_login import current_user
from crawler import classic_crawler
ucontr = UserController()
users = []
diff --git a/src/runserver.py b/src/runserver.py
index c7bdbff9..92a03667 100755
--- a/src/runserver.py
+++ b/src/runserver.py
@@ -28,6 +28,7 @@ if conf.ON_HEROKU:
babel = Babel(application)
+
# Jinja filters
def month_name(month_number):
return calendar.month_name[month_number]
diff --git a/src/web/forms.py b/src/web/forms.py
index 905a0b2a..59a7bde5 100644
--- a/src/web/forms.py
+++ b/src/web/forms.py
@@ -163,7 +163,8 @@ class ProfileForm(Form):
refresh_rate = IntegerField(lazy_gettext("Feeds refresh frequency "
"(in minutes)"),
default=60)
- is_public_profile = BooleanField(lazy_gettext("Public profile"), default=True)
+ is_public_profile = BooleanField(lazy_gettext("Public profile"),
+ default=True)
submit = SubmitField(lazy_gettext("Save"))
def validate(self):
diff --git a/src/web/views/__init__.py b/src/web/views/__init__.py
index 1ca5c473..e0e49927 100644
--- a/src/web/views/__init__.py
+++ b/src/web/views/__init__.py
@@ -16,6 +16,7 @@ import conf
from flask import request
from flask import g
+
@g.babel.localeselector
def get_locale():
return request.accept_languages.best_match(conf.LANGUAGES.keys())
diff --git a/src/web/views/admin.py b/src/web/views/admin.py
index 9703894e..493a91c9 100644
--- a/src/web/views/admin.py
+++ b/src/web/views/admin.py
@@ -6,7 +6,7 @@ from werkzeug import generate_password_hash
from web.views.common import admin_permission
from web.lib.utils import redirect_url
-from web.controllers import UserController, ArticleController
+from web.controllers import UserController
from web.forms import InformationMessageForm, UserForm
admin_bp = Blueprint('admin', __name__, url_prefix='/admin')
diff --git a/src/web/views/user.py b/src/web/views/user.py
index df6508f5..541432bb 100644
--- a/src/web/views/user.py
+++ b/src/web/views/user.py
@@ -41,6 +41,7 @@ def profile_public(nickname=None):
feeds=user.feeds,
tag_cloud=tag_cloud)
+
@user_bp.route('/management', methods=['GET', 'POST'])
@login_required
def management():
diff --git a/src/web/views/views.py b/src/web/views/views.py
index ecb4f888..b9db05bf 100644
--- a/src/web/views/views.py
+++ b/src/web/views/views.py
@@ -65,7 +65,7 @@ def popular():
filters = {}
filters['created_date__gt'] = not_added_before
feeds = FeedController().count_by_link(**filters)
- sorted_feeds = sorted(feeds.items(), key=operator.itemgetter(1),
+ sorted_feeds = sorted(list(feeds.items()), key=operator.itemgetter(1),
reverse=True)
return render_template('popular.html', popular=sorted_feeds)
bgstack15