diff --git a/README b/README index deb4c69..8ba81cd 100644 --- a/README +++ b/README @@ -25,6 +25,8 @@ python3 main.py ### TODO: + -- Without redirects (after creation) the potential for reload's trying to re-add objects may suck... + -> see if I can see how to pass alert/message through to /owneds somehow ... if I can even pass a global or some shit then pick it up in the python code? - need to create all classes (green + button) - need to delete all classes (and watch for referential integrity) - need to add 1 author to book, book to sub_book, series @@ -41,4 +43,3 @@ python3 main.py when moving a book in a series (which is part of 2 series), do we pop-up offer to move parent/child series orders as well to match (think Thomas Covenant) - try to "export" db from sqlalchemy to see what it is doing with sequences / primary key for owned table and maybe "new_id" not needed? diff --git a/main.py b/main.py index d926dc6..8f71cf2 100644 --- a/main.py +++ b/main.py @@ -112,6 +112,7 @@ class Book(db.Model): def LastSubBookNum(self): # need to work out the last sub book and return an id? if self.IsParent(): + # -1 subscript returns the last one return self.child_ref[-1].sub_book_num else: return 1 diff --git a/owned.py b/owned.py index 82fd3be..37a788d 100644 --- a/owned.py +++ b/owned.py @@ -2,13 +2,14 @@ from wtforms import SubmitField, StringField, HiddenField, SelectField, validato from flask import request, render_template from flask_wtf import FlaskForm from __main__ import db, app, ma -from sqlalchemy import func +from sqlalchemy import func, Sequence + ################################################################################ # Class describing Owned in the database, and via sqlalchemy, connected to the DB as well ################################################################################ class Owned(db.Model): - id = db.Column(db.Integer, primary_key=True ) + id = db.Column(db.Integer, db.Sequence('owned_id_seq'), primary_key=True ) name = db.Column(db.String(50), unique=True, nullable=False) def __repr__(self): @@ -20,7 +21,6 @@ class Owned(db.Model): class OwnedSchema(ma.SQLAlchemyAutoSchema): class Meta: model = Owned - ################################################################################ # Helper class that defines a form for owned, used to make html