Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nopaque
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Looking for advice? Join the
Matrix channel for GitLab users in Bielefeld
!
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
c8d7de43
Commit
c8d7de43
authored
2 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Extend CorpusList for use in public corpora route
parent
5491cb18
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/corpora/routes.py
+8
-8
8 additions, 8 deletions
app/corpora/routes.py
app/static/js/RessourceLists/CorpusList.js
+9
-0
9 additions, 0 deletions
app/static/js/RessourceLists/CorpusList.js
app/templates/corpora/corpora.html.j2
+28
-0
28 additions, 0 deletions
app/templates/corpora/corpora.html.j2
with
45 additions
and
8 deletions
app/corpora/routes.py
+
8
−
8
View file @
c8d7de43
...
...
@@ -31,14 +31,17 @@ def user_can_delete_corpus(user, corpus):
@bp.route
(
''
)
@login_required
def
corpora
():
corpora
=
Corpus
.
query
.
filter
(
Corpus
.
user_id
==
current_user
.
id
|
Corpus
.
is_public
==
True
).
all
()
return
render_template
(
'
corpora/corpora.html
'
,
corpora
=
corpora
)
query
=
Corpus
.
query
.
filter
(
(
Corpus
.
user_id
==
current_user
.
id
)
|
(
Corpus
.
is_public
==
True
)
)
corpora
=
[
c
.
to_json_serializeable
()
for
c
in
query
.
all
()]
return
render_template
(
'
corpora/corpora.html.j2
'
,
corpora
=
corpora
,
title
=
'
Corpora
'
)
@bp.route
(
'
/create
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
@login_required
def
create_corpus
():
form
=
CreateCorpusForm
(
prefix
=
'
create-corpus-form
'
)
form
=
CreateCorpusForm
()
if
form
.
validate_on_submit
():
try
:
corpus
=
Corpus
.
create
(
...
...
@@ -150,7 +153,7 @@ def create_corpus_file(corpus_id):
corpus
=
Corpus
.
query
.
get_or_404
(
corpus_id
)
if
not
user_can_update_corpus
(
current_user
,
corpus
):
abort
(
403
)
form
=
CreateCorpusFileForm
(
prefix
=
'
create-corpus-file-form
'
)
form
=
CreateCorpusFileForm
()
if
form
.
is_submitted
():
if
not
form
.
validate
():
response
=
{
'
errors
'
:
form
.
errors
}
...
...
@@ -197,10 +200,7 @@ def corpus_file(corpus_id, corpus_file_id):
corpus_file
=
CorpusFile
.
query
.
filter_by
(
corpus_id
=
corpus_id
,
id
=
corpus_file_id
).
first_or_404
()
if
not
(
corpus_file
.
corpus
.
user
==
current_user
or
current_user
.
is_administrator
()):
abort
(
403
)
form
=
UpdateCorpusFileForm
(
data
=
corpus_file
.
to_json_serializeable
(),
prefix
=
'
edit-corpus-file-form
'
)
form
=
UpdateCorpusFileForm
(
data
=
corpus_file
.
to_json_serializeable
())
if
form
.
validate_on_submit
():
form
.
populate_obj
(
corpus_file
)
if
db
.
session
.
is_modified
(
corpus_file
):
...
...
This diff is collapsed.
Click to expand it.
app/static/js/RessourceLists/CorpusList.js
+
9
−
0
View file @
c8d7de43
class
CorpusList
extends
RessourceList
{
static
instances
=
[];
static
getInstance
(
elem
)
{
return
CorpusList
.
instances
.
find
((
instance
)
=>
{
return
instance
.
listjs
.
list
===
elem
;
});
}
static
autoInit
()
{
for
(
let
corpusListElement
of
document
.
querySelectorAll
(
'
.corpus-list:not(.no-autoinit)
'
))
{
new
CorpusList
(
corpusListElement
);
...
...
@@ -59,6 +67,7 @@ class CorpusList extends RessourceList {
constructor
(
listElement
,
options
=
{})
{
super
(
listElement
,
{...
CorpusList
.
options
,
...
options
});
CorpusList
.
instances
.
push
(
this
);
}
init
(
user
)
{
...
...
This diff is collapsed.
Click to expand it.
app/templates/corpora/corpora.html.j2
0 → 100644
+
28
−
0
View file @
c8d7de43
{% extends "base.html.j2" %}
{% block page_content %}
<div class="container">
<div class="row">
<div class="col s12">
<h1 id="title">{{ title }}</h1>
</div>
<div class="col s12" id="corpora">
<div class="card">
<div class="card-content">
<div class="corpus-list"></div>
</div>
</div>
</div>
</div>
</div>
{% endblock page_content %}
{% block scripts %}
{{ super() }}
<script>
let corpusList = CorpusList.getInstance(document.querySelector('#corpora .corpus-list .list'));
corpusList._init({{ corpora|tojson }});
</script>
{% endblock scripts %}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment