Commit fa3d2b43c28cacf50183fcfffa14a75547cc0abb

Authored by Antoine Goutenoir
1 parent 0b094aac
Exists in master

Conflate the database model to accept the output data.

Showing 1 changed file with 12 additions and 3 deletions   Show diff stats
flaskr/models.py
  1 +from flaskr.core import generate_unique_id
1 2 from flask_sqlalchemy import SQLAlchemy
2 3 from flask_login import UserMixin, AnonymousUserMixin
3 4 from werkzeug.security import generate_password_hash, check_password_hash
4 5 import enum
5 6  
6   -
7 7 # These are not the emission "models" in the scientific meaning of the word.
8 8 # They are the SQL Database Models.
9 9 # These are also named Entities, in other conventions (we're following flasks")
... ... @@ -22,10 +22,15 @@ class StatusEnum(enum.Enum):
22 22  
23 23 class Estimation(db.Model):
24 24 id = db.Column(db.Integer(), primary_key=True)
  25 + public_id = db.Column(
  26 + db.Unicode(),
  27 + default=lambda: generate_unique_id(),
  28 + unique=True
  29 + )
25 30 email = db.Column(db.Unicode(1024))
26 31 first_name = db.Column(db.Unicode(1024)) # Antoine
27 32 last_name = db.Column(db.Unicode(1024)) # Goutenoir
28   - status = db.Column(db.Enum(StatusEnum))
  33 + status = db.Column(db.Enum(StatusEnum), default=StatusEnum.pending)
29 34  
30 35 # City, Country
31 36 # One address per line
... ... @@ -34,6 +39,10 @@ class Estimation(db.Model):
34 39  
35 40 compute_optimal_destination = db.Column(db.Boolean())
36 41  
  42 + output_as_yaml = db.Column(db.UnicodeText())
  43 + warnings = db.Column(db.UnicodeText())
  44 + errors = db.Column(db.UnicodeText())
  45 +
37 46  
38 47 # USERS #######################################################################
39 48  
... ... @@ -72,4 +81,4 @@ class User(db.Model, UserMixin):
72 81 return self.id
73 82  
74 83 def __repr__(self):
75   - return '<User %r>' % self.username
76 84 \ No newline at end of file
  85 + return '<User %r>' % self.username
... ...