Find other users and see what corpora they have made public.
diff --git a/app/users/routes.py b/app/users/routes.py
index 82d37247..cd3f2ba4 100644
--- a/app/users/routes.py
+++ b/app/users/routes.py
@@ -1,16 +1,13 @@
-from datetime import datetime
from flask import (
abort,
- current_app,
flash,
- Markup,
redirect,
render_template,
send_from_directory,
url_for
)
+from flask_breadcrumbs import register_breadcrumb
from flask_login import current_user, login_required
-from threading import Thread
import os
from app import db
from app.models import Avatar, Corpus, ProfilePrivacySettings, User
@@ -22,13 +19,21 @@ from .forms import (
EditProfileSettingsForm,
EditPublicProfileInformationForm
)
+from .utils import (
+ user_endpoint_arguments_constructor as user_eac,
+ user_dynamic_list_constructor as user_dlc
+)
-@bp.before_request
+
+@bp.route('')
+@register_breadcrumb(bp, '.', 'Users')
@login_required
-def before_request():
- pass
+def users():
+ return redirect(url_for('main.social_area', _anchor='users'))
+
@bp.route('/')
+@register_breadcrumb(bp, '.entity', '', dynamic_list_constructor=user_dlc)
@login_required
def user(user_id):
user = User.query.get_or_404(user_id)
@@ -50,12 +55,13 @@ def user(user_id):
member_since=member_since,
own_public_corpora=own_public_corpora,
user=user.to_json_serializeable(),
- user_id=user_id
+ user_id=user_id,
+ title=user.username
)
-
@bp.route('//avatar')
+@login_required
def profile_avatar(user_id):
user = User.query.get_or_404(user_id)
if user.avatar is None:
@@ -72,6 +78,8 @@ def profile_avatar(user_id):
@bp.route('//edit', methods=['GET', 'POST'])
+@register_breadcrumb(bp, '.entity.edit', 'Edit', endpoint_arguments_constructor=user_eac)
+@login_required
def edit_profile(user_id):
user = User.query.get_or_404(user_id)
if not (user == current_user or current_user.is_administrator()):
diff --git a/app/users/utils.py b/app/users/utils.py
new file mode 100644
index 00000000..e352fe5c
--- /dev/null
+++ b/app/users/utils.py
@@ -0,0 +1,17 @@
+from flask import request, url_for
+from app.models import User
+
+
+def user_endpoint_arguments_constructor():
+ return {'user_id': request.view_args['user_id']}
+
+
+def user_dynamic_list_constructor():
+ user_id = request.view_args['user_id']
+ user = User.query.get_or_404(user_id)
+ return [
+ {
+ 'text': user.username,
+ 'url': url_for('.user', user_id=user_id)
+ }
+ ]