diff --git a/README b/README index a7d1ba1..b3f2703 100644 --- a/README +++ b/README @@ -80,6 +80,10 @@ To get back a 'working' but scanned set of data: # start db, using new tables.sql + DEV: + ( cd /srv/docker/config/ ; sudo docker-compose stop padb_dev ; sudo docker-compose rm -f padb_dev ; sudo rm -rf /srv/docker/container/padb_dev/data/ ; sudo cp /home/ddp/src/photoassistant/tables.sql /srv/docker/container/padb_dev/docker-entrypoint-initdb.d/tables.sql ; sudo docker-compose up -d padb_dev ) + + ### decide what tables.sql you want, e.g. sudo bash diff --git a/TODO b/TODO index 0695ce1..c08fd5c 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,8 @@ ## GENERAL * for below.. make Options( request ) - remove all "Options()" that are not set by a user-choice in the F/E and just make sure new "Options" sets all defaults as needed + -- ALSO, preferences are different to app settings... allow prefs from "ddp" menu + -> it should allow default pagesize, default thumbsize, etc. -- viewlist can work out new view_eids server side, and pass them back as json data - can consider an optim-- new_view page makes calls to viewlist to ADD json data only, so only trigger a new "viewlist" if we dont have data for that part of the eids @@ -8,6 +10,7 @@ don't render_template instead do a redirect to a GET of the new, or list? for del... * need to catch "option changes" as POSTs to make them GETs somehow... (search, files_ip POST change trigger issue) + -- I think it is the same URL being used issue? -- validate this in PROD only I think [DONE] files.py:@app.route("/view/", methods=["POST"]) files.py:@app.route("/viewlist", methods=["POST"]) diff --git a/states.py b/states.py index 48ab5b5..db09529 100644 --- a/states.py +++ b/states.py @@ -12,6 +12,7 @@ from shared import PA ################################################################################ class PA_UserState(db.Model): __tablename__ = "pa_user_state" + id = db.Column(db.Integer, db.Sequence('pa_user_state_id_seq'), primary_key=True ) pa_user_dn = db.Column(db.String, db.ForeignKey('pa_user.dn'), primary_key=True ) path_type = db.Column(db.String, primary_key=True, unique=False, nullable=False ) noo = db.Column(db.String, unique=False, nullable=False ) @@ -23,7 +24,7 @@ class PA_UserState(db.Model): fullscreen = db.Column(db.Boolean, unique=False, nullable=False ) root = db.Column(db.String, unique=False, nullable=False ) cwd = db.Column(db.String, unique=False, nullable=False ) - ## this is non normal form, but this table only ever has a handful of rows per user, not worth the extra effort + ## for now being lazy and not doing a separate table until I settle on needed fields and when # only used if ptype == View view_eid = db.Column(db.Integer, unique=False, nullable=False ) orig_ptype = db.Column(db.String, unique=False, nullable=False ) @@ -160,10 +161,8 @@ class States(PA): if 'next' in request.form: self.offset += int(self.how_many) - # now save pref + # now save pref (if this is 'another' search, view, etc. then it will add a row for it with matching search_term, or view_eid, etc. if not pref: - # now we have 'unique' search and view states, blow away any old ones that are not this unique combo (different search term, or different image viewed) - old_pref=PA_UserState.query.filter(PA_UserState.pa_user_dn==current_user.dn,PA_UserState.path_type==self.path_type).delete() pref=PA_UserState( pa_user_dn=current_user.dn, path_type=self.path_type, view_eid=self.view_eid, noo=self.noo, grouping=self.grouping, how_many=self.how_many, st_offset=self.offset, size=self.size, folders=self.folders, root=self.root, cwd=self.cwd, orig_ptype=self.orig_ptype, orig_search_term=self.orig_search_term ) else: diff --git a/tables.sql b/tables.sql index a3ff02d..ffe223d 100644 --- a/tables.sql +++ b/tables.sql @@ -15,12 +15,22 @@ create table SETTINGS( constraint FK_DEFAULT_REFIMG_MODEL foreign key (DEFAULT_REFIMG_MODEL) references AI_MODEL(ID), constraint FK_DEFAULT_SCAN_MODEL foreign key (DEFAULT_SCAN_MODEL) references AI_MODEL(ID) ); -create table PA_USER_STATES ( PA_USER_DN varchar(128), PATH_TYPE varchar(16), NOO varchar(16), GROUPING varchar(16), HOW_MANY integer, ST_OFFSET integer, SIZE integer, FOLDERS Boolean, FULLSCREEN Boolean, ROOT varchar, CWD varchar, VIEW_EIDS varchar, VIEW_EIDS varchar, - constraint PK_PA_USER_STATES_DN_PATH_TYPE primary key(PA_USER_DN, PATH_TYPE ) ); - -create table PA_USER( ID integer, dn varchar, +create table PA_USER( + ID integer, + DN varchar unique, + DEFAULT_NOO varchar, + DEFAULT_GROUPING varchar(16), + DEFAULT_HOW_MANY integer, + DEFAULT_SIZE integer, + DEFAULT_FOLDERS Boolean, + DEFAULT_FULLSCREEN Boolean, constraint PK_PA_USER_ID primary key(ID) ); +-- this should reference pa_user_id not pa_user_dn +create table PA_USER_STATE ( ID integer, PA_USER_DN varchar(128), PATH_TYPE varchar(16), NOO varchar(16), GROUPING varchar(16), HOW_MANY integer, ST_OFFSET integer, SIZE integer, FOLDERS Boolean, FULLSCREEN Boolean, ROOT varchar, CWD varchar, VIEW_EID integer, ORIG_PTYPE varchar, ORIG_SEARCH_TERM varchar, + constraint FK_PA_USER_DN foreign key (PA_USER_DN) references PA_USER(DN), + constraint PK_PA_USER_STATES_ID primary key(ID ) ); + create table FILE_TYPE ( ID integer, NAME varchar(32) unique, constraint PK_FILE_TYPE_ID primary key(ID) ); create table PATH_TYPE ( ID integer, NAME varchar(16) unique, constraint PK_PATH_TYPE_ID primary key(ID) ); @@ -97,6 +107,7 @@ create table PA_JOB_MANAGER_FE_MESSAGE ( ID integer, JOB_ID integer, ALERT varch constraint FK_PA_JOB_MANAGER_FE_MESSAGE_JOB_ID foreign key(JOB_ID) references JOB(ID) ); create sequence PA_USER_ID_SEQ; +create sequence PA_USER_STATE_ID_SEQ; create sequence FACE_ID_SEQ; create sequence PATH_ID_SEQ; create sequence PATH_TYPE_ID_SEQ;