first pass, maybe doesn't work

This commit is contained in:
Aaron Kimbre 2022-05-11 20:37:22 -05:00
parent 7b4e11d65b
commit 35ee0ed457
4 changed files with 50 additions and 20 deletions

View File

@ -16,6 +16,7 @@ from functools import partial
from sqlalchemy import func
import time
@click.command("init_db")
@click.argument('drop_tables', nargs=1)
@with_appcontext

View File

@ -3,7 +3,9 @@ from flask import (
send_file,
g,
redirect,
url_for
url_for,
make_response,
abort
)
from flask_user import login_required
from app.models import CharacterInfo
@ -12,6 +14,7 @@ import os
from wand import image
from wand.exceptions import BlobError as BE
import pathlib
import json
import sqlite3
import xml.etree.ElementTree as ET
@ -123,6 +126,42 @@ def get_icon_iconid(id):
return send_file(pathlib.Path(cache).resolve())
@luclient_blueprint.route('/ldddb/')
@login_required
def brick_list():
brick_list = []
if len(brick_list) == 0:
suffixes = [".g", ".g1", ".g2", ".g3", ".xml"]
res = pathlib.Path('app/luclient/res/')
# Load g files
for path in res.rglob("*.*"):
if str(path.suffix) in suffixes:
brick_list.append(
{
"type": "file",
"name": str(path.as_posix()).replace("app/luclient/res/", "")
}
)
response = make_response(json.dumps(brick_list))
response.headers.set('Content-Type', 'application/json')
return response
@luclient_blueprint.route('/ldddb/<path>')
def dir_listing(path):
# Joining the base and the requested path
rel_path = pathlib.Path(str(pathlib.Path(f'app/luclient/res/{path}').resolve()))
# Return 404 if path doesn't exist
if not rel_path.exists():
return abort(404)
# Check if path is a file and serve
if rel_path.is_file():
return send_file(rel_path)
else:
return abort(404)
@luclient_blueprint.route('/unknown')
@login_required
def unknown():

View File

@ -99,7 +99,7 @@ def reject(id):
form = RejectPropertyForm()
if form.validate_on_submit():
char_name = CharacterInfo.query.filter(CharacterInfo.id==property_data.owner_id).first().name
char_name = CharacterInfo.query.filter(CharacterInfo.id == property_data.owner_id).first().name
zone_name = query_cdclient(
'select DisplayDescription from ZoneTable where zoneID = ?',
[property_data.zone_id],
@ -197,11 +197,11 @@ def get(status="all"):
if status == "approved":
query = db.session.query().select_from(Property).join(
CharacterInfo, CharacterInfo.id == Property.owner_id
).join(Account).filter(Property.mod_approved == True).filter(Property.privacy_option == 2)
).join(Account).filter(Property.mod_approved == True).filter(Property.privacy_option == 2) # noqa
elif status == "unapproved":
query = db.session.query().select_from(Property).join(
CharacterInfo, CharacterInfo.id == Property.owner_id
).join(Account).filter(Property.mod_approved == False).filter(Property.privacy_option == 2).filter(Property.rejection_reason == "")
).join(Account).filter(Property.mod_approved == False).filter(Property.privacy_option == 2).filter(Property.rejection_reason == "") # noqa
else:
query = db.session.query().select_from(Property).join(CharacterInfo, CharacterInfo.id == Property.owner_id).join(Account)

View File

@ -469,14 +469,14 @@
this.Parts = []
this.studsFields2D = []
let lod = {{ lod }}
let GeometryLocation = `lod${lod}/${designID}.g`
let PrimitiveLocation = `${designID}.xml`
let GeometryLocation = `brickprimitives/lod${lod}/${designID}.g`
let PrimitiveLocation = `Primitives/${designID}.xml`
let GeometryCount = 0
while (GeometryLocation in database.filelist) {
this.Parts[GeometryCount] = new GeometryReader(database.filelist[GeometryLocation].read())
GeometryCount = GeometryCount + 1
GeometryLocation = `lod${lod}/${designID}.g${GeometryCount}`
GeometryLocation = `brickprimitives/lod${lod}/${designID}.g${GeometryCount}`
}
let primitive = new Primitive(database.filelist[PrimitiveLocation].read())
this.Partname = primitive.Designname
@ -549,7 +549,7 @@
LoadDBURL(dbURLlocation){
this.database = new DBURLReader(dbURLlocation)
if(this.database.initok && this.database.fileexist('Materials.xml') && this.database.fileexist('localizedStrings.loc')){
if(this.database.initok && this.database.fileexist('Materials.xml')){
this.allMaterials = new Materials(this.database.filelist['Materials.xml'].read())
}
}
@ -881,7 +881,6 @@
class Materials {
//done
constructor(data) {
this.Materials = {}
let parser = new DOMParser();
@ -928,13 +927,11 @@
function FindDBURL(){
let dburl = 'https://json.aronwk.com/LDD-DB/'
let dburl = '/luclient/ldddb/'
let xhr = new XMLHttpRequest();
xhr.open('GET', dburl, false); // `false` makes the request synchronous
// request state change event
xhr.onreadystatechange = function() {
// request completed?
if (xhr.readyState !== 4) {//return;
dburl = false;
@ -950,7 +947,6 @@
console.log('HTTP error in FindDBURL:', xhr.status, xhr.statusText);
}
};
// start request
xhr.send();
return dburl
@ -1041,13 +1037,7 @@
self.parse(dburl + obj.name + '/', obj.name)
}
else if (obj.type == 'file'){
if (folder.includes("lod")){
self.filelist[`${folder}/${obj.name}`] = new DBURLFile(dburl + obj.name, obj.name)
} else {
self.filelist[obj.name] = new DBURLFile(dburl + obj.name, obj.name)
}
self.filelist[obj.name] = new DBURLFile(dburl + obj.name, obj.name)
}
else {
console.log('Strange object parsed: ' + obj.type)