Skip to content

Commit

Permalink
Merge branch 'main' into docker-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Pipazoul committed Dec 19, 2023
2 parents fa7f8b2 + c91d323 commit edf1b96
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
4 changes: 4 additions & 0 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,13 @@ class Projects(db.Model):
user_id = db.Column(db.Integer, db.ForeignKey(schema + ".users.id"))
model_id = db.Column(db.Integer, db.ForeignKey(schema + ".documents.id"))
csv_id = db.Column(db.Integer, db.ForeignKey(schema + ".documents.id"))
emprise_id = db.Column(db.Integer, db.ForeignKey(schema + ".documents.id"))

# Object links
user = db.relationship("Users", foreign_keys=user_id)
model = db.relationship("Documents", foreign_keys=model_id, viewonly=True)
csv = db.relationship("Documents", foreign_keys=csv_id, viewonly=True)
emprise = db.relationship("Documents", foreign_keys=emprise_id, viewonly=True)

def __str__(self):
return (
Expand All @@ -140,6 +142,8 @@ def __str__(self):
+ str(self.model_id)
+ '" csv_id="'
+ str(self.csv_id)
+ '" emprise_id="'
+ str(self.emprise_id)
+ '">'
)

Expand Down
14 changes: 9 additions & 5 deletions app/modules/projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,13 @@ def create():
description: ratio
model_id:
type: integer
description: ratio
description: model document
csv_id:
type: integer
description: ratio
description: csv document
emprise_id:
type: integer
description: emprise document
responses:
200:
description: OK
Expand All @@ -155,7 +158,7 @@ def create():
if currentUser:
# Get Body of request
form = request.json
if 'model_id' in form and 'csv_id' in form and 'name' in form and 'bbox' in form and 'nb_plaques_h' in form and 'nb_plaques_v' in form and 'ratio' in form:
if 'name' in form and 'bbox' in form and 'nb_plaques_h' in form and 'nb_plaques_v' in form and 'ratio' in form:
newproject = Projects(
date_create=datetime.datetime.utcnow(),
user_id=currentUser['user_id'],
Expand All @@ -164,8 +167,9 @@ def create():
nb_plaques_h=form['nb_plaques_h'],
nb_plaques_v=form['nb_plaques_v'],
ratio=form['ratio'],
model_id=form['model_id'],
csv_id=form['csv_id']
model_id=form['model_id'] if 'model_id' in form else None,
csv_id=form['csv_id'] if 'csv_id' in form else None,
emprise_id=form['emprise_id'] if 'emprise_id' in form else None
)
db.session.add(newproject)
db.session.commit()
Expand Down
1 change: 1 addition & 0 deletions app/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class ProjectsSchema(ma.SQLAlchemyAutoSchema):
user = ma.Nested("UserSchema", only=("id",), many=False)
model = ma.Nested("DocumentOnlySchema", only=("id",), many=False)
csv = ma.Nested("DocumentOnlySchema", only=("id",), many=False)
emprise = ma.Nested("DocumentOnlySchema", only=("id",), many=False)
class Meta:
model = Projects

Expand Down
7 changes: 6 additions & 1 deletion sql/create-tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ CREATE TABLE base.projects (
id serial PRIMARY KEY,
date_create timestamp without time zone NOT NULL DEFAULT now(),
name character varying(100) NOT NULL,
bbox character varying(100) NOT NULL,
bbox character varying(1000) NOT NULL,
nb_plaques_h INT NOT NULL ,
nb_plaques_v INT NOT NULL ,
ratio INT NOT NULL,
Expand All @@ -77,6 +77,11 @@ CREATE TABLE base.projects (
ON DELETE NO ACTION,
csv_id INTEGER NULL,
FOREIGN KEY (csv_id)
REFERENCES base.documents (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
emprise_id INTEGER NULL,
FOREIGN KEY (emprise_id)
REFERENCES base.documents (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
Expand Down

0 comments on commit edf1b96

Please sign in to comment.