You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.8KB

  1. # @name: models.py
  2. # @creation_date: 2021-10-20
  3. # @license: The MIT License <https://opensource.org/licenses/MIT>
  4. # @author: Simon Bowie <ad7588@coventry.ac.uk>
  5. # @purpose: Database models for tables in the database
  6. # @acknowledgements:
  7. # https://www.digitalocean.com/community/tutorials/how-to-add-authentication-to-your-app-with-flask-login
  8. from flask_login import UserMixin
  9. from . import db
  10. from datetime import datetime
  11. # table for users
  12. class User(UserMixin, db.Model):
  13. __tablename__ = 'User'
  14. id = db.Column(db.Integer, primary_key=True) # primary keys are required by SQLAlchemy
  15. email = db.Column(db.String(100), unique=True)
  16. password = db.Column(db.String(100))
  17. name = db.Column(db.String(1000))
  18. # table for resources
  19. class Resource(db.Model):
  20. __tablename__ = 'Resource'
  21. id = db.Column(db.Integer, primary_key=True) # primary keys are required by SQLAlchemy
  22. created = db.Column(db.DateTime, default=datetime.utcnow)
  23. type = db.Column(db.Text)
  24. name = db.Column(db.Text)
  25. description = db.Column(db.Text)
  26. developer = db.Column(db.Text)
  27. developerUrl = db.Column(db.Text)
  28. projectUrl = db.Column(db.Text)
  29. repositoryUrl = db.Column(db.Text)
  30. license = db.Column(db.Text)
  31. scriptingLanguage = db.Column(db.Text)
  32. expertiseToUse = db.Column(db.Text)
  33. expertiseToHost = db.Column(db.Text)
  34. dependencies = db.Column(db.Text)
  35. ingestFormats = db.Column(db.Text)
  36. outputFormats = db.Column(db.Text)
  37. status = db.Column(db.Text)
  38. publisherUrl = db.Column(db.Text)
  39. zoteroUrl = db.Column(db.Text)
  40. # table for relationships
  41. class Relationship(db.Model):
  42. __tablename__ = 'Relationship'
  43. id = db.Column(db.Integer, primary_key=True) # primary keys are required by SQLAlchemy
  44. first_resource_id = db.Column(db.Integer)
  45. second_resource_id = db.Column(db.Integer)