Add corpus model.

This commit is contained in:
Patrick Jentsch 2019-08-06 12:06:41 +02:00
parent ebba2913f8
commit 46b8550c65

View File

@ -111,6 +111,7 @@ class User(UserMixin, db.Model):
role_id = db.Column(db.Integer, db.ForeignKey('roles.id'))
username = db.Column(db.String(64), unique=True, index=True)
# Relationships
corpora = db.relationship('Corpus', backref='corpus', lazy='dynamic')
jobs = db.relationship('Job', backref='job', lazy='dynamic')
def __repr__(self):
@ -247,6 +248,27 @@ class Job(db.Model):
return '<Job %r>' % self.title
class Corpus(db.Model):
"""
Class to define a corpus.
"""
__tablename__ = 'corpora'
# Primary key
id = db.Column(db.Integer, primary_key=True)
description = db.Column(db.String(64))
title = db.Column(db.String(32))
user_id = db.Column(db.Integer, db.ForeignKey('users.id'))
def __init__(self, **kwargs):
super(Job, self).__init__(**kwargs)
def __repr__(self):
"""
String representation of the corpus. For human readability.
"""
return '<Corpus %r>' % self.title
'''
' Flask-Login is told to use the applications custom anonymous user by setting
' its class in the login_manager.anonymous_user attribute.