From 46b8550c65475b68a3b2bc59f42427e8d6f89a5c Mon Sep 17 00:00:00 2001
From: Patrick Jentsch <p.jentsch@uni-bielefeld.de>
Date: Tue, 6 Aug 2019 12:06:41 +0200
Subject: [PATCH] Add corpus model.

---
 app/models.py | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/app/models.py b/app/models.py
index 41a7ca5a..41c8f271 100644
--- a/app/models.py
+++ b/app/models.py
@@ -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 application’s custom anonymous user by setting
 ' its class in the login_manager.anonymous_user attribute.
-- 
GitLab