mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 02:44:18 +00:00
Add breadcrumbs to users package
This commit is contained in:
parent
c91004d6ba
commit
a9767bf3c3
@ -91,6 +91,7 @@ def create_app(config: Config = Config) -> Flask:
|
||||
app.register_blueprint(services_blueprint, url_prefix='/services')
|
||||
|
||||
from .users import bp as users_blueprint
|
||||
default_breadcrumb_root(users_blueprint, '.users')
|
||||
app.register_blueprint(users_blueprint, url_prefix='/users')
|
||||
|
||||
return app
|
||||
|
@ -4,7 +4,7 @@ from app.models import SpaCyNLPPipelineModel
|
||||
|
||||
def spacy_nlp_pipeline_model_dlc():
|
||||
snpm_id = request.view_args['spacy_nlp_pipeline_model_id']
|
||||
snpm = SpaCyNLPPipelineModel.query.get(snpm_id)
|
||||
snpm = SpaCyNLPPipelineModel.query.get_or_404(snpm_id)
|
||||
return [
|
||||
{
|
||||
'text': f'{snpm.title} {snpm.version}',
|
||||
|
@ -4,7 +4,7 @@ from app.models import TesseractOCRPipelineModel
|
||||
|
||||
def tesseract_ocr_pipeline_model_dlc():
|
||||
topm_id = request.view_args['tesseract_ocr_pipeline_model_id']
|
||||
topm = TesseractOCRPipelineModel.query.get(topm_id)
|
||||
topm = TesseractOCRPipelineModel.query.get_or_404(topm_id)
|
||||
return [
|
||||
{
|
||||
'text': f'{topm.title} {topm.version}',
|
||||
|
@ -8,7 +8,7 @@ def corpus_endpoint_arguments_constructor():
|
||||
|
||||
def corpus_dynamic_list_constructor():
|
||||
corpus_id = request.view_args['corpus_id']
|
||||
corpus = Corpus.query.get(corpus_id)
|
||||
corpus = Corpus.query.get_or_404(corpus_id)
|
||||
return [
|
||||
{
|
||||
'text': f'<i class="material-icons left">book</i>{corpus.title}',
|
||||
|
@ -21,7 +21,7 @@ def corpora():
|
||||
|
||||
|
||||
@bp.route('/<hashid:job_id>')
|
||||
@register_breadcrumb(bp, '.job', '', dynamic_list_constructor=job_dlc)
|
||||
@register_breadcrumb(bp, '.entity', '', dynamic_list_constructor=job_dlc)
|
||||
@login_required
|
||||
def job(job_id):
|
||||
job = Job.query.get_or_404(job_id)
|
||||
|
@ -4,7 +4,7 @@ from app.models import Job
|
||||
|
||||
def job_dynamic_list_constructor():
|
||||
job_id = request.view_args['job_id']
|
||||
job = Job.query.get(job_id)
|
||||
job = Job.query.get_or_404(job_id)
|
||||
return [
|
||||
{
|
||||
'text': f'<i class="nopaque-icons left service-icons" data-service="{job.service}"></i>{job.title}',
|
||||
|
@ -36,7 +36,7 @@
|
||||
</div>
|
||||
|
||||
<div class="col s12">
|
||||
<h3>Other Users</h3>
|
||||
<h3 id="users">Other Users</h3>
|
||||
<p>Find other users and see what corpora they have made public.</p>
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
|
@ -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('/<hashid:user_id>')
|
||||
@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('/<hashid:user_id>/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('/<hashid:user_id>/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()):
|
||||
|
17
app/users/utils.py
Normal file
17
app/users/utils.py
Normal file
@ -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)
|
||||
}
|
||||
]
|
Loading…
Reference in New Issue
Block a user