aboutsummaryrefslogtreecommitdiff
path: root/src/web
diff options
context:
space:
mode:
Diffstat (limited to 'src/web')
-rw-r--r--src/web/forms.py1
-rw-r--r--src/web/models/user.py1
-rw-r--r--src/web/templates/feed_list.html50
-rw-r--r--src/web/templates/profile.html3
-rw-r--r--src/web/templates/profile_public.html16
-rw-r--r--src/web/views/user.py25
6 files changed, 71 insertions, 25 deletions
diff --git a/src/web/forms.py b/src/web/forms.py
index e73cfb98..4770f70c 100644
--- a/src/web/forms.py
+++ b/src/web/forms.py
@@ -162,6 +162,7 @@ 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)
submit = SubmitField(lazy_gettext("Save"))
def validate(self):
diff --git a/src/web/models/user.py b/src/web/models/user.py
index e8ac1d3b..3e4ffcac 100644
--- a/src/web/models/user.py
+++ b/src/web/models/user.py
@@ -45,6 +45,7 @@ class User(db.Model, UserMixin, RightMixin):
nickname = db.Column(db.String(), unique=True)
email = db.Column(db.String(254), index=True, unique=True)
pwdhash = db.Column(db.String())
+ is_public_profile = db.Column(db.Boolean(), default=False)
date_created = db.Column(db.DateTime(), default=datetime.now)
last_seen = db.Column(db.DateTime(), default=datetime.now)
refresh_rate = db.Column(db.Integer, default=60) # in minutes
diff --git a/src/web/templates/feed_list.html b/src/web/templates/feed_list.html
index 093ed631..04543e4c 100644
--- a/src/web/templates/feed_list.html
+++ b/src/web/templates/feed_list.html
@@ -4,36 +4,44 @@
<thead>
<tr>
<th>#</th>
- <th>{{ _('Status') }}</th>
+ {% if current_user.is_authenticated and current_user.id == user.id %}
+ <th>{{ _('Status') }}</th>
+ {% endif %}
<th>{{ _('Title') }}</th>
<th>{{ _('Site') }}</th>
- <th>{{ _('Articles') }}</th>
- <th>{{ _('Actions') }}</th>
+ {% if current_user.is_authenticated and current_user.id == user.id %}
+ <th>{{ _('Articles') }}</th>
+ <th>{{ _('Actions') }}</th>
+ {% endif %}
</tr>
</thead>
<tbody>
{% for feed in feeds %}
- <tr {% if not feed.enabled %}class="warning"{% endif %}>
+ <tr {% if not feed.enabled and current_user.is_authenticated %}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>
+ {% if current_user.is_authenticated and current_user.id == user.id %}
+ <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>
+ {% endif %}
<td>{% if feed.icon_url %}<img src="{{ url_for('icon.icon', url=feed.icon_url) }}" width="16px" />&nbsp;{% endif %}{{ feed.title }}</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("feed.feed", feed_id=feed.id) }}"><i class="glyphicon glyphicon-info-sign" title="{{ _('Information') }}"></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.duplicates", feed_id=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>
+ {% if current_user.is_authenticated and current_user.id == user.id %}
+ <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-info-sign" title="{{ _('Information') }}"></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.duplicates", feed_id=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>
+ {% endif %}
</tr>
{% endfor %}
</tbody>
diff --git a/src/web/templates/profile.html b/src/web/templates/profile.html
index acd593b2..8751446f 100644
--- a/src/web/templates/profile.html
+++ b/src/web/templates/profile.html
@@ -34,6 +34,9 @@
{{ form.refresh_rate.label }}
{{ form.refresh_rate(class_="form-control") }} {% for error in form.refresh_rate.errors %} <span style="color: red;">{{ error }}<br /></span>{% endfor %}
+
+ {{ form.is_public_profile.label }}
+ {{ form.is_public_profile(class_="form-control") }} {% for error in form.is_public_profile.errors %} <span style="color: red;">{{ error }}<br /></span>{% endfor %}
<br />
{{ form.submit(class_="btn") }}
</form>
diff --git a/src/web/templates/profile_public.html b/src/web/templates/profile_public.html
new file mode 100644
index 00000000..04beee8e
--- /dev/null
+++ b/src/web/templates/profile_public.html
@@ -0,0 +1,16 @@
+{% extends "layout.html" %}
+{% block content %}
+<div class="container">
+ <h1>{{ user.nickname }}</h1>
+ <div class="row">
+ <div class="col-md-6">
+ <p>{{ _('Member since') }} {{ user.date_created | datetime }}.</p>
+ <p>{{ _('Last seen:') }} {{ user.last_seen | datetime }}.</p>
+ </div>
+ </div>
+
+ <h2>Feeds</h2>
+ {% include "feed_list.html" %}
+
+</div><!-- /.container -->
+{% endblock %}
diff --git a/src/web/views/user.py b/src/web/views/user.py
index 229530d1..bd12010c 100644
--- a/src/web/views/user.py
+++ b/src/web/views/user.py
@@ -18,6 +18,22 @@ users_bp = Blueprint('users', __name__, url_prefix='/users')
user_bp = Blueprint('user', __name__, url_prefix='/user')
+@user_bp.route('/<string:nickname>', methods=['GET'])
+def profile_public(nickname=None):
+ """
+ Display the public profile of the user.
+ """
+ user_contr = UserController()
+ user = user_contr.get(nickname=nickname)
+ if not user.is_public_profile:
+ return redirect(url_for('home'))
+ art_contr = ArticleController(user.id)
+ return render_template('profile_public.html',
+ user=user,
+ feeds=user.feeds,
+ unread_article_count=art_contr.count_by_category(readed=False),
+ article_count=art_contr.count_by_category())
+
@user_bp.route('/management', methods=['GET', 'POST'])
@login_required
def management():
@@ -80,10 +96,11 @@ def profile():
if request.method == 'POST':
if form.validate():
user_contr.update({'id': current_user.id},
- {'nickname': form.nickname.data,
- 'email': form.email.data,
- 'password': form.password.data,
- 'refresh_rate': form.refresh_rate.data})
+ {'nickname': form.nickname.data,
+ 'email': form.email.data,
+ 'password': form.password.data,
+ 'refresh_rate': form.refresh_rate.data,
+ 'is_public_profile': form.is_public_profile.data})
flash(gettext('User %(nick)s successfully updated',
nick=user.nickname), 'success')
bgstack15