Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

49 rindas
1.7KB

  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. projectUrl = db.Column(db.Text)
  27. repositoryUrl = db.Column(db.Text)
  28. expertiseToUse = db.Column(db.Text)
  29. expertiseToHost = db.Column(db.Text)
  30. dependencies = db.Column(db.Text)
  31. ingestFormats = db.Column(db.Text)
  32. outputFormats = db.Column(db.Text)
  33. status = db.Column(db.Text)
  34. publisherUrl = db.Column(db.Text)
  35. zoteroUrl = db.Column(db.Text)
  36. # table for relationships
  37. class Relationship(db.Model):
  38. __tablename__ = 'Relationship'
  39. id = db.Column(db.Integer, primary_key=True) # primary keys are required by SQLAlchemy
  40. first_resource_id = db.Column(db.Integer)
  41. second_resource_id = db.Column(db.Integer)