mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-26 03:14:19 +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')
|
app.register_blueprint(services_blueprint, url_prefix='/services')
|
||||||
|
|
||||||
from .users import bp as users_blueprint
|
from .users import bp as users_blueprint
|
||||||
|
default_breadcrumb_root(users_blueprint, '.users')
|
||||||
app.register_blueprint(users_blueprint, url_prefix='/users')
|
app.register_blueprint(users_blueprint, url_prefix='/users')
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
@ -4,7 +4,7 @@ from app.models import SpaCyNLPPipelineModel
|
|||||||
|
|
||||||
def spacy_nlp_pipeline_model_dlc():
|
def spacy_nlp_pipeline_model_dlc():
|
||||||
snpm_id = request.view_args['spacy_nlp_pipeline_model_id']
|
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 [
|
return [
|
||||||
{
|
{
|
||||||
'text': f'{snpm.title} {snpm.version}',
|
'text': f'{snpm.title} {snpm.version}',
|
||||||
|
@ -4,7 +4,7 @@ from app.models import TesseractOCRPipelineModel
|
|||||||
|
|
||||||
def tesseract_ocr_pipeline_model_dlc():
|
def tesseract_ocr_pipeline_model_dlc():
|
||||||
topm_id = request.view_args['tesseract_ocr_pipeline_model_id']
|
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 [
|
return [
|
||||||
{
|
{
|
||||||
'text': f'{topm.title} {topm.version}',
|
'text': f'{topm.title} {topm.version}',
|
||||||
|
@ -8,7 +8,7 @@ def corpus_endpoint_arguments_constructor():
|
|||||||
|
|
||||||
def corpus_dynamic_list_constructor():
|
def corpus_dynamic_list_constructor():
|
||||||
corpus_id = request.view_args['corpus_id']
|
corpus_id = request.view_args['corpus_id']
|
||||||
corpus = Corpus.query.get(corpus_id)
|
corpus = Corpus.query.get_or_404(corpus_id)
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
'text': f'<i class="material-icons left">book</i>{corpus.title}',
|
'text': f'<i class="material-icons left">book</i>{corpus.title}',
|
||||||
|
@ -21,7 +21,7 @@ def corpora():
|
|||||||
|
|
||||||
|
|
||||||
@bp.route('/<hashid:job_id>')
|
@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
|
@login_required
|
||||||
def job(job_id):
|
def job(job_id):
|
||||||
job = Job.query.get_or_404(job_id)
|
job = Job.query.get_or_404(job_id)
|
||||||
|
@ -4,7 +4,7 @@ from app.models import Job
|
|||||||
|
|
||||||
def job_dynamic_list_constructor():
|
def job_dynamic_list_constructor():
|
||||||
job_id = request.view_args['job_id']
|
job_id = request.view_args['job_id']
|
||||||
job = Job.query.get(job_id)
|
job = Job.query.get_or_404(job_id)
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
'text': f'<i class="nopaque-icons left service-icons" data-service="{job.service}"></i>{job.title}',
|
'text': f'<i class="nopaque-icons left service-icons" data-service="{job.service}"></i>{job.title}',
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col s12">
|
<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>
|
<p>Find other users and see what corpora they have made public.</p>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
from datetime import datetime
|
|
||||||
from flask import (
|
from flask import (
|
||||||
abort,
|
abort,
|
||||||
current_app,
|
|
||||||
flash,
|
flash,
|
||||||
Markup,
|
|
||||||
redirect,
|
redirect,
|
||||||
render_template,
|
render_template,
|
||||||
send_from_directory,
|
send_from_directory,
|
||||||
url_for
|
url_for
|
||||||
)
|
)
|
||||||
|
from flask_breadcrumbs import register_breadcrumb
|
||||||
from flask_login import current_user, login_required
|
from flask_login import current_user, login_required
|
||||||
from threading import Thread
|
|
||||||
import os
|
import os
|
||||||
from app import db
|
from app import db
|
||||||
from app.models import Avatar, Corpus, ProfilePrivacySettings, User
|
from app.models import Avatar, Corpus, ProfilePrivacySettings, User
|
||||||
@ -22,13 +19,21 @@ from .forms import (
|
|||||||
EditProfileSettingsForm,
|
EditProfileSettingsForm,
|
||||||
EditPublicProfileInformationForm
|
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
|
@login_required
|
||||||
def before_request():
|
def users():
|
||||||
pass
|
return redirect(url_for('main.social_area', _anchor='users'))
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/<hashid:user_id>')
|
@bp.route('/<hashid:user_id>')
|
||||||
|
@register_breadcrumb(bp, '.entity', '', dynamic_list_constructor=user_dlc)
|
||||||
@login_required
|
@login_required
|
||||||
def user(user_id):
|
def user(user_id):
|
||||||
user = User.query.get_or_404(user_id)
|
user = User.query.get_or_404(user_id)
|
||||||
@ -50,12 +55,13 @@ def user(user_id):
|
|||||||
member_since=member_since,
|
member_since=member_since,
|
||||||
own_public_corpora=own_public_corpora,
|
own_public_corpora=own_public_corpora,
|
||||||
user=user.to_json_serializeable(),
|
user=user.to_json_serializeable(),
|
||||||
user_id=user_id
|
user_id=user_id,
|
||||||
|
title=user.username
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/<hashid:user_id>/avatar')
|
@bp.route('/<hashid:user_id>/avatar')
|
||||||
|
@login_required
|
||||||
def profile_avatar(user_id):
|
def profile_avatar(user_id):
|
||||||
user = User.query.get_or_404(user_id)
|
user = User.query.get_or_404(user_id)
|
||||||
if user.avatar is None:
|
if user.avatar is None:
|
||||||
@ -72,6 +78,8 @@ def profile_avatar(user_id):
|
|||||||
|
|
||||||
|
|
||||||
@bp.route('/<hashid:user_id>/edit', methods=['GET', 'POST'])
|
@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):
|
def edit_profile(user_id):
|
||||||
user = User.query.get_or_404(user_id)
|
user = User.query.get_or_404(user_id)
|
||||||
if not (user == current_user or current_user.is_administrator()):
|
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