diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2016-10-24 13:30:11 +0200 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2016-10-24 13:30:11 +0200 |
commit | 106d83ea8157c6f14a399716381ddf07ac21a024 (patch) | |
tree | fab0f6c0fa0dd449b52242377da17c97e0bb8168 /src/web | |
parent | Updated deprecated code. (diff) | |
download | newspipe-106d83ea8157c6f14a399716381ddf07ac21a024.tar.gz newspipe-106d83ea8157c6f14a399716381ddf07ac21a024.tar.bz2 newspipe-106d83ea8157c6f14a399716381ddf07ac21a024.zip |
add the possibility to mak a feed as private
Diffstat (limited to 'src/web')
-rw-r--r-- | src/web/forms.py | 1 | ||||
-rw-r--r-- | src/web/models/feed.py | 1 | ||||
-rw-r--r-- | src/web/templates/edit_feed.html | 10 | ||||
-rw-r--r-- | src/web/views/feed.py | 3 | ||||
-rw-r--r-- | src/web/views/user.py | 8 | ||||
-rw-r--r-- | src/web/views/views.py | 1 |
6 files changed, 20 insertions, 4 deletions
diff --git a/src/web/forms.py b/src/web/forms.py index 4ea646fc..be1650d8 100644 --- a/src/web/forms.py +++ b/src/web/forms.py @@ -191,6 +191,7 @@ class AddFeedForm(Form): submit = SubmitField(lazy_gettext("Save")) category_id = SelectField(lazy_gettext("Category of the feed"), [validators.Optional()]) + private = BooleanField(lazy_gettext("Private"), default=False) def set_category_choices(self, categories): self.category_id.choices = [('0', 'No Category')] diff --git a/src/web/models/feed.py b/src/web/models/feed.py index 362a0d67..7bf2ace3 100644 --- a/src/web/models/feed.py +++ b/src/web/models/feed.py @@ -45,6 +45,7 @@ class Feed(db.Model, RightMixin): enabled = db.Column(db.Boolean(), default=True) created_date = db.Column(db.DateTime(), default=datetime.utcnow) filters = db.Column(db.PickleType, default=[]) + private = db.Column(db.Boolean(), default=False) # cache handling etag = db.Column(db.String(), default="") diff --git a/src/web/templates/edit_feed.html b/src/web/templates/edit_feed.html index ab624f15..128b54fb 100644 --- a/src/web/templates/edit_feed.html +++ b/src/web/templates/edit_feed.html @@ -45,6 +45,16 @@ </div> </div> </div> + + <div class="form-group"> + <label for="{{ form.private.id }}" class="col-sm-3 control-label">{{ form.private.label }}</label> + <div class="col-sm-9"> + <div class="checkbox"> + {{ form.private(class_="checkbox", style="margin-left: 0px;") }} + </div> + </div> + </div> + <div class="form-group"> <label class="col-sm-3 control-label">{{ _("Filters") }}</label> <div class="col-sm-1"> diff --git a/src/web/views/feed.py b/src/web/views/feed.py index 6338f320..92aef10a 100644 --- a/src/web/views/feed.py +++ b/src/web/views/feed.py @@ -191,7 +191,8 @@ def process_form(feed_id=None): # Edit an existing feed feed_attr = {'title': form.title.data, 'enabled': form.enabled.data, 'link': form.link.data, 'site_link': form.site_link.data, - 'filters': [], 'category_id': form.category_id.data} + 'filters': [], 'category_id': form.category_id.data, + 'private': form.private.data} if not feed_attr['category_id'] or feed_attr['category_id'] == '0': del feed_attr['category_id'] diff --git a/src/web/views/user.py b/src/web/views/user.py index fc94f205..682e20ff 100644 --- a/src/web/views/user.py +++ b/src/web/views/user.py @@ -29,6 +29,10 @@ def profile_public(nickname=None): if not user.is_public_profile: return redirect(url_for('home')) + filters = {} + filters['private__eq'] = False + feeds = FeedController(user.id).read(**filters).all() + """word_size = 6 filters = {} filters['retrieved_date__gt'] = datetime.now() - timedelta(weeks=10) @@ -36,9 +40,7 @@ def profile_public(nickname=None): top_words = misc_utils.top_words(articles, n=50, size=int(word_size)) tag_cloud = misc_utils.tag_cloud(top_words)""" - return render_template('profile_public.html', - user=user, - feeds=user.feeds) + return render_template('profile_public.html', user=user, feeds=feeds) @user_bp.route('/management', methods=['GET', 'POST']) diff --git a/src/web/views/views.py b/src/web/views/views.py index 8703edba..8024b27d 100644 --- a/src/web/views/views.py +++ b/src/web/views/views.py @@ -64,6 +64,7 @@ def popular(): filters = {} filters['created_date__gt'] = not_added_before + filters['private__eq'] = False feeds = FeedController().count_by_link(**filters) sorted_feeds = sorted(list(feeds.items()), key=operator.itemgetter(1), reverse=True) |