aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrançois Schmidts <francois.schmidts@gmail.com>2015-08-04 18:17:10 +0200
committerFrançois Schmidts <francois.schmidts@gmail.com>2015-08-05 16:11:29 +0200
commitd770bc17899b7e947252237e04a71075999c7f59 (patch)
tree06d726ad99e1fe42bcbda502ba326f02d57dd566
parentredoing the way the crawler wait on itself (diff)
downloadnewspipe-d770bc17899b7e947252237e04a71075999c7f59.tar.gz
newspipe-d770bc17899b7e947252237e04a71075999c7f59.tar.bz2
newspipe-d770bc17899b7e947252237e04a71075999c7f59.zip
refact feed list
-rw-r--r--pyaggr3g470r/templates/admin/user.html35
-rw-r--r--pyaggr3g470r/templates/feed_list.html47
-rw-r--r--pyaggr3g470r/templates/feeds.html44
-rw-r--r--pyaggr3g470r/views/views.py17
4 files changed, 59 insertions, 84 deletions
diff --git a/pyaggr3g470r/templates/admin/user.html b/pyaggr3g470r/templates/admin/user.html
index 21bcd6b6..d1e08c0d 100644
--- a/pyaggr3g470r/templates/admin/user.html
+++ b/pyaggr3g470r/templates/admin/user.html
@@ -14,39 +14,6 @@
</div>
</div>
</div>
- <div class="well">
- {% if user.feeds.all()|count == 0 %}
- <h1>{{ _('This user is not subscribed to any feed.') }}</h1>
- {% else %}
- <h1>{{ _('Feeds') }}</h1>
- <table class="table table-striped">
- <thead>
- <tr>
- <th>#</th>
- <th>{{ _('Title') }}</th>
- <th>{{ _('Feed link') }}</th>
- <th>{{ _('Site link') }}</th>
- <th>{{ _('(unread) articles') }}</th>
- <th>{{ _('Actions') }}</th>
- </tr>
- </thead>
- <tbody>
- {% for feed in user.feeds|sort(attribute="title") %}
- <tr>
- <td>{{ loop.index }}</td>
- <td><a href="{{ url_for("feed.feed", feed_id=feed.id) }}">{%if feed.icon%}<img src="{{ url_for('feed.icon', feed_id=feed.id) }}" width="16px" />{%endif%}{{ feed.title }}</a></td>
- <td>{{ feed.link }}</td>
- <td>{{ feed.site_link }}</td>
- <td>( {{ unread_article_count.get(feed.id, 0) }} ) {{ article_count.get(feed.id, 0) }}</td>
- <td>
- <a href="{{ url_for("feed.feed", feed_id=feed.id) }}"><i class="glyphicon glyphicon-th-list" title="{{ _('Feed') }}"></i></a>
- <a href="{{ url_for("feed.form", feed_id=feed.id) }}"><i class="glyphicon glyphicon-edit" title="{{ _('Edit this feed') }}"></i></a>
- <a href="{{ url_for("feed.delete", feed_id=feed.id) }}"><i class="glyphicon glyphicon-remove" title="{{ _('Delete this feed') }}" onclick="return confirm('{{ _('You are going to delete this feed.') }}');"></i></a>
- </td>
- {% endfor %}
- </tbody>
- </table>
- {% endif %}
- </div>
+ {% include "feed_list.html" %}
</div>
{% endblock %}
diff --git a/pyaggr3g470r/templates/feed_list.html b/pyaggr3g470r/templates/feed_list.html
new file mode 100644
index 00000000..6ef612b4
--- /dev/null
+++ b/pyaggr3g470r/templates/feed_list.html
@@ -0,0 +1,47 @@
+{% if feeds.all()| count == 0 %}
+ <h1>{{_("No feed")}}</h1>
+{% else %}
+<div class="table-responsive">
+ <table class="table table-striped">
+ <thead>
+ <tr>
+ <th>#</th>
+ <th>{{ _('Status') }}</th>
+ <th>{{ _('Title') }}</th>
+ <th>{{ _('Site') }}</th>
+ <th>{{ _('Articles') }}</th>
+ <th>{{ _('Actions') }}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for feed in feeds|sort(attribute="title") %}
+ <tr {% if not feed.enabled %}class="warning"{% endif %}>
+ <td>{{ loop.index }}</td>
+ <td>
+ {% if feed.enabled %}
+ <i class="glyphicon glyphicon-eye-open" title="{{ _('Feed enabled') }}"></i>
+ {% else %}
+ <i class="glyphicon glyphicon-eye-close" title="{{ _('Feed disabled') }}"></i>
+ {% endif %}
+ {% if feed.error_count > conf.DEFAULT_MAX_ERROR %}
+ <i class="glyphicon glyphicon-exclamation-sign" title="{{ _('Feed encountered too much errors.') }}"></i>
+ {% endif %}
+ </td>
+ <td><a href="{{ url_for("feed.feed", feed_id=feed.id) }}" {% if feed.description %}title="{{ feed.description }}"{% endif %}>
+ {% if feed.icon_url %}<img src="{{ url_for('icon.icon', url=feed.icon_url) }}" width="16px" />{% endif %}
+ {{ feed.title }}
+ </a></td>
+ <td><a href="{{ feed.site_link }}">{{ feed.site_link }}</a></td>
+ <td>( {{ unread_article_count.get(feed.id, 0) }} ) {{ article_count.get(feed.id, 0) }}</td>
+ <td>
+ <a href="{{ url_for("home", feed_id=feed.id, filter_="all") }}"><i class="glyphicon glyphicon-th-list" title="{{ _('Articles') }}"></i></a>
+ <a href="{{ url_for("feed.form", feed_id=feed.id) }}"><i class="glyphicon glyphicon-edit" title="{{ _('Edit this feed') }}"></i></a>
+ <a href="/duplicates/{{ feed.id }}"><i class="glyphicon glyphicon-book" title="{{ _('Duplicate articles') }}"></i></a>
+ <a href="{{ url_for("feed.delete", feed_id=feed.id) }}"><i class="glyphicon glyphicon-remove" title="{{ _('Delete this feed') }}" onclick="return confirm('{{ _('You are going to delete this feed.') }}');"></i></a>
+ </td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+</div>
+{% endif %}
diff --git a/pyaggr3g470r/templates/feeds.html b/pyaggr3g470r/templates/feeds.html
index 82af2411..9ba16359 100644
--- a/pyaggr3g470r/templates/feeds.html
+++ b/pyaggr3g470r/templates/feeds.html
@@ -2,48 +2,6 @@
{% block content %}
<div class="container">
<h1>{{ _('You are subscribed to') }} {{ feeds.count() }} {{ _('feeds') }} &middot; {{ _('Add a') }} <a href="{{ url_for("feed.form") }}">{{ _('feed') }}</a></h1>
- <div class="table-responsive">
- <table class="table table-striped">
- <thead>
- <tr>
- <th>#</th>
- <th>{{ _('Status') }}</th>
- <th>{{ _('Title') }}</th>
- <th>{{ _('Site') }}</th>
- <th>{{ _('Articles') }}</th>
- <th>{{ _('Actions') }}</th>
- </tr>
- </thead>
- <tbody>
- {% for feed in feeds|sort(attribute="title") %}
- <tr {% if not feed.enabled %}class="warning"{% endif %}>
- <td>{{ loop.index }}</td>
- <td>
- {% if feed.enabled %}
- <i class="glyphicon glyphicon-eye-open" title="{{ _('Feed enabled') }}"></i>
- {% else %}
- <i class="glyphicon glyphicon-eye-close" title="{{ _('Feed disabled') }}"></i>
- {% endif %}
- {% if feed.error_count > conf.DEFAULT_MAX_ERROR %}
- <i class="glyphicon glyphicon-exclamation-sign" title="{{ _('Feed encountered too much errors.') }}"></i>
- {% endif %}
- </td>
- <td><a href="{{ url_for("feed.feed", feed_id=feed.id) }}" {% if feed.description %}title="{{ feed.description }}"{% endif %}>
- {% if feed.icon_url %}<img src="{{ url_for('icon.icon', url=feed.icon_url) }}" width="16px" />{% endif %}
- {{ feed.title }}
- </a></td>
- <td><a href="{{ feed.site_link }}">{{ feed.site_link }}</a></td>
- <td>( {{ unread_article_count.get(feed.id, 0) }} ) {{ article_count.get(feed.id, 0) }}</td>
- <td>
- <a href="{{ url_for("home", feed_id=feed.id, filter_="all") }}"><i class="glyphicon glyphicon-th-list" title="{{ _('Articles') }}"></i></a>
- <a href="{{ url_for("feed.form", feed_id=feed.id) }}"><i class="glyphicon glyphicon-edit" title="{{ _('Edit this feed') }}"></i></a>
- <a href="/duplicates/{{ feed.id }}"><i class="glyphicon glyphicon-book" title="{{ _('Duplicate articles') }}"></i></a>
- <a href="{{ url_for("feed.delete", feed_id=feed.id) }}"><i class="glyphicon glyphicon-remove" title="{{ _('Delete this feed') }}" onclick="return confirm('{{ _('You are going to delete this feed.') }}');"></i></a>
- </td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- </div>
+ {% include "feed_list.html" %}
</div><!-- /.container -->
{% endblock %}
diff --git a/pyaggr3g470r/views/views.py b/pyaggr3g470r/views/views.py
index 69c2b50b..560bd382 100644
--- a/pyaggr3g470r/views/views.py
+++ b/pyaggr3g470r/views/views.py
@@ -718,8 +718,10 @@ def create_user(user_id=None):
user.activation_key = ""
db.session.add(user)
db.session.commit()
- flash(gettext('User') + ' ' + user.nickname + ' ' + gettext('successfully created.'), 'success')
- return redirect("/admin/edit_user/"+str(user.id))
+ flash("%s %s %s" % (gettext('User'), user.nickname,
+ gettext('successfully created.')),
+ 'success')
+ return redirect(url_for('create_user', user_id=user.id))
else:
return redirect(url_for('create_user'))
@@ -727,11 +729,13 @@ def create_user(user_id=None):
if user_id is not None:
user = User.query.filter(User.id == user_id).first()
form = UserForm(obj=user)
- message = gettext('Edit the user') + ' <i>' + user.nickname + '</i>'
+ message = "%s <i>%s</i>" % (gettext('Edit the user'),
+ user.nickname)
else:
form = UserForm()
message = gettext('Add a new user')
- return render_template('/admin/create_user.html', form=form, message=message)
+ return render_template('/admin/create_user.html',
+ form=form, message=message)
@app.route('/admin/user/<int:user_id>', methods=['GET'])
@login_required
@@ -743,10 +747,9 @@ def user(user_id=None):
user = UserController().get(id=user_id)
if user is not None:
article_contr = ArticleController(user_id)
- return render_template('/admin/user.html', user=user,
+ return render_template('/admin/user.html', user=user, feeds=user.feeds,
article_count=article_contr.count_by_feed(),
- unread_article_count=article_contr.count_by_feed(readed=False),
- )
+ unread_article_count=article_contr.count_by_feed(readed=False))
else:
flash(gettext('This user does not exist.'), 'danger')
bgstack15