From 0a7f69cc1fc0e068c66ca34b3f4a44067cfe9761 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Thu, 6 Oct 2016 14:16:58 +0200 Subject: Fetch feeds only if the user do not want to use its own crawler. --- src/web/forms.py | 2 ++ src/web/lib/misc_utils.py | 2 +- src/web/models/user.py | 2 ++ src/web/templates/profile.html | 4 ++++ src/web/views/user.py | 1 + 5 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/web') diff --git a/src/web/forms.py b/src/web/forms.py index 69abac46..033ccbbe 100644 --- a/src/web/forms.py +++ b/src/web/forms.py @@ -156,6 +156,8 @@ class ProfileForm(Form): validators.Required(lazy_gettext("Please enter your email."))]) password = PasswordField(lazy_gettext("Password")) password_conf = PasswordField(lazy_gettext("Password Confirmation")) + automatic_crawling = BooleanField(lazy_gettext("Automatic crawling"), + default=True) webpage = URLField(lazy_gettext("Webpage")) twitter = URLField(lazy_gettext("Twitter")) is_public_profile = BooleanField(lazy_gettext("Public profile"), diff --git a/src/web/lib/misc_utils.py b/src/web/lib/misc_utils.py index fc49dd6d..8166df29 100755 --- a/src/web/lib/misc_utils.py +++ b/src/web/lib/misc_utils.py @@ -108,7 +108,7 @@ def fetch(id, feed_id=None): The "asyncio" crawler is launched with the manager. """ cmd = [sys.executable, conf.BASE_DIR + '/manager.py', 'fetch_asyncio', - str(id), str(feed_id)] + '--user_id='+str(id)] return subprocess.Popen(cmd, stdout=subprocess.PIPE) def history(user_id, year=None, month=None): diff --git a/src/web/models/user.py b/src/web/models/user.py index 59c4ad38..2b069728 100644 --- a/src/web/models/user.py +++ b/src/web/models/user.py @@ -48,6 +48,8 @@ class User(db.Model, UserMixin, RightMixin): email = db.Column(db.String(254), index=True, unique=True) pwdhash = db.Column(db.String()) + automatic_crawling = db.Column(db.Boolean(), default=True) + is_public_profile = db.Column(db.Boolean(), default=False) webpage = db.Column(db.String(), default="") twitter = db.Column(db.String(), default="") diff --git a/src/web/templates/profile.html b/src/web/templates/profile.html index d21608cf..39834ca5 100644 --- a/src/web/templates/profile.html +++ b/src/web/templates/profile.html @@ -42,6 +42,10 @@ {{ form.is_public_profile.label }} {{ form.is_public_profile(class_="form-control") }} {% for error in form.is_public_profile.errors %} {{ error }}
{% endfor %}

{{ _('Your profile will be available here.', url=url_for('user.profile_public', nickname=user.nickname) ) }}

+ + {{ form.automatic_crawling.label }} + {{ form.automatic_crawling(class_="form-control") }} {% for error in form.automatic_crawling.errors %} {{ error }}
{% endfor %} +

{{ _('Uncheck if you are using your own crawler.') }}

diff --git a/src/web/views/user.py b/src/web/views/user.py index bf568d69..26d65de3 100644 --- a/src/web/views/user.py +++ b/src/web/views/user.py @@ -107,6 +107,7 @@ def profile(): {'nickname': form.nickname.data, 'email': form.email.data, 'password': form.password.data, + 'automatic_crawling': form.automatic_crawling.data, 'is_public_profile': form.is_public_profile.data, 'webpage': form.webpage.data, 'twitter': form.twitter.data}) -- cgit