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
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
5a67164d
Commit
5a67164d
authored
5 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Add corpus to database after creation.
parent
4ec0acc0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/main/views.py
+8
-5
8 additions, 5 deletions
app/main/views.py
app/models.py
+1
-1
1 addition, 1 deletion
app/models.py
with
9 additions
and
6 deletions
app/main/views.py
+
8
−
5
View file @
5a67164d
from
datetime
import
datetime
from
flask
import
current_app
,
flash
,
redirect
,
render_template
,
url_for
from
flask_login
import
current_user
,
login_required
from
..models
import
User
from
..models
import
User
,
Corpus
from
..tables
import
AdminUserTable
,
AdminUserItem
from
.
import
main
from
.forms
import
CreateCorpusForm
from
..decorators
import
admin_required
from
..
import
db
import
hashlib
import
os
...
...
@@ -27,15 +28,17 @@ def dashboard():
if
create_corpus_form
.
validate_on_submit
():
app
=
current_app
.
_get_current_object
()
id
=
hashlib
.
md5
(
(
current_user
.
username
+
'
_
'
+
datetime
.
now
().
isoformat
()).
encode
()
).
hexdigest
()
corpus
=
{
'
description
'
:
create_corpus_form
.
description
.
data
,
'
id
'
:
id
,
'
creator
'
:
current_user
.
id
,
'
title
'
:
create_corpus_form
.
title
.
data
}
dir
=
os
.
path
.
join
(
app
.
config
[
'
OPAQUE_FILES
'
],
'
corpora
'
,
id
)
corpus
=
Corpus
(
description
=
create_corpus_form
.
description
.
data
,
title
=
create_corpus_form
.
title
.
data
,
user_id
=
current_user
.
id
)
db
.
session
.
add
(
corpus
)
db
.
session
.
commit
()
dir
=
os
.
path
.
join
(
app
.
config
[
'
OPAQUE_STORAGE
'
],
'
corpora
'
,
str
(
corpus
.
id
))
try
:
os
.
makedirs
(
dir
)
...
...
This diff is collapsed.
Click to expand it.
app/models.py
+
1
−
1
View file @
5a67164d
...
...
@@ -260,7 +260,7 @@ class Corpus(db.Model):
user_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
'
users.id
'
))
def
__init__
(
self
,
**
kwargs
):
super
(
Job
,
self
).
__init__
(
**
kwargs
)
super
(
Corpus
,
self
).
__init__
(
**
kwargs
)
def
__repr__
(
self
):
"""
...
...
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