diff --git a/main.py b/main.py index df21d11..a874f44 100644 --- a/main.py +++ b/main.py @@ -30,6 +30,17 @@ Bootstrap(app) from settings import Settings from files import Files from person import Person +from refimg import Refimg +from ai import * + +####################################### CLASSES / DB model ####################################### +class Person_Refimg_Link(db.Model): + __tablename__ = "person_refimg_link" + person_id = db.Column(db.Integer, db.ForeignKey('person.id'), unique=True, nullable=False, primary_key=True) + refimg_id = db.Column(db.Integer, db.ForeignKey('refimg.id'), unique=True, nullable=False, primary_key=True) + + def __repr__(self): + return "".format(self.person_id, self.refimg_id) ####################################### GLOBALS ####################################### # allow jinja2 to call these python functions directly diff --git a/person.py b/person.py index 79b9a46..e56c105 100644 --- a/person.py +++ b/person.py @@ -6,6 +6,8 @@ from sqlalchemy import Sequence from sqlalchemy.exc import SQLAlchemyError from status import st, Status +from files import Files + ################################################################################ # Class describing Person in the database, and via sqlalchemy, connected to the DB as well ################################################################################ @@ -18,6 +20,14 @@ class Person(db.Model): def __repr__(self): return "".format(self.tag,self.firstname, self.surname) +class File_Person_Link(db.Model): + __tablename__ = "file_person_link" + file_id = db.Column(db.Integer, db.ForeignKey('files.id'), unique=True, nullable=False, primary_key=True) + person_id = db.Column(db.Integer, db.ForeignKey('person.id'), unique=True, nullable=False, primary_key=True) + + def __repr__(self): + return "".format(self.file_id, self.person_id) + ################################################################################ # Helper class that inherits a .dump() method to turn class Person into json / useful in jinja2 ################################################################################ @@ -100,9 +110,3 @@ def person(id): person = Person.query.get(id) form = PersonForm(request.values, obj=person) return render_template("person.html", object=person, form=form, page_title = page_title, alert=st.GetAlert(), message=st.GetMessage() ) - -################################################################################ -# helper fund to GetPersons -> person_list -> jinja2 for person drop-down in book.html -################################################################################ -def GetPersons(): - return Person.query.order_by('surname','firstname').all() diff --git a/templates/refimg.html b/templates/refimg.html new file mode 100644 index 0000000..d33bd5e --- /dev/null +++ b/templates/refimg.html @@ -0,0 +1,69 @@ +{% extends "base.html" %} +{% block main_content %} +
+

{{page_title}}

+
+
+ {% for field in form %} + {% if field.type == 'HiddenField' or field.type == 'CSRFTokenField' %} + {{field}}
+ {% elif field.type != 'SubmitField' %} +
+ {% if 'Edit' in page_title %} + {{ field.label( class="col-lg-2" ) }} +
+
+ +
+
+ {{field.data}} + +
+ {% else %} + {{ field.label( class="col-lg-2" ) }} + +
+
+ {{field.data}} +
+
+ +
+
+ {% endif %} +
+ {% endif %} + {% endfor %} +
+
+
+
+ {{ form.submit( class="btn btn-primary offset-lg-2 col-lg-2" )}} + {% if 'Edit' in page_title %} + {{ form.delete( class="btn btn-outline-danger col-lg-2" )}} + {% endif %} +
+ +
+
+{% endblock main_content %} + +{% block script_content %} + +{% endblock script_content %} diff --git a/templates/refimgs.html b/templates/refimgs.html new file mode 100644 index 0000000..1af2343 --- /dev/null +++ b/templates/refimgs.html @@ -0,0 +1,15 @@ +{% extends "base.html" %} + +{% block main_content %} +

Show All Reference Images

+ + + + + + {% for refimg in refimgs %} + + {% endfor %} + +
Filename
{{refimg.fname}}
+{% endblock main_content %}