diff --git a/code/backend/nest_backend/__main__.py b/code/backend/nest_backend/__main__.py index d58ebb5..fb8dd56 100644 --- a/code/backend/nest_backend/__main__.py +++ b/code/backend/nest_backend/__main__.py @@ -5,7 +5,7 @@ from flask import Flask import os import werkzeug.middleware.proxy_fix from .routes import * -from database import Base, tables +from .database import Base, tables import psycopg2 @@ -19,7 +19,7 @@ app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://postgres:password@localhos Base.app = app Base.init_app(app) # Routes setup -app.add_url_rule("/doa", view_func=page_doa, methods=["GET"]) +app.add_url_rule("/doa", view_func=page_doa, methods=["GET", "POST"]) if __name__ == "__main__": Base.create_all() diff --git a/code/backend/nest_backend/database/tables/Alert.py b/code/backend/nest_backend/database/tables/Alert.py index 03f058e..ff9a7a3 100644 --- a/code/backend/nest_backend/database/tables/Alert.py +++ b/code/backend/nest_backend/database/tables/Alert.py @@ -15,5 +15,5 @@ class Alert(Base.Model): repository_id = Base.Column(Base.Integer, Base.ForeignKey("repository.id"), nullable=False) # Relationships repository = Base.relationship("Repository", back_populates="alerts") - notifications = Base.relationship("Notifications", back_populates="alerts") + notifications = Base.relationship("Notification", back_populates="alert") operations = Base.relationship("BoolOperation", back_populates="alert") \ No newline at end of file diff --git a/code/backend/nest_backend/database/tables/BoolOperation.py b/code/backend/nest_backend/database/tables/BoolOperation.py index 5fca10d..927feae 100644 --- a/code/backend/nest_backend/database/tables/BoolOperation.py +++ b/code/backend/nest_backend/database/tables/BoolOperation.py @@ -19,7 +19,7 @@ class BoolOperation(Base.Model): # Relationships condition = Base.relationship("Condition", back_populates="operations") node_1 = Base.relationship("BoolOperation", primaryjoin=("bool_operation.c.node_1_id==bool_operation.c.id"), - remote_side="BoolOperation.id", backref=backref("father", uselist=False)) + remote_side="BoolOperation.id", backref=backref("father_1", uselist=False)) node_2 = Base.relationship("BoolOperation", primaryjoin=("bool_operation.c.node_2_id==bool_operation.c.id"), - remote_side="BoolOperation.id", backref=backref("father", uselist=False)) + remote_side="BoolOperation.id", backref=backref("father_2", uselist=False)) alert = Base.relationship("Alert", back_populates="operations") diff --git a/code/backend/nest_backend/database/tables/Repository.py b/code/backend/nest_backend/database/tables/Repository.py index 1a14cfa..27dfe8a 100644 --- a/code/backend/nest_backend/database/tables/Repository.py +++ b/code/backend/nest_backend/database/tables/Repository.py @@ -17,4 +17,5 @@ class Repository(Base.Model): owner = Base.relationship("User", back_populates="owner_of") authorizations = Base.relationship("Authorization", back_populates="repository") tweets = Base.relationship("Composed", back_populates="repository") - alerts = Base.relationship("Alert", back_populates="repository") \ No newline at end of file + alerts = Base.relationship("Alert", back_populates="repository") + uses = Base.relationship("Uses", back_populates="repository") \ No newline at end of file diff --git a/code/backend/nest_backend/routes/doa.py b/code/backend/nest_backend/routes/doa.py index 58ff15f..29c4e6d 100644 --- a/code/backend/nest_backend/routes/doa.py +++ b/code/backend/nest_backend/routes/doa.py @@ -2,12 +2,12 @@ Page that displays a message if the server is on """ -from flask import render_template, abort +from flask import render_template, abort, jsonify, request from ..database import * - - def page_doa(): - utente = Utente() + utente = User() + if request.method == "GET": + return "Get" return "If you see this, the server is fine."