diff options
Diffstat (limited to 'pyaggr3g470r')
-rw-r--r-- | pyaggr3g470r/emails.py | 4 | ||||
-rw-r--r-- | pyaggr3g470r/export.py | 2 | ||||
-rw-r--r-- | pyaggr3g470r/models.py | 8 | ||||
-rw-r--r-- | pyaggr3g470r/rest.py | 2 | ||||
-rw-r--r-- | pyaggr3g470r/search.py | 2 | ||||
-rw-r--r-- | pyaggr3g470r/templates/home.html | 5 | ||||
-rw-r--r-- | pyaggr3g470r/templates/layout.html | 2 | ||||
-rwxr-xr-x | pyaggr3g470r/utils.py | 5 | ||||
-rw-r--r-- | pyaggr3g470r/views.py | 18 |
9 files changed, 25 insertions, 23 deletions
diff --git a/pyaggr3g470r/emails.py b/pyaggr3g470r/emails.py index 7d4d4c55..6ec4e74d 100644 --- a/pyaggr3g470r/emails.py +++ b/pyaggr3g470r/emails.py @@ -26,9 +26,9 @@ from email.mime.text import MIMEText from postmark import PMMail -import utils +from pyaggr3g470r import utils import conf -from decorators import async +from pyaggr3g470r.decorators import async logger = logging.getLogger(__name__) diff --git a/pyaggr3g470r/export.py b/pyaggr3g470r/export.py index 1341e58f..4c768483 100644 --- a/pyaggr3g470r/export.py +++ b/pyaggr3g470r/export.py @@ -42,7 +42,7 @@ from datetime import datetime from flask import jsonify import conf -import models +from pyaggr3g470r import models def HTML_HEADER(title="pyAggr3g470r", css="./style.css"): diff --git a/pyaggr3g470r/models.py b/pyaggr3g470r/models.py index 5139c1d4..3e3f76d4 100644 --- a/pyaggr3g470r/models.py +++ b/pyaggr3g470r/models.py @@ -28,7 +28,7 @@ __license__ = "GPLv3" import re import json -import random, base64, hashlib +import random, hashlib from datetime import datetime from sqlalchemy import asc, desc from werkzeug import generate_password_hash, check_password_hash @@ -45,8 +45,10 @@ class User(db.Model, UserMixin): email = db.Column(db.String(254), index = True, unique = True) pwdhash = db.Column(db.String()) roles = db.relationship('Role', backref = 'user', lazy = 'dynamic') - activation_key = db.Column(db.String(86), default = base64.b64encode(hashlib.sha512( str(random.getrandbits(256)) ).digest(), - random.choice(['rA','aZ','gQ','hH','hG','aR','DD'])).rstrip('==')) + activation_key = db.Column(db.String(86), default = + hashlib.sha512( + str(random.getrandbits(256)).encode("utf-8") + ).hexdigest()) date_created = db.Column(db.DateTime(), default=datetime.now) last_seen = db.Column(db.DateTime(), default=datetime.now) feeds = db.relationship('Feed', backref = 'subscriber', lazy = 'dynamic', cascade='all,delete-orphan') diff --git a/pyaggr3g470r/rest.py b/pyaggr3g470r/rest.py index 8dcdf43f..a3c63c1d 100644 --- a/pyaggr3g470r/rest.py +++ b/pyaggr3g470r/rest.py @@ -34,7 +34,7 @@ from flask.ext.restful import Resource, reqparse import conf if not conf.ON_HEROKU: - import search as fastsearch + import pyaggr3g470r.search as fastsearch from pyaggr3g470r import api, db from pyaggr3g470r.models import User, Article, Feed diff --git a/pyaggr3g470r/search.py b/pyaggr3g470r/search.py index a7832c00..0dc953b4 100644 --- a/pyaggr3g470r/search.py +++ b/pyaggr3g470r/search.py @@ -36,7 +36,7 @@ from whoosh.qparser import QueryParser from whoosh.writing import AsyncWriter from collections import defaultdict -import utils +from pyaggr3g470r import utils indexdir = "./pyaggr3g470r/var/indexdir" diff --git a/pyaggr3g470r/templates/home.html b/pyaggr3g470r/templates/home.html index 32671ebb..5c9cf0f7 100644 --- a/pyaggr3g470r/templates/home.html +++ b/pyaggr3g470r/templates/home.html @@ -12,10 +12,10 @@ </div> {% else %} <div id="affix-nav" class="col-md-3 sidebar hidden-xs hidden-sm"> - <ul class="nav sidenav navbar-collapse pre-scrollable" data-offset-top="0" data-offset-bottom="0" style="min-height: 600px;"> + <ul class="nav sidenav navbar-collapse pre-scrollable" data-offset-top="0" data-offset-bottom="0" style="min-height: 650px;"> <li><a href="{{ gen_url(feed=0) }}"> {% if not feed_id %}<b>{% endif %} - {{ _('All feeds') }} + {{ _('All feeds') }} <span id="total-unread" class="badge pull-right">{{ articles.__len__() }}</span> {% if not feed_id %}</b>{% endif %} </a></li> {% for fid, nbunread in unread|dictsort(by='value')|reverse %} @@ -52,7 +52,6 @@ </ul> </div> <div class="container col-md-9"> - <h1>{{ _('Articles') }} (<span id="total-unread">{{ articles.__len__() }}</span>)</h1> <div id="filters" data-filter="{{ filter_ }}"> {% if filter_ == 'all' %}<b>{% endif %} <a href="{{ gen_url(filter_='all') }}">{{ _('All') }}</a> diff --git a/pyaggr3g470r/templates/layout.html b/pyaggr3g470r/templates/layout.html index 6f159143..5509cc4d 100644 --- a/pyaggr3g470r/templates/layout.html +++ b/pyaggr3g470r/templates/layout.html @@ -40,7 +40,7 @@ deployed on Heroku or on a traditional server." /> } /* First level of nav */ .sidenav { - margin-top: 60px; + margin-top: 10px; margin-bottom: 0px; padding-top: 10px; padding-bottom: 0px; diff --git a/pyaggr3g470r/utils.py b/pyaggr3g470r/utils.py index 0238e9e5..d0419362 100755 --- a/pyaggr3g470r/utils.py +++ b/pyaggr3g470r/utils.py @@ -43,7 +43,10 @@ import datetime import operator import urllib import subprocess -from urlparse import urlparse, parse_qs, urlunparse +try: + from urlparse import urlparse, parse_qs, urlunparse +except: + from urllib.parse import urlparse, parse_qs, urlunparse from bs4 import BeautifulSoup from collections import Counter from contextlib import contextmanager diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index 6e8b35d2..cf50dae3 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -42,16 +42,15 @@ from sqlalchemy.exc import IntegrityError from werkzeug import generate_password_hash import conf -import utils -import export -import emails -if not conf.ON_HEROKU: - import search as fastsearch -from forms import SignupForm, SigninForm, AddFeedForm, \ - ProfileForm, InformationMessageForm, RecoverPasswordForm +from pyaggr3g470r import utils, emails, export from pyaggr3g470r import app, db, allowed_file, babel from pyaggr3g470r.models import User, Feed, Article, Role from pyaggr3g470r.decorators import feed_access_required +from pyaggr3g470r.forms import SignupForm, SigninForm, AddFeedForm, \ + ProfileForm, InformationMessageForm, RecoverPasswordForm +if not conf.ON_HEROKU: + import pyaggr3g470r.search as fastsearch + Principal(app) # Create a permission with a single Need, in this case a RoleNeed. @@ -914,9 +913,8 @@ def disable_user(user_id=None): flash(gettext('Problem while sending activation email') + ': ' + str(e), 'danger') else: - import random, base64, hashlib - user.activation_key = base64.b64encode(hashlib.sha512( str(random.getrandbits(256)) ).digest(), - random.choice(['rA','aZ','gQ','hH','hG','aR','DD'])).rstrip('==') + import random, hashlib + user.activation_key = hashlib.sha512(str(random.getrandbits(256)).encode("utf-8")).hexdigest() flash(gettext('Account of the user') + ' ' + user.nickname + ' ' + gettext('successfully disabled.'), 'success') db.session.commit() else: |