Compare commits

..

No commits in common. "main" and "v1.0.0" have entirely different histories.
main ... v1.0.0

53 changed files with 773 additions and 1303 deletions

View File

@ -1,54 +0,0 @@
name: ci
on:
push:
branches:
- "main"
tags:
- "v*.*.*"
pull_request:
branches:
- "main"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=pr
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

4
.gitignore vendored
View File

@ -4,7 +4,7 @@ resources.py
__pycache__/ __pycache__/
venv/ venv/
static/policy/ static/policy/
app/static/css/site.css app/static/site.css
app/static/.webassets-cache/**/* app/static/.webassets-cache/**/*
app/static/brickdb/* app/static/brickdb/*
locale.json locale.json
@ -17,5 +17,3 @@ property_files/*
*.log *.log
app/settings.py app/settings.py
*.exe *.exe
*.csv
*.sql

View File

@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1 # syntax=docker/dockerfile:1
FROM python:3.11-slim-bookworm FROM python:3.8-slim-buster
RUN apt update RUN apt update
RUN apt -y install zip RUN apt -y install zip

220
README.md
View File

@ -65,30 +65,28 @@
* Reports how much currency that characters posses * Reports how much currency that characters posses
* U-Score: * U-Score:
* Reports how much U-Score that characters posses * Reports how much U-Score that characters posses
* Analytics:
* Provide reporting to Developers to help better solve issues
* Disabled by default. Set `ALLOW_ANALYTICS` to true to enable.
# Deployment # Deployment
> **NOTE: This tutorial assumes you have a working DLU server instance and** > **NOTE: This tutorial assumes you have a working DLU server instance and**
> **some knowledge of command line interfaces on your chosen platform** > **some knowledge of Linux**
**It is highly recommended to setup a reverse proxy via Nginx or some other tool and use SSL to secure your Nexus Dashboard instance if you are going to be opening it up to any non-LANs**
* [How to setup Nginx](https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-as-a-reverse-proxy-on-ubuntu-22-04)
* [How to use certbot for SSL](https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-22-04)
## Docker ## Docker
```bash ```bash
docker run -d \ docker run -d \
-e APP_SECRET_KEY='<secret_key>' \ -e APP_SECRET_KEY='<secret_key>' \
-e APP_DATABASE_URI='mysql+pymysql://<username>:<password>@<host>:<port>/<database>' \ -e APP_DATABASE_URI='mysql+pymysql://<username>:<password>@<host>:<port>/<database>' \
# you can include other optional Environment Variables from below like this # you can include other optional Environment Variables from below like this
-e REQUIRE_PLAY_KEY=True \ -e REQUIRE_PLAY_KEY=True
-p 8000:8000/tcp \ -p 8000:8000/tcp
-v /path/to/logs:/logs:rw / -v /path/to/unpacked/client:/app/luclient:rw \
-v /path/to/unpacked/client:/app/luclient:ro \
-v /path/to/cachedir:/app/cache:rw \ -v /path/to/cachedir:/app/cache:rw \
ghcr.io/darkflameuniverse/nexusdashboard:latest aronwk/nexus-dashboard:latest
``` ```
* `/app/luclient` must be mapped to the location of an unpacked client * `/app/luclient` must be mapped to the location of an unpacked client
@ -98,48 +96,43 @@ docker run -d \
### Environmental Variables ### Environmental Variables
Please Reference `app/settings_example.py` to see all the variables Please Reference `app/settings_exmaple.py` to see all the variables
* Required: * Required:
* APP_SECRET_KEY (Must be provided) * APP_SECRET_KEY (Must be provided)
* APP_DATABASE_URI (Must be provided) * APP_DATABASE_URI (Must be provided)
* Everything else is optional and has defaults * Everything else is optional and has defaults
## Manual Linux Installation ## Manual
Thanks to [HailStorm32](https://github.com/HailStorm32) for this manual install guide! Thanks to [HailStorm32](https://github.com/HailStorm32) for this manual install guide!
### Setting Up The Environment ### Setting Up The Environment
First you will want to install the following packages by executing the following commands presuming you are on a Debian based system. First you will want to install the following packages by executing the following commands
`sudo apt-get update` `sudo apt-get update`
`sudo apt-get install -y python3 python3-pip sqlite3 git unzip libmagickwand-dev` `sudo apt-get install -y python3 python3-pip sqlite3 git unzip libmagickwand-dev`
> *Note: If you are having issues with installing `sqlite3`, change it to `sqlite`* > *Note: If you are having issues with installing `sqlite3`, change it to `sqlite`*
<br> <br>
Next you will want to clone the repository. You can clone it anywhere, but for the purpose of this tutorial, we will be cloning it to the home directory.' Next we will clone the repository. You can clone it anywhere, but for the purpose of this tutorial, we will be cloning it to the home directory.
<br></br>
Run `cd ~` to ensure that you are currently in the home directory then run the following command to clone the repository into our home directory `cd` *make sure you are in the home directory*
`git clone https://github.com/DarkflameUniverse/NexusDashboard.git` `git clone https://github.com/DarkflameUniverse/NexusDashboard.git`
You should now have a directory called `NexusDashboard` present in your home directory You should now have a directory called `NexusDashboard`
### Setting up ### Setting up
Rename the example settings file Rename the example settings file
`cp ~/NexusDashboard/app/settings_example.py ~/NexusDashboard/app/settings.py` `cp ~/NexusDashboard/app/settings_example.py ~/NexusDashboard/app/settings.py`
Now let's open the settings file we just created and configure some of the settings with nano as it is a simple text editor that is easy to use Now let's open the settings file we just created and configure some of the settings
`nano ~/NexusDashboard/app/settings.py` `vim ~/NexusDashboard/app/settings.py`
>*Obviously you can replace this with a text editor of your choice, nano is just the most simple to use out of the ones available by default on most Linux distros* >*Feel free to use any text editor you are more comfortable with instead of vim*
<br> <br>
Inside this file is where you can change certain settings like user registration, email support and other things. In this tutorial we will only be focusing on the bare minimum to get up and running, but feel free to adjust what you would like to fit your needs. Inside this file is where you can change certain settings like user registration, email support and other things. In this tutorial I will only be focusing on the bare minimum to get up and running, but feel free to adjust what you would like
>*Note: Enabling the email option will require further setup that is outside the scope of this tutorial*
>*Note: There are options in here that are related to email registration and password recovery among other features however those require extra setup not covered by this tutorial*
The two important settings to configure are `APP_SECRET_KEY` and `APP_DATABASE_URI` The two important settings to configure are `APP_SECRET_KEY` and `APP_DATABASE_URI`
@ -169,166 +162,65 @@ Once you are done making the changes, save and close the file
We will need the following folders from the client We will need the following folders from the client
``` ```
locale locale (all of the files inside)
└───locale.xml
res res
├───BrickModels |_BrickModels
├───brickprimitives |_brickprimitives
├───textures |_textures
├───ui |_ui
├───brickdb.zip |_brickdb.zip
``` ```
Put the two folders in `~/NexusDashboard/app/luclient` Put the two folders in `~/NexusDashboard/app/luclient`
Unzip the `brickdb.zip` in place Unzip the `brickdb.zip` in place
`unzip brickdb.zip` `unzip brickdb.zip`
Remove the `.zip` file after you have unzipped it, you can do that with Remove the `.zip` after you have unzipped it
`rm brickdb.zip` `rm brickdb.zip`
In the `luclient` directory you should now have a file structure that looks like this In the `luclient` directory you should now have a file structure that looks like this
``` ```
locale local
└───locale.xml |_locale.xml
res res
├───BrickModels |_BrickModels
│ └─── ... |_...
├───brickprimitives |_brickprimitives
│ └─── ... |_...
├───textures |_textures
│ └─── ... |_...
├───ui |_ui
│ └─── ... |_...
├───Assemblies |_Assemblies
│ └─── ... |_...
├───Primitives |_Primitives
│ └─── ... |_...
├───Materials.xml |_Materials.xml
└───info.xml |_info.xml
``` ```
We will also need to copy the `CDServer.sqlite` database file from the server to the `~/NexusDashboard/app/luclient/res` folder We will also need to copy the `CDServer.sqlite` database file from the server to the `~/NexusDashboard/app/luclient/res` folder
Once the file is moved over, you will need to rename it to `cdclient.sqlite`, this can be done with the following command Once the file is moved over, you will need to rename it to `cdclient.sqlite`
```bash `mv ~/NexusDashboard/app/luclient/res/CDServer.sqlite ~/NexusDashboard/app/luclient/res/cdclient.sqlite`
mv ~/NexusDashboard/app/luclient/res/CDServer.sqlite ~/NexusDashboard/app/luclient/res/cdclient.sqlite
```
##### Remaining Setup ##### Remaining Setup
To finish this, we will need to install the python dependencies and run the database migrations, simply run the following commands one at a time Run the following commands one at a time
```bash
cd ~/NexusDashboard `cd ~/NexusDashboard`
pip install -r requirements.txt `pip install -r requirements.txt`
pip install gunicorn `pip install gunicorn`
flask db upgrade `flask db upgrade`
```
##### Running the site ##### Running the site
Once all of the above is complete, you can run the site with the command You can run the site with
`gunicorn -b :8000 -w 4 wsgi:app` `gunicorn -b :8000 -w 4 wsgi:app`
## Manual Windows Setup
While a lot of the setup on Windows is the same a lot of it can be completed with GUI interfaces and requires installing things from websites instead of the command line.
### Setting Up The Environment
You need to install the following prerequisites:
* [Python 3.8](https://www.python.org/downloads/release/python-380/)
* [Git](https://git-scm.com/downloads)
* [ImageMagick](https://docs.wand-py.org/en/latest/guide/install.html#install-imagemagick-on-windows)
* [7-Zip](https://www.7-zip.org/download.html)
Next you will need to clone the repository. You can clone it anywhere, but for the purpose of this tutorial, you will want to clone it to your desktop just for simplicity, it can be moved after.
Open a command prompt and run `cd Desktop` (The command line should place you in your Home directory be default) to ensure that you are currently in the desktop directory then run the following command to clone the repository into our desktop directory
Run the following command to clone the repository `git clone https://github.com/DarkflameUniverse/NexusDashboard.git`
You should now have a directory called `NexusDashboard` present on your desktop.
### Setting up
Now that we have the repository cloned you need to rename the example settings file, you can perform this manually in the GUI or you can use the command line, to do the latter run the following commands
* `cd NexusDashboard\app`
* `copy settings_example.py settings.py`
Now let's open the settings file we just created and configure some of the settings with the Windows default notepad.
* `notepad settings.py`
Inside this file is where you can change certain settings like user registration, email support and other things. In this tutorial we will only be focusing on the bare minimum to get up and running, but feel free to adjust what you would like to fit your needs.
> *Note: There are options in here that are related to email registration and password recovery among other features however those require extra setup not covered by this tutorial*
The two important settings to configure are `APP_SECRET_KEY` and `APP_DATABASE_URI`
For `APP_SECRET_KEY` you can just fill in any random 32 character string and for `APP_DATABASE_URI` you will need to fill in a connection string to your database. The connection string will look similar to this. You will need to fill in your own information for the username, password, host, port and database name.
```
APP_DATABASE_URI = "mysql+pymysql://<username>:<password>@<host>:<port>/<database>"
```
and the rest of the file can be left at the default values other than the `APP_SECRET_KEY` which you will need to fill in with random characters.
Once you are done making the changes, save and close the file
##### Client related files
We will need the following folders from the client
```
locale
└───locale.xml
res
├───BrickModels
├───brickprimitives
├───textures
├───ui
└───brickdb.zip
```
Put the two folders in `Desktop/NexusDashboard/app/luclient`
Unzip the `brickdb.zip` in place using 7-Zip, you can do this by right clicking the file and selecting `7-Zip > Extract Here`.
After doing this you can remove the `.zip`, simply delete the file.
In the `luclient` directory you should now have a file structure that looks like this
```
locale
└───locale.xml
res
├───BrickModels
│ └─── ...
├───brickprimitives
│ └─── ...
├───textures
│ └─── ...
├───ui
│ └─── ...
├───Assemblies
│ └─── ...
├───Primitives
│ └─── ...
├───Materials.xml
└───info.xml
```
We will also need to copy the `CDServer.sqlite` database file from the server to the `Desktop/NexusDashboard/app/luclient/res` folder
Once the file is moved over, you will need to rename it to `cdclient.sqlite`, this can be done by right clicking the file and selecting `Rename` and then changing the name to `cdclient.sqlite`
##### Remaining Setup
To finish this, we will need to install the python dependencies and run the database migrations, simply run the following commands one at a time in the root directory of the site, if you are not in the root directory you can run `cd Desktop/NexusDashboard` to get there (assuming you have opened a new terminal window)
```bat
pip install -r requirements.txt
flask db upgrade
```
##### Running the site
Once all of the above is complete, you can run the site with the command
`flask run` however bare in mind that this is a development version of the site, at the moment running a production version of the site on Windows is not supported.
# Development # Development
Please use [Editor Config](https://editorconfig.org/) to maintain a consistent coding style between different editors and different contributors. Please use [Editor Config](https://editorconfig.org/)
* `python3 -m flask run` to run a local dev server * `flask run` to run local dev server

View File

@ -5,12 +5,12 @@ from flask_assets import Environment
from webassets import Bundle from webassets import Bundle
import time import time
from app.models import db, migrate, PlayKey from app.models import db, migrate, PlayKey
from app.schemas import ma
from app.forms import CustomUserManager from app.forms import CustomUserManager
from flask_user import user_registered, current_user, user_logged_in from flask_user import user_registered, current_user, user_logged_in
from flask_wtf.csrf import CSRFProtect from flask_wtf.csrf import CSRFProtect
from flask_apscheduler import APScheduler from flask_apscheduler import APScheduler
from app.luclient import register_luclient_jinja_helpers from app.luclient import register_luclient_jinja_helpers
import pathlib
from app.commands import ( from app.commands import (
init_db, init_db,
@ -18,9 +18,7 @@ from app.commands import (
load_property, load_property,
gen_image_cache, gen_image_cache,
gen_model_cache, gen_model_cache,
fix_clone_ids, fix_clone_ids
remove_buffs,
find_missing_commendation_items
) )
from app.models import Account, AccountInvitation, AuditLog from app.models import Account, AccountInvitation, AuditLog
@ -84,11 +82,6 @@ def create_app():
if cdclient is not None: if cdclient is not None:
cdclient.close() cdclient.close()
@app.template_filter()
def numberFormat(value):
return format(int(value), ',d')
# add the commands to flask cli # add the commands to flask cli
app.cli.add_command(init_db) app.cli.add_command(init_db)
app.cli.add_command(init_accounts) app.cli.add_command(init_accounts)
@ -96,8 +89,6 @@ def create_app():
app.cli.add_command(gen_image_cache) app.cli.add_command(gen_image_cache)
app.cli.add_command(gen_model_cache) app.cli.add_command(gen_model_cache)
app.cli.add_command(fix_clone_ids) app.cli.add_command(fix_clone_ids)
app.cli.add_command(remove_buffs)
app.cli.add_command(find_missing_commendation_items)
register_logging(app) register_logging(app)
register_settings(app) register_settings(app)
@ -105,19 +96,6 @@ def create_app():
register_blueprints(app) register_blueprints(app)
register_luclient_jinja_helpers(app) register_luclient_jinja_helpers(app)
# Extract the brickdb if it's not already extracted
materials = pathlib.Path(f'{app.config["CACHE_LOCATION"]}Materials.xml')
if not materials.is_file():
# unzip the brickdb, and remove the import after
from zipfile import ZipFile
with ZipFile(f"{app.config['CLIENT_LOCATION']}res/brickdb.zip","r") as zip_ref:
zip_ref.extractall(app.config["CACHE_LOCATION"])
del ZipFile
# copy over the brick primitives, and remove the import after
from shutil import copytree
copytree(f"{app.config['CLIENT_LOCATION']}res/brickprimitives", f"{app.config['CACHE_LOCATION']}brickprimitives")
del copytree
return app return app
@ -129,6 +107,8 @@ def register_extensions(app):
""" """
db.init_app(app) db.init_app(app)
migrate.init_app(app, db) migrate.init_app(app, db)
ma.init_app(app)
scheduler.init_app(app) scheduler.init_app(app)
scheduler.start() scheduler.start()
@ -140,7 +120,7 @@ def register_extensions(app):
assets = Environment(app) assets = Environment(app)
assets.url = app.static_url_path assets.url = app.static_url_path
scss = Bundle('scss/site.scss', filters='libsass', output='css/site.css') scss = Bundle('scss/site.scss', filters='libsass', output='site.css')
assets.register('scss_all', scss) assets.register('scss_all', scss)
@ -179,7 +159,7 @@ def register_blueprints(app):
def register_logging(app): def register_logging(app):
# file logger # file logger
file_handler = RotatingFileHandler('logs/nexus_dashboard.log', maxBytes=1024 * 1024 * 100, backupCount=20) file_handler = RotatingFileHandler('nexus_dashboard.log', maxBytes=1024 * 1024 * 100, backupCount=20)
file_handler.setLevel(logging.INFO) file_handler.setLevel(logging.INFO)
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
file_handler.setFormatter(formatter) file_handler.setFormatter(formatter)
@ -203,23 +183,19 @@ def register_settings(app):
# Load environment specific settings # Load environment specific settings
app.config['TESTING'] = False app.config['TESTING'] = False
app.config['DEBUG'] = False app.config['DEBUG'] = False
app.config['SQLALCHEMY_ENGINE_OPTIONS'] = {
"pool_pre_ping": True,
"pool_size": 10,
"max_overflow": 2,
"pool_recycle": 300,
"pool_pre_ping": True,
"pool_use_lifo": True
}
# always pull these two from the env
app.config['SECRET_KEY'] = os.getenv( app.config['SECRET_KEY'] = os.getenv(
'APP_SECRET_KEY', 'APP_SECRET_KEY',
app.config['APP_SECRET_KEY'] app.config['APP_SECRET_KEY']
) )
app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv( app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv(
'APP_DATABASE_URI', 'APP_DATABASE_URI',
app.config['APP_DATABASE_URI'] app.config['APP_DATABASE_URI']
) )
# try to get overides, otherwise just use what we have already
app.config['USER_ENABLE_REGISTER'] = os.getenv( app.config['USER_ENABLE_REGISTER'] = os.getenv(
'USER_ENABLE_REGISTER', 'USER_ENABLE_REGISTER',
app.config['USER_ENABLE_REGISTER'] app.config['USER_ENABLE_REGISTER']
@ -244,15 +220,25 @@ def register_settings(app):
'USER_REQUIRE_INVITATION', 'USER_REQUIRE_INVITATION',
app.config['USER_REQUIRE_INVITATION'] app.config['USER_REQUIRE_INVITATION']
) )
app.config['ALLOW_ANALYTICS'] = os.getenv(
'ALLOW_ANALYTICS',
app.config['ALLOW_ANALYTICS']
)
app.config['SQLALCHEMY_ENGINE_OPTIONS'] = {
"pool_pre_ping": True,
"pool_size": 10,
"max_overflow": 2,
"pool_recycle": 300,
"pool_pre_ping": True,
"pool_use_lifo": True
}
app.config['MAIL_SERVER'] = os.getenv( app.config['MAIL_SERVER'] = os.getenv(
'MAIL_SERVER', 'MAIL_SERVER',
app.config['MAIL_SERVER'] app.config['MAIL_SERVER']
) )
app.config['MAIL_PORT'] = int( app.config['MAIL_PORT'] = os.getenv(
os.getenv( 'MAIL_USE_SSL',
'MAIL_PORT',
app.config['MAIL_PORT'] app.config['MAIL_PORT']
)
) )
app.config['MAIL_USE_SSL'] = os.getenv( app.config['MAIL_USE_SSL'] = os.getenv(
'MAIL_USE_SSL', 'MAIL_USE_SSL',
@ -279,71 +265,6 @@ def register_settings(app):
app.config['USER_EMAIL_SENDER_EMAIL'] app.config['USER_EMAIL_SENDER_EMAIL']
) )
if "ENABLE_CHAR_XML_UPLOAD" not in app.config:
app.config['ENABLE_CHAR_XML_UPLOAD'] = False
app.config['ENABLE_CHAR_XML_UPLOAD'] = os.getenv(
'ENABLE_CHAR_XML_UPLOAD',
app.config['ENABLE_CHAR_XML_UPLOAD']
)
if "CLIENT_LOCATION" not in app.config:
app.config['CLIENT_LOCATION'] = 'app/luclient/'
app.config['CLIENT_LOCATION'] = os.getenv(
'CLIENT_LOCATION',
app.config['CLIENT_LOCATION']
)
if "CD_SQLITE_LOCATION" not in app.config:
app.config['CD_SQLITE_LOCATION'] = 'app/luclient/res/'
app.config['CD_SQLITE_LOCATION'] = os.getenv(
'CD_SQLITE_LOCATION',
app.config['CD_SQLITE_LOCATION']
)
if "CACHE_LOCATION" not in app.config:
app.config['CACHE_LOCATION'] = 'app/cache/'
app.config['CACHE_LOCATION'] = os.getenv(
'CACHE_LOCATION',
app.config['CACHE_LOCATION']
)
# Recaptcha settings
if "RECAPTCHA_ENABLE" not in app.config:
app.config['RECAPTCHA_ENABLE'] = False
app.config['RECAPTCHA_ENABLE'] = os.getenv(
'RECAPTCHA_ENABLE',
app.config['RECAPTCHA_ENABLE']
)
if "RECAPTCHA_PUBLIC_KEY" not in app.config:
app.config['RECAPTCHA_PUBLIC_KEY'] = ''
app.config['RECAPTCHA_PUBLIC_KEY'] = os.getenv(
'RECAPTCHA_PUBLIC_KEY',
app.config['RECAPTCHA_PUBLIC_KEY']
)
if "RECAPTCHA_PRIVATE_KEY" not in app.config:
app.config['RECAPTCHA_PRIVATE_KEY'] = ''
app.config['RECAPTCHA_PRIVATE_KEY'] = os.getenv(
'RECAPTCHA_PRIVATE_KEY',
app.config['RECAPTCHA_PRIVATE_KEY']
)
# Optional
if "RECAPTCHA_API_SERVER" in app.config:
app.config['RECAPTCHA_API_SERVER'] = os.getenv(
'RECAPTCHA_API_SERVER',
app.config['RECAPTCHA_API_SERVER']
)
if "RECAPTCHA_PARAMETERS" in app.config:
app.config['RECAPTCHA_PARAMETERS'] = os.getenv(
'RECAPTCHA_PARAMETERS',
app.config['RECAPTCHA_PARAMETERS']
)
if "RECAPTCHA_DATA_ATTRS" in app.config:
app.config['RECAPTCHA_DATA_ATTRS'] = os.getenv(
'RECAPTCHA_DATA_ATTRS',
app.config['RECAPTCHA_DATA_ATTRS']
)
def gm_level(gm_level): def gm_level(gm_level):
"""Decorator for handling permissions based on the user's GM Level """Decorator for handling permissions based on the user's GM Level

View File

@ -1,9 +1,7 @@
from flask import render_template, Blueprint, redirect, url_for, request, current_app, flash from flask import render_template, Blueprint, redirect, url_for, request, current_app, flash
from flask_user import login_required, current_user from flask_user import login_required, current_user
from datatables import ColumnDT, DataTables from datatables import ColumnDT, DataTables
import bcrypt
import datetime import datetime
import secrets
from app.models import ( from app.models import (
Account, Account,
CharacterInfo, CharacterInfo,
@ -16,15 +14,17 @@ from app.models import (
AuditLog, AuditLog,
BugReport, BugReport,
AccountInvitation, AccountInvitation,
db, db
Friends
) )
from app.schemas import AccountSchema
from app import gm_level, log_audit from app import gm_level, log_audit
from app.forms import EditGMLevelForm, EditEmailForm from app.forms import EditGMLevelForm, EditEmailForm
from sqlalchemy import or_
accounts_blueprint = Blueprint('accounts', __name__) accounts_blueprint = Blueprint('accounts', __name__)
account_schema = AccountSchema()
@accounts_blueprint.route('/', methods=['GET']) @accounts_blueprint.route('/', methods=['GET'])
@login_required @login_required
@gm_level(3) @gm_level(3)
@ -150,14 +150,10 @@ def delete(id):
message = f"Deleted Account ({account.id}){account.username}" message = f"Deleted Account ({account.id}){account.username}"
chars = CharacterInfo.query.filter(CharacterInfo.account_id == id).all() chars = CharacterInfo.query.filter(CharacterInfo.account_id == id).all()
for char in chars: for char in chars:
activities = ActivityLog.query.filter( activities = ActivityLog.query.filter(ActivityLog.character_id == char.id).all()
ActivityLog.character_id == char.id
).all()
for activity in activities: for activity in activities:
activity.delete() activity.delete()
lb_entries = Leaderboard.query.filter( lb_entries = Leaderboard.query.filter(Leaderboard.character_id == char.id).all()
Leaderboard.character_id == char.id
).all()
for lb_entry in lb_entries: for lb_entry in lb_entries:
lb_entry.delete() lb_entry.delete()
mails = Mail.query.filter(Mail.receiver_id == char.id).all() mails = Mail.query.filter(Mail.receiver_id == char.id).all()
@ -165,29 +161,21 @@ def delete(id):
mail.delete() mail.delete()
props = Property.query.filter(Property.owner_id == char.id).all() props = Property.query.filter(Property.owner_id == char.id).all()
for prop in props: for prop in props:
prop_contents = PropertyContent.query.filter( prop_contents = PropertyContent.query.filter(PropertyContent.property_id == prop.id).all()
PropertyContent.property_id == prop.id
).all()
for prop_content in prop_contents: for prop_content in prop_contents:
if prop_content.lot == "14": if prop_content.lot == "14":
UGC.query.filter(UGC.id == prop.ugc_id).first().delete() UGC.query.filter(UGC.id == prop.ugc_id).first().delete()
prop_content.delete() prop_content.delete()
prop.delete() prop.delete()
friends = Friends.query.filter(
or_(Friends.player_id == char.id, Friends.friend_id == char.id)
).all()
for friend in friends:
friend.delete()
char.delete() char.delete()
# This is for GM stuff, it will be permnently delete logs # This is for GM stuff, it will be permnently delete logs
bugs = BugReport.query.filter(BugReport.resoleved_by_id == id).all() bugs = BugReport.query.filter(BugReport.resolve_by_id == id).all()
for bug in bugs: for bug in bugs:
bug.delete() bug.delete()
audits = AuditLog.query.filter(AuditLog.account_id == id).all() audits = AuditLog.query.filter(AuditLog.account_id == id).all()
for audit in audits: for audit in audits:
audit.delete() audit.delete()
invites = AccountInvitation.query.filter( invites = AccountInvitation.query.filter(AccountInvitation.invited_by_user_id == id).all()
AccountInvitation.invited_by_user_id == id).all()
for invite in invites: for invite in invites:
invite.delete() invite.delete()
account.delete() account.delete()
@ -196,27 +184,6 @@ def delete(id):
return redirect(url_for("main.index")) return redirect(url_for("main.index"))
@accounts_blueprint.route('/pass_reset/<id>', methods=['GET', 'POST'])
@login_required
@gm_level(9)
def pass_reset(id):
# get the account
account = Account.query.filter(Account.id == id).first()
# make a random pass of length 12 using secrets
raw_pass = secrets.token_urlsafe(12)
# generate the hash
salt = bcrypt.gensalt()
hashed = bcrypt.hashpw(str.encode(raw_pass), salt)
# save the has
account.password = hashed
account.save()
# display for the admin to get and log that the action was done
flash(f"Set password for account {account.username} to {raw_pass}", "success")
log_audit(f"Reset password for {account.username}")
return redirect(request.referrer if request.referrer else url_for("main.index"))
@accounts_blueprint.route('/get', methods=['GET']) @accounts_blueprint.route('/get', methods=['GET'])
@login_required @login_required
@gm_level(3) @gm_level(3)
@ -252,9 +219,6 @@ def get():
# Delete # Delete
# </a> # </a>
if not current_app.config["USER_ENABLE_EMAIL"]:
account["2"] = '''N/A'''
if account["4"]: if account["4"]:
account["4"] = '''<h2 class="far fa-times-circle text-danger"></h2>''' account["4"] = '''<h2 class="far fa-times-circle text-danger"></h2>'''
else: else:
@ -270,11 +234,20 @@ def get():
else: else:
account["6"] = '''<h2 class="far fa-check-square text-success"></h2>''' account["6"] = '''<h2 class="far fa-check-square text-success"></h2>'''
if not current_app.config["USER_ENABLE_EMAIL"]: if current_app.config["USER_ENABLE_EMAIL"]:
account["8"] = '''<h2 class="far fa-times-circle text-muted"></h2>''' if account["8"]:
elif account["8"]: account["8"] = '''<h2 class="far fa-check-square text-success"></h2>'''
account["8"] = '''<h2 class="far fa-check-square text-success"></h2>''' else:
account["8"] = '''<h2 class="far fa-times-circle text-danger"></h2>'''
else: else:
account["8"] = '''<h2 class="far fa-times-circle text-danger"></h2>''' # shift columns to fill in gap of 2
account["2"] = account["3"]
account["3"] = account["4"]
account["4"] = account["5"]
account["5"] = account["6"]
account["6"] = account["7"]
# remove last two columns
del account["7"]
del account["8"]
return data return data

View File

@ -1,19 +1,21 @@
from flask import render_template, Blueprint, redirect, url_for, request, abort, flash, make_response, current_app from flask import render_template, Blueprint, redirect, url_for, request, abort, flash, make_response
from flask_user import login_required, current_user from flask_user import login_required, current_user
from datatables import ColumnDT, DataTables from datatables import ColumnDT, DataTables
import time import time
from app.models import CharacterInfo, CharacterXML, Account, db from app.models import CharacterInfo, CharacterXML, Account, db
from app.forms import RescueForm, CharXMLUploadForm from app.schemas import CharacterInfoSchema
from app.forms import RescueForm
from app import gm_level, log_audit from app import gm_level, log_audit
from app.luclient import translate_from_locale from app.luclient import translate_from_locale
import xmltodict import xmltodict
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
import json
from xml.dom import minidom
character_blueprint = Blueprint('characters', __name__) character_blueprint = Blueprint('characters', __name__)
character_schema = CharacterInfoSchema()
@character_blueprint.route('/', methods=['GET']) @character_blueprint.route('/', methods=['GET'])
@login_required @login_required
@gm_level(3) @gm_level(3)
@ -28,20 +30,14 @@ def approve_name(id, action):
character = CharacterInfo.query.filter(CharacterInfo.id == id).first() character = CharacterInfo.query.filter(CharacterInfo.id == id).first()
if action == "approve": if action == "approve":
log_audit(f"Approved ({character.id}){character.pending_name} from {character.name}")
flash(
f"Approved ({character.id}){character.pending_name} from {character.name}",
"success"
)
if character.pending_name: if character.pending_name:
character.name = character.pending_name character.name = character.pending_name
character.pending_name = "" character.pending_name = ""
log_audit(f"Approved ({character.id}){character.pending_name} from {character.name}")
flash(
f"Approved ({character.id}){character.pending_name} from {character.name}",
"success"
)
else:
log_audit("Cannot make character name empty")
flash(
"Cannot make character name empty",
"danger"
)
character.needs_rename = False character.needs_rename = False
elif action == "rename": elif action == "rename":
@ -76,7 +72,7 @@ def view(id):
character_json = xmltodict.parse( character_json = xmltodict.parse(
CharacterXML.query.filter( CharacterXML.query.filter(
CharacterXML.id == id CharacterXML.id == id
).first().xml_data.replace("\"stt=", "\" stt="), ).first().xml_data,
attr_prefix="attr_" attr_prefix="attr_"
) )
@ -89,10 +85,9 @@ def view(id):
# stupid fix for jinja parsing # stupid fix for jinja parsing
character_json["obj"]["inv"]["holdings"] = character_json["obj"]["inv"].pop("items") character_json["obj"]["inv"]["holdings"] = character_json["obj"]["inv"].pop("items")
# sort by items slot index # sort by items slot index
if type(character_json["obj"]["inv"]["holdings"]["in"]) == list: for inv in character_json["obj"]["inv"]["holdings"]["in"]:
for inv in character_json["obj"]["inv"]["holdings"]["in"]: if "i" in inv.keys() and type(inv["i"]) == list:
if "i" in inv.keys() and type(inv["i"]) == list: inv["i"] = sorted(inv["i"], key=lambda i: int(i['attr_s']))
inv["i"] = sorted(inv["i"], key=lambda i: int(i['attr_s']))
return render_template( return render_template(
'character/view.html.j2', 'character/view.html.j2',
@ -100,88 +95,6 @@ def view(id):
character_json=character_json character_json=character_json
) )
@character_blueprint.route('/chardata/<id>', methods=['GET'])
@login_required
def chardata(id):
character_data = CharacterInfo.query.filter(CharacterInfo.id == id).first()
if character_data == {}:
abort(404)
return
if current_user.gm_level < 3:
if character_data.account_id and character_data.account_id != current_user.id:
abort(403)
return
character_json = xmltodict.parse(
CharacterXML.query.filter(
CharacterXML.id == id
).first().xml_data.replace("\"stt=", "\" stt="),
attr_prefix="attr_"
)
# print json for reference
# with open("errorchar.json", "a") as file:
# file.write(
# json.dumps(character_json, indent=4)
# )
# stupid fix for jinja parsing
character_json["obj"]["inv"]["holdings"] = character_json["obj"]["inv"].pop("items")
# sort by items slot index
if type(character_json["obj"]["inv"]["holdings"]["in"]) == list:
for inv in character_json["obj"]["inv"]["holdings"]["in"]:
if "i" in inv.keys() and type(inv["i"]) == list:
inv["i"] = sorted(inv["i"], key=lambda i: int(i['attr_s']))
return render_template(
'partials/_charxml.html.j2',
character_data=character_data,
character_json=character_json
)
@character_blueprint.route('/inventory/<id>/<inventory_id>', methods=['GET'])
@login_required
def inventory(id, inventory_id):
character_data = CharacterInfo.query.filter(CharacterInfo.id == id).first()
if character_data == {}:
abort(404)
return
if current_user.gm_level < 3:
if character_data.account_id and character_data.account_id != current_user.id:
abort(403)
return
character_json = xmltodict.parse(
CharacterXML.query.filter(
CharacterXML.id == id
).first().xml_data.replace("\"stt=", "\" stt="),
attr_prefix="attr_"
)
# print json for reference
# with open("errorchar.json", "a") as file:
# file.write(
# json.dumps(character_json, indent=4)
# )
# stupid fix for jinja parsing
character_json["obj"]["inv"]["holdings"] = character_json["obj"]["inv"].pop("items")
# sort by items slot index
if type(character_json["obj"]["inv"]["holdings"]["in"]) == list:
for inv in character_json["obj"]["inv"]["holdings"]["in"]:
if "i" in inv.keys() and type(inv["i"]) == list:
inv["i"] = sorted(inv["i"], key=lambda i: int(i['attr_s']))
for inventory in character_json["obj"]["inv"]["holdings"]["in"]:
if inventory["attr_t"] == inventory_id:
return render_template(
'partials/charxml/_inventory.html.j2',
inventory=inventory
)
return "No Items in Inventory", 404
@character_blueprint.route('/view_xml/<id>', methods=['GET']) @character_blueprint.route('/view_xml/<id>', methods=['GET'])
@login_required @login_required
@ -200,7 +113,7 @@ def view_xml(id):
character_xml = CharacterXML.query.filter( character_xml = CharacterXML.query.filter(
CharacterXML.id == id CharacterXML.id == id
).first().xml_data.replace("\"stt=", "\" stt=") ).first().xml_data
response = make_response(character_xml) response = make_response(character_xml)
response.headers.set('Content-Type', 'text/xml') response.headers.set('Content-Type', 'text/xml')
@ -271,7 +184,7 @@ def rescue(id):
CharacterXML.id == id CharacterXML.id == id
).first() ).first()
character_xml = ET.XML(character_data.xml_data.replace("\"stt=", "\" stt=")) character_xml = ET.XML(character_data.xml_data)
for zone in character_xml.findall('.//r'): for zone in character_xml.findall('.//r'):
if int(zone.attrib["w"]) % 100 == 0: if int(zone.attrib["w"]) % 100 == 0:
form.save_world.choices.append( form.save_world.choices.append(
@ -297,30 +210,6 @@ def rescue(id):
return render_template("character/rescue.html.j2", form=form) return render_template("character/rescue.html.j2", form=form)
@character_blueprint.route('/upload/<id>', methods=['GET', 'POST'])
@login_required
@gm_level(8)
def upload(id):
if not current_app.config["ENABLE_CHAR_XML_UPLOAD"]:
flash("You must enable this setting to do this", "danger")
return redirect(url_for('characters.view', id=id))
form = CharXMLUploadForm()
character_data = CharacterXML.query.filter(
CharacterXML.id == id
).first()
if form.validate_on_submit():
character_data.xml_data = form.char_xml.data
character_data.save()
flash("You accept all consequences from these actions", "danger")
log_audit(f"Updated {character_data.id}'s xml data")
return redirect(url_for('characters.view', id=id))
form.char_xml.data = minidom.parseString(character_data.xml_data).toprettyxml(indent=" ")
return render_template("character/upload.html.j2", form=form)
@character_blueprint.route('/get/<status>', methods=['GET']) @character_blueprint.route('/get/<status>', methods=['GET'])
@login_required @login_required
@gm_level(3) @gm_level(3)
@ -339,7 +228,7 @@ def get(status):
if status == "approved": if status == "approved":
query = db.session.query().select_from(CharacterInfo).join(Account).filter((CharacterInfo.pending_name == "") & (CharacterInfo.needs_rename == False)) query = db.session.query().select_from(CharacterInfo).join(Account).filter((CharacterInfo.pending_name == "") & (CharacterInfo.needs_rename == False))
elif status == "unapproved": elif status == "unapproved":
query = db.session.query().select_from(CharacterInfo).join(Account).filter((CharacterInfo.pending_name != "") & (CharacterInfo.needs_rename == False)) query = db.session.query().select_from(CharacterInfo).join(Account).filter((CharacterInfo.pending_name != "") | (CharacterInfo.needs_rename == True))
else: else:
query = db.session.query().select_from(CharacterInfo).join(Account) query = db.session.query().select_from(CharacterInfo).join(Account)

View File

@ -4,8 +4,8 @@ import random
import string import string
import datetime import datetime
from flask_user import current_app from flask_user import current_app
from app import db, luclient from app import db
from app.models import Account, PlayKey, CharacterInfo, Property, PropertyContent, UGC, Mail, CharacterXML from app.models import Account, PlayKey, CharacterInfo, Property, PropertyContent, UGC, Mail
import pathlib import pathlib
import zlib import zlib
from wand import image from wand import image
@ -15,7 +15,7 @@ from multiprocessing import Pool
from functools import partial from functools import partial
from sqlalchemy import func from sqlalchemy import func
import time import time
import xml.etree.ElementTree as ET
@click.command("init_db") @click.command("init_db")
@click.argument('drop_tables', nargs=1) @click.argument('drop_tables', nargs=1)
@ -180,20 +180,6 @@ def load_property(zone, player):
) )
new_prop_content.save() new_prop_content.save()
@click.command("remove_buffs")
@with_appcontext
def remove_buffs():
"""Clears all buff from all characters"""
chars = CharacterXML.query.all()
for char in chars:
character_xml = ET.XML(char.xml_data.replace("\"stt=", "\" stt="))
dest = character_xml.find(".//dest")
if dest:
buff = character_xml.find(".//buff")
if buff:
dest.remove(buff)
char.xml_data = ET.tostring(character_xml)
char.save()
@click.command("gen_image_cache") @click.command("gen_image_cache")
def gen_image_cache(): def gen_image_cache():
@ -281,41 +267,3 @@ def find_or_create_account(name, email, password, gm_level=9):
db.session.add(play_key) db.session.add(play_key)
db.session.commit() db.session.commit()
return # account return # account
@click.command("find_missing_commendation_items")
@with_appcontext
def find_missing_commendation_items():
data = dict()
lots = set()
reward_items = luclient.query_cdclient("Select reward_item1 from Missions;")
for reward_item in reward_items:
lots.add(reward_item[0])
reward_items = luclient.query_cdclient("Select reward_item2 from Missions;")
for reward_item in reward_items:
lots.add(reward_item[0])
reward_items = luclient.query_cdclient("Select reward_item3 from Missions;")
for reward_item in reward_items:
lots.add(reward_item[0])
reward_items = luclient.query_cdclient("Select reward_item4 from Missions;")
for reward_item in reward_items:
lots.add(reward_item[0])
lots.remove(0)
lots.remove(-1)
for lot in lots:
itemcompid = luclient.query_cdclient(
"Select component_id from ComponentsRegistry where component_type = 11 and id = ?;",
[lot],
one=True
)[0]
itemcomp = luclient.query_cdclient(
"Select commendationLOT, commendationCost from ItemComponent where id = ?;",
[itemcompid],
one=True
)
if itemcomp[0] is None or itemcomp[1] is None:
data[lot] = {"name": luclient.get_lot_name(lot)}
print(data)

View File

@ -1,15 +1,17 @@
from flask_wtf import FlaskForm, Recaptcha, RecaptchaField from flask_wtf import FlaskForm
from flask import current_app from flask import current_app
from flask_user.forms import ( from flask_user.forms import (
unique_email_validator, unique_email_validator,
LoginForm, password_validator,
RegisterForm unique_username_validator
) )
from flask_user import UserManager from flask_user import UserManager
from wtforms.widgets import TextArea, NumberInput from wtforms.widgets import TextArea, NumberInput
from wtforms import ( from wtforms import (
StringField, StringField,
HiddenField,
PasswordField,
BooleanField, BooleanField,
SubmitField, SubmitField,
validators, validators,
@ -22,43 +24,67 @@ from app.models import PlayKey
def validate_play_key(form, field): def validate_play_key(form, field):
"""Validates a field for a valid play kyey """Validates a field for a valid phone number
Args: Args:
form: REQUIRED, the field's parent form form: REQUIRED, the field's parent form
field: REQUIRED, the field with data field: REQUIRED, the field with data
Returns: Returns:
None, raises ValidationError if failed None, raises ValidationError if failed
""" """
# jank to get the foreign key that we need back into the field # jank to get the fireign key that we need back into the field
if current_app.config["REQUIRE_PLAY_KEY"]: if current_app.config["REQUIRE_PLAY_KEY"]:
field.data = PlayKey.key_is_valid(key_string=field.data) field.data = PlayKey.key_is_valid(key_string=field.data)
return True return
class CustomRecaptcha(Recaptcha):
def __call__(self, form, field):
if not current_app.config.get("RECAPTCHA_ENABLE", False):
return True
return super(CustomRecaptcha, self).__call__(form, field)
class CustomUserManager(UserManager): class CustomUserManager(UserManager):
def customize(self, app): def customize(self, app):
self.RegisterFormClass = CustomRegisterForm self.RegisterFormClass = CustomRegisterForm
self.LoginFormClass = CustomLoginForm
class CustomRegisterForm(RegisterForm):
class CustomRegisterForm(FlaskForm):
"""Registration form"""
next = HiddenField()
reg_next = HiddenField()
# Login Info
email = StringField(
'E-Mail',
validators=[
Optional(),
validators.Email('Invalid email address'),
unique_email_validator,
]
)
username = StringField(
'Username',
validators=[
DataRequired(),
unique_username_validator,
]
)
play_key_id = StringField( play_key_id = StringField(
'Play Key', 'Play Key',
validators=[validate_play_key] validators=[
) Optional(),
recaptcha = RecaptchaField( validate_play_key,
validators=[CustomRecaptcha()] ]
) )
class CustomLoginForm(LoginForm): password = PasswordField('Password', validators=[
recaptcha = RecaptchaField( DataRequired(),
validators=[CustomRecaptcha()] password_validator
) ])
retype_password = PasswordField('Retype Password', validators=[
validators.EqualTo('password', message='Passwords did not match')
])
invite_token = HiddenField('Token')
submit = SubmitField('Register')
class CreatePlayKeyForm(FlaskForm): class CreatePlayKeyForm(FlaskForm):
@ -93,7 +119,7 @@ class EditPlayKeyForm(FlaskForm):
class EditGMLevelForm(FlaskForm): class EditGMLevelForm(FlaskForm):
gm_level = IntegerField( email = IntegerField(
'GM Level', 'GM Level',
widget=NumberInput(min=0, max=9) widget=NumberInput(min=0, max=9)
) )
@ -183,13 +209,3 @@ class RejectPropertyForm(FlaskForm):
) )
submit = SubmitField('Submit') submit = SubmitField('Submit')
class CharXMLUploadForm(FlaskForm):
char_xml = StringField(
'Paste minified charxml here:',
widget=TextArea(),
validators=[validators.DataRequired()]
)
submit = SubmitField('Submit')

View File

@ -25,7 +25,7 @@ def command():
@log_blueprint.route('/system') @log_blueprint.route('/system')
@gm_level(8) @gm_level(8)
def system(): def system():
with open('logs/nexus_dashboard.log', 'r') as file: with open('nexus_dashboard.log', 'r') as file:
logs = '</br>'.join(file.read().split('\n')[-100:]) logs = '</br>'.join(file.read().split('\n')[-100:])
return render_template('logs/system.html.j2', logs=logs) return render_template('logs/system.html.j2', logs=logs)

View File

@ -5,8 +5,7 @@ from flask import (
redirect, redirect,
url_for, url_for,
make_response, make_response,
abort, abort
current_app
) )
from flask_user import login_required from flask_user import login_required
from app.models import CharacterInfo from app.models import CharacterInfo
@ -33,7 +32,7 @@ def get_dds_as_png(filename):
cache = f'cache/{filename.split(".")[0]}.png' cache = f'cache/{filename.split(".")[0]}.png'
if not os.path.exists(cache): if not os.path.exists(cache):
root = f"{current_app.config['CLIENT_LOCATION']}res/" root = 'app/luclient/res/'
path = glob.glob( path = glob.glob(
root + f'**/{filename}', root + f'**/{filename}',
@ -42,7 +41,7 @@ def get_dds_as_png(filename):
with image.Image(filename=path) as img: with image.Image(filename=path) as img:
img.compression = "no" img.compression = "no"
img.save(filename=current_app.config["CACHE_LOCATION"] + filename.split('.')[0] + '.png') img.save(filename='app/cache/' + filename.split('.')[0] + '.png')
return send_file(cache) return send_file(cache)
@ -53,7 +52,7 @@ def get_dds(filename):
if filename.split('.')[-1] != 'dds': if filename.split('.')[-1] != 'dds':
return 404 return 404
root = f"{current_app.config['CLIENT_LOCATION']}res/" root = 'app/luclient/res/'
dds = glob.glob( dds = glob.glob(
root + f'**/{filename}', root + f'**/{filename}',
@ -66,17 +65,12 @@ def get_dds(filename):
@luclient_blueprint.route('/get_icon_lot/<id>') @luclient_blueprint.route('/get_icon_lot/<id>')
@login_required @login_required
def get_icon_lot(id): def get_icon_lot(id):
if id is None:
redirect(url_for('luclient.unknown'))
render_component_id = query_cdclient( render_component_id = query_cdclient(
'select component_id from ComponentsRegistry where component_type = 2 and id = ?', 'select component_id from ComponentsRegistry where component_type = 2 and id = ?',
[id], [id],
one=True one=True
) )[0]
if render_component_id is not None:
render_component_id = render_component_id[0]
else:
return redirect(url_for('luclient.unknown'))
# find the asset from rendercomponent given the component id # find the asset from rendercomponent given the component id
filename = query_cdclient( filename = query_cdclient(
@ -90,10 +84,10 @@ def get_icon_lot(id):
else: else:
return redirect(url_for('luclient.unknown')) return redirect(url_for('luclient.unknown'))
cache = f'{current_app.config["CACHE_LOCATION"]}{filename.split(".")[0]}.png' cache = f'app/cache/{filename.split(".")[0]}.png'
if not os.path.exists(cache): if not os.path.exists(cache):
root = f"{current_app.config['CLIENT_LOCATION']}res/" root = 'app/luclient/res/'
try: try:
pathlib.Path(os.path.dirname(cache)).resolve().mkdir(parents=True, exist_ok=True) pathlib.Path(os.path.dirname(cache)).resolve().mkdir(parents=True, exist_ok=True)
with image.Image(filename=f'{root}{filename}'.lower()) as img: with image.Image(filename=f'{root}{filename}'.lower()) as img:
@ -117,10 +111,10 @@ def get_icon_iconid(id):
filename = filename.replace("..\\", "").replace("\\", "/") filename = filename.replace("..\\", "").replace("\\", "/")
cache = f'{current_app.config["CACHE_LOCATION"]}{filename.split(".")[0]}.png' cache = f'app/cache/{filename.split(".")[0]}.png'
if not os.path.exists(cache): if not os.path.exists(cache):
root = f"{current_app.config['CLIENT_LOCATION']}res/" root = 'app/luclient/res/'
try: try:
pathlib.Path(os.path.dirname(cache)).resolve().mkdir(parents=True, exist_ok=True) pathlib.Path(os.path.dirname(cache)).resolve().mkdir(parents=True, exist_ok=True)
with image.Image(filename=f'{root}{filename}'.lower()) as img: with image.Image(filename=f'{root}{filename}'.lower()) as img:
@ -138,14 +132,14 @@ def brick_list():
brick_list = [] brick_list = []
if len(brick_list) == 0: if len(brick_list) == 0:
suffixes = [".g", ".g1", ".g2", ".g3", ".xml"] suffixes = [".g", ".g1", ".g2", ".g3", ".xml"]
cache = pathlib.Path(f"{current_app.config['CACHE_LOCATION']}") res = pathlib.Path('app/luclient/res/')
# Load g files # Load g files
for path in cache.rglob("*.*"): for path in res.rglob("*.*"):
if str(path.suffix) in suffixes: if str(path.suffix) in suffixes:
brick_list.append( brick_list.append(
{ {
"type": "file", "type": "file",
"name": str(path.as_posix()).replace(f"{current_app.config['CACHE_LOCATION']}", "") "name": str(path.as_posix()).replace("app/luclient/res/", "")
} }
) )
response = make_response(json.dumps(brick_list)) response = make_response(json.dumps(brick_list))
@ -157,7 +151,7 @@ def brick_list():
@luclient_blueprint.route('/ldddb/<path:req_path>') @luclient_blueprint.route('/ldddb/<path:req_path>')
def dir_listing(req_path): def dir_listing(req_path):
# Joining the base and the requested path # Joining the base and the requested path
rel_path = pathlib.Path(str(pathlib.Path(f"{current_app.config['CACHE_LOCATION']}/{req_path}").resolve())) rel_path = pathlib.Path(str(pathlib.Path(f'app/luclient/res/{req_path}').resolve()))
# Return 404 if path doesn't exist # Return 404 if path doesn't exist
if not rel_path.exists(): if not rel_path.exists():
return abort(404) return abort(404)
@ -174,10 +168,10 @@ def dir_listing(req_path):
def unknown(): def unknown():
filename = "textures/ui/inventory/unknown.dds" filename = "textures/ui/inventory/unknown.dds"
cache = f'{current_app.config["CACHE_LOCATION"]}{filename.split(".")[0]}.png' cache = f'app/cache/{filename.split(".")[0]}.png'
if not os.path.exists(cache): if not os.path.exists(cache):
root = f"{current_app.config['CLIENT_LOCATION']}res/" root = 'app/luclient/res/'
try: try:
pathlib.Path(os.path.dirname(cache)).resolve().mkdir(parents=True, exist_ok=True) pathlib.Path(os.path.dirname(cache)).resolve().mkdir(parents=True, exist_ok=True)
with image.Image(filename=f'{root}{filename}'.lower()) as img: with image.Image(filename=f'{root}{filename}'.lower()) as img:
@ -197,16 +191,7 @@ def get_cdclient():
""" """
cdclient = getattr(g, '_cdclient', None) cdclient = getattr(g, '_cdclient', None)
if cdclient is None: if cdclient is None:
path = pathlib.Path(f"{current_app.config['CD_SQLITE_LOCATION']}cdclient.sqlite") cdclient = g._database = sqlite3.connect('app/luclient/res/cdclient.sqlite')
if path.is_file():
cdclient = g._database = sqlite3.connect(f"{current_app.config['CD_SQLITE_LOCATION']}cdclient.sqlite")
return cdclient
path = pathlib.Path(f"{current_app.config['CD_SQLITE_LOCATION']}CDServer.sqlite")
if path.is_file():
cdclient = g._database = sqlite3.connect(f"{current_app.config['CD_SQLITE_LOCATION']}CDServer.sqlite")
return cdclient
return cdclient return cdclient
@ -238,7 +223,7 @@ def translate_from_locale(trans_string):
locale_data = "" locale_data = ""
if not locale: if not locale:
locale_path = f"{current_app.config['CLIENT_LOCATION']}locale/locale.xml" locale_path = "app/luclient/locale/locale.xml"
with open(locale_path, 'r') as file: with open(locale_path, 'r') as file:
locale_data = file.read() locale_data = file.read()
@ -296,7 +281,6 @@ def register_luclient_jinja_helpers(app):
@app.template_filter('parse_lzid') @app.template_filter('parse_lzid')
def parse_lzid(lzid): def parse_lzid(lzid):
if not lzid: return [1000, 1000, 1000]
return[ return[
(int(lzid) & ((1 << 16) - 1)), (int(lzid) & ((1 << 16) - 1)),
((int(lzid) >> 16) & ((1 << 16) - 1)), ((int(lzid) >> 16) & ((1 << 16) - 1)),
@ -324,9 +308,7 @@ def register_luclient_jinja_helpers(app):
'select component_id from ComponentsRegistry where component_type = 11 and id = ?', 'select component_id from ComponentsRegistry where component_type = 11 and id = ?',
[lot_id], [lot_id],
one=True one=True
) )[0]
if render_component_id:
render_component_id = render_component_id[0]
rarity = query_cdclient( rarity = query_cdclient(
'select rarity from ItemComponent where id = ?', 'select rarity from ItemComponent where id = ?',

View File

@ -69,7 +69,8 @@ def send():
form.recipient.choices.append((character.id, character.name)) form.recipient.choices.append((character.id, character.name))
items = query_cdclient( items = query_cdclient(
'Select id, name, displayName from Objects where type = "Loot"' 'Select id, name, displayName from Objects where type = ?',
["Loot"]
) )
for item in items: for item in items:

View File

@ -2,12 +2,13 @@ from flask import render_template, Blueprint, send_from_directory
from flask_user import current_user, login_required from flask_user import current_user, login_required
from app.models import Account, CharacterInfo, ActivityLog from app.models import Account, CharacterInfo, ActivityLog
from app.schemas import AccountSchema, CharacterInfoSchema
import datetime
import time
main_blueprint = Blueprint('main', __name__) main_blueprint = Blueprint('main', __name__)
account_schema = AccountSchema()
char_info_schema = CharacterInfoSchema()
@main_blueprint.route('/', methods=['GET']) @main_blueprint.route('/', methods=['GET'])
def index(): def index():
@ -27,16 +28,12 @@ def index():
@login_required @login_required
def about(): def about():
"""About Page""" """About Page"""
mods = Account.query.filter(Account.gm_level > 1).order_by(Account.gm_level.desc()).all() mods = Account.query.filter(Account.gm_level > 0).order_by(Account.gm_level.desc()).all()
online = 0 online = 0
users = [] chars = CharacterInfo.query.all()
zones = {}
twodaysago = time.mktime((datetime.datetime.now() - datetime.timedelta(days=2)).timetuple())
chars = CharacterInfo.query.filter(CharacterInfo.last_login >= twodaysago).all()
for char in chars: for char in chars:
last_log = ActivityLog.query.with_entities( last_log = ActivityLog.query.with_entities(
ActivityLog.activity, ActivityLog.map_id ActivityLog.activity
).filter( ).filter(
ActivityLog.character_id == char.id ActivityLog.character_id == char.id
).order_by(ActivityLog.id.desc()).first() ).order_by(ActivityLog.id.desc()).first()
@ -44,13 +41,8 @@ def about():
if last_log: if last_log:
if last_log[0] == 0: if last_log[0] == 0:
online += 1 online += 1
if current_user.gm_level >= 8: users.append([char.name, last_log[1]])
if str(last_log[1]) not in zones:
zones[str(last_log[1])] = 1
else:
zones[str(last_log[1])] += 1
return render_template('main/about.html.j2', mods=mods, online=online, users=users, zones=zones) return render_template('main/about.html.j2', mods=mods, online=online)
@main_blueprint.route('/favicon.ico') @main_blueprint.route('/favicon.ico')

View File

@ -4,9 +4,10 @@ from flask_user import UserMixin
from wtforms import ValidationError from wtforms import ValidationError
import logging import logging
from flask_sqlalchemy.query import Query from flask_sqlalchemy import BaseQuery
from sqlalchemy.dialects import mysql from sqlalchemy.dialects import mysql
from sqlalchemy.exc import OperationalError, StatementError from sqlalchemy.exc import OperationalError, StatementError
from sqlalchemy.types import JSON
from time import sleep from time import sleep
import random import random
import string import string
@ -14,7 +15,7 @@ import string
# retrying query to work around python trash collector # retrying query to work around python trash collector
# killing connections of other gunicorn workers # killing connections of other gunicorn workers
class RetryingQuery(Query): class RetryingQuery(BaseQuery):
__retry_count__ = 3 __retry_count__ = 3
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
@ -113,7 +114,7 @@ class PlayKey(db.Model):
) )
db.session.add(new_key) db.session.add(new_key)
db.session.commit() db.session.commit()
return key return key
def delete(self): def delete(self):
db.session.delete(self) db.session.delete(self)
@ -1017,7 +1018,7 @@ class Reports(db.Model):
__tablename__ = 'reports' __tablename__ = 'reports'
data = db.Column( data = db.Column(
mysql.MEDIUMBLOB(), JSON(),
nullable=False nullable=False
) )

View File

@ -11,14 +11,14 @@ play_keys_blueprint = Blueprint('play_keys', __name__)
# Key creation page # Key creation page
@play_keys_blueprint.route('/', methods=['GET']) @play_keys_blueprint.route('/', methods=['GET'])
@login_required @login_required
@gm_level(5) @gm_level(9)
def index(): def index():
return render_template('play_keys/index.html.j2') return render_template('play_keys/index.html.j2')
@play_keys_blueprint.route('/create/<count>/<uses>', methods=['GET'], defaults={'count': 1, 'uses': 1}) @play_keys_blueprint.route('/create/<count>/<uses>', methods=['GET'], defaults={'count': 1, 'uses': 1})
@login_required @login_required
@gm_level(5) @gm_level(9)
def create(count=1, uses=1): def create(count=1, uses=1):
key = PlayKey.create(count=count, uses=uses) key = PlayKey.create(count=count, uses=uses)
log_audit(f"Created {count} Play Key(s) with {uses} uses!") log_audit(f"Created {count} Play Key(s) with {uses} uses!")
@ -28,7 +28,7 @@ def create(count=1, uses=1):
@play_keys_blueprint.route('/create/bulk', methods=('GET', 'POST')) @play_keys_blueprint.route('/create/bulk', methods=('GET', 'POST'))
@login_required @login_required
@gm_level(5) @gm_level(9)
def bulk_create(): def bulk_create():
form = CreatePlayKeyForm() form = CreatePlayKeyForm()
if form.validate_on_submit(): if form.validate_on_submit():
@ -42,7 +42,7 @@ def bulk_create():
@play_keys_blueprint.route('/delete/<id>', methods=('GET', 'POST')) @play_keys_blueprint.route('/delete/<id>', methods=('GET', 'POST'))
@login_required @login_required
@gm_level(5) @gm_level(9)
def delete(id): def delete(id):
key = PlayKey.query.filter(PlayKey.id == id).first() key = PlayKey.query.filter(PlayKey.id == id).first()
# associated_accounts = Account.query.filter(Account.play_key_id==id).all() # associated_accounts = Account.query.filter(Account.play_key_id==id).all()
@ -54,7 +54,7 @@ def delete(id):
@play_keys_blueprint.route('/edit/<id>', methods=('GET', 'POST')) @play_keys_blueprint.route('/edit/<id>', methods=('GET', 'POST'))
@login_required @login_required
@gm_level(5) @gm_level(9)
def edit(id): def edit(id):
key = PlayKey.query.filter(PlayKey.id == id).first() key = PlayKey.query.filter(PlayKey.id == id).first()
form = EditPlayKeyForm() form = EditPlayKeyForm()
@ -81,7 +81,7 @@ def edit(id):
@play_keys_blueprint.route('/view/<id>', methods=('GET', 'POST')) @play_keys_blueprint.route('/view/<id>', methods=('GET', 'POST'))
@login_required @login_required
@gm_level(5) @gm_level(9)
def view(id): def view(id):
key = PlayKey.query.filter(PlayKey.id == id).first() key = PlayKey.query.filter(PlayKey.id == id).first()
accounts = Account.query.filter(Account.play_key_id == id).all() accounts = Account.query.filter(Account.play_key_id == id).all()
@ -90,7 +90,7 @@ def view(id):
@play_keys_blueprint.route('/get', methods=['GET']) @play_keys_blueprint.route('/get', methods=['GET'])
@login_required @login_required
@gm_level(5) @gm_level(9)
def get(): def get():
columns = [ columns = [
ColumnDT(PlayKey.id), ColumnDT(PlayKey.id),

View File

@ -13,6 +13,7 @@ from flask_user import login_required, current_user
from datatables import ColumnDT, DataTables from datatables import ColumnDT, DataTables
import time import time
from app.models import Property, db, UGC, CharacterInfo, PropertyContent, Account, Mail from app.models import Property, db, UGC, CharacterInfo, PropertyContent, Account, Mail
from app.schemas import PropertySchema
from app import gm_level, log_audit from app import gm_level, log_audit
from app.luclient import query_cdclient from app.luclient import query_cdclient
from app.forms import RejectPropertyForm from app.forms import RejectPropertyForm
@ -23,6 +24,9 @@ import pathlib
property_blueprint = Blueprint('properties', __name__) property_blueprint = Blueprint('properties', __name__)
property_schema = PropertySchema()
@property_blueprint.route('/', methods=['GET']) @property_blueprint.route('/', methods=['GET'])
@login_required @login_required
@gm_level(3) @gm_level(3)
@ -407,37 +411,25 @@ def download_model(id):
def ugc(content): def ugc(content):
ugc_data = UGC.query.filter(UGC.id == content.ugc_id).first() ugc_data = UGC.query.filter(UGC.id == content.ugc_id).first()
uncompressed_lxfml = decompress(ugc_data.lxfml) uncompressed_lxfml = zlib.decompress(ugc_data.lxfml)
response = make_response(uncompressed_lxfml) response = make_response(uncompressed_lxfml)
return response, ugc_data.filename return response, ugc_data.filename
def decompress(data):
assert data[:5] == b"sd0\x01\xff"
pos = 5
out = b""
while pos < len(data):
length = int.from_bytes(data[pos:pos+4], "little")
pos += 4
out += zlib.decompress(data[pos:pos+length])
pos += length
return out
def prebuilt(content, file_format, lod): def prebuilt(content, file_format, lod):
# translate LOT to component id # translate LOT to component id
# we need to get a type of 2 for the render component to find the filename # we need to get a type of 2 because reasons
render_component_id = query_cdclient( render_component_id = query_cdclient(
'select component_id from ComponentsRegistry where component_type = 2 and id = ?', 'select component_id from ComponentsRegistry where component_type = 2 and id = ?',
[content.lot], [content.lot],
one=True one=True
)[0] )[0]
# find the asset from rendercomponent given the component id # find the asset from rendercomponent given the component id
filename = query_cdclient( filename = query_cdclient(
'select render_asset from RenderComponent where id = ?', 'select render_asset from RenderComponent where id = ?',
[render_component_id], [render_component_id],
one=True one=True
) )
# if we have a valie filename, coerce it
if filename: if filename:
filename = filename[0].split("\\\\")[-1].lower().split(".")[0] filename = filename[0].split("\\\\")[-1].lower().split(".")[0]
if "/" in filename: if "/" in filename:
@ -445,29 +437,25 @@ def prebuilt(content, file_format, lod):
else: else:
return f"No filename for LOT {content.lot}" return f"No filename for LOT {content.lot}"
# if we just want the lxfml, fine t and return it lxfml = pathlib.Path(f'app/luclient/res/BrickModels/{filename.split(".")[0]}.lxfml')
lxfml = pathlib.Path(f'{current_app.config["CLIENT_LOCATION"]}res/BrickModels/{filename.split(".")[0]}.lxfml')
if file_format == "lxfml": if file_format == "lxfml":
with open(lxfml, 'r') as file: with open(lxfml, 'r') as file:
lxfml_data = file.read() lxfml_data = file.read()
response = make_response(lxfml_data) response = make_response(lxfml_data)
# else we handle getting the files for lddviewer
elif file_format in ["obj", "mtl"]: elif file_format in ["obj", "mtl"]:
# check to see if the file exists cache = pathlib.Path(f'app/cache/BrickModels/{filename}.lod{lod}.{file_format}')
cache = pathlib.Path(f'{current_app.config["CACHE_LOCATION"]}BrickModels/{filename}.lod{lod}.{file_format}')
if not cache.is_file(): if not cache.is_file():
# if not make it an store it for later
cache.parent.mkdir(parents=True, exist_ok=True) cache.parent.mkdir(parents=True, exist_ok=True)
try: try:
ldd.main(str(lxfml.as_posix()), str(cache.with_suffix("").as_posix()), lod) # convert to OBJ ldd.main(str(lxfml.as_posix()), str(cache.with_suffix("").as_posix()), lod) # convert to OBJ
except Exception as e: except Exception as e:
current_app.logger.error(f"ERROR on {cache}:\n {e}") current_app.logger.error(f"ERROR on {cache}:\n {e}")
# then just read it
with open(str(cache.as_posix()), 'r') as file: with open(str(cache.as_posix()), 'r') as file:
cache_data = file.read() cache_data = file.read()
# and serve it
response = make_response(cache_data) response = make_response(cache_data)
else: else:

View File

@ -7,7 +7,6 @@ import math
import struct import struct
import zipfile import zipfile
from xml.dom import minidom from xml.dom import minidom
from flask import current_app
PRIMITIVEPATH = '/Primitives/' PRIMITIVEPATH = '/Primitives/'
GEOMETRIEPATH = PRIMITIVEPATH GEOMETRIEPATH = PRIMITIVEPATH
@ -969,8 +968,8 @@ def main(lxf_filename, obj_filename, lod="2"):
GEOMETRIEPATH = GEOMETRIEPATH + f"LOD{lod}/" GEOMETRIEPATH = GEOMETRIEPATH + f"LOD{lod}/"
converter = Converter() converter = Converter()
# print("Found DB folder. Will use this instead of db.lif!") # print("Found DB folder. Will use this instead of db.lif!")
setDBFolderVars(dbfolderlocation=f"{current_app.config['CACHE_LOCATION']}", lod=lod) setDBFolderVars(dbfolderlocation="app/luclient/res/", lod=lod)
converter.LoadDBFolder(dbfolderlocation=f"{current_app.config['CACHE_LOCATION']}") converter.LoadDBFolder(dbfolderlocation="app/luclient/res/")
converter.LoadScene(filename=lxf_filename) converter.LoadScene(filename=lxf_filename)
converter.Export(filename=obj_filename) converter.Export(filename=obj_filename)

View File

@ -4,7 +4,9 @@ from app.models import CharacterInfo, Account, CharacterXML, Reports
from app.luclient import get_lot_name from app.luclient import get_lot_name
from app import gm_level, scheduler from app import gm_level, scheduler
from sqlalchemy.orm import load_only from sqlalchemy.orm import load_only
import xmltodict, gzip, json, datetime import datetime
import xmltodict
import random
reports_blueprint = Blueprint('reports', __name__) reports_blueprint = Blueprint('reports', __name__)
@ -30,6 +32,7 @@ def index():
).filter( ).filter(
Reports.report_type == "uscore" Reports.report_type == "uscore"
).group_by(Reports.date).options(load_only(Reports.date)).all() ).group_by(Reports.date).options(load_only(Reports.date)).all()
return render_template( return render_template(
'reports/index.html.j2', 'reports/index.html.j2',
reports_items=reports_items, reports_items=reports_items,
@ -43,8 +46,6 @@ def index():
@gm_level(3) @gm_level(3)
def items_by_date(date): def items_by_date(date):
data = Reports.query.filter(Reports.date == date).filter(Reports.report_type == "items").first().data data = Reports.query.filter(Reports.date == date).filter(Reports.report_type == "items").first().data
data = gzip.decompress(data)
data = json.loads(data.decode('utf-8'))
return render_template('reports/items/by_date.html.j2', data=data, date=date) return render_template('reports/items/by_date.html.j2', data=data, date=date)
@ -63,31 +64,25 @@ def items_graph(start, end):
datasets = [] datasets = []
# get stuff ready # get stuff ready
for entry in entries: for entry in entries:
entry.data = gzip.decompress(entry.data)
entry.data = json.loads(entry.data.decode('utf-8'))
labels.append(entry.date.strftime("%m/%d/%Y")) labels.append(entry.date.strftime("%m/%d/%Y"))
for key in entry.data: for key in entry.data:
items[key] = get_lot_name(key) items[key] = get_lot_name(key)
# make it # make it
for key, value in items.items(): for key, value in items.items():
if value: data = []
data = [] for entry in entries:
for entry in entries: if key in entry.data.keys():
if key in entry.data.keys(): data.append(entry.data[key])
if not isinstance(entry.data[key], int): else:
data.append(entry.data[key]["item_count"]) data.append(0)
else: color = "#" + value.encode("utf-8").hex()[1:7]
data.append(entry.data[key]) if max(data) > 10:
else: datasets.append({
data.append(0) "label": value,
color = "#" + value.encode("utf-8").hex()[1:7] "data": data,
if max(data) > 10: "backgroundColor": color,
datasets.append({ "borderColor": color
"label": value, })
"data": data,
"backgroundColor": color,
"borderColor": color
})
return render_template( return render_template(
'reports/graph.html.j2', 'reports/graph.html.j2',
@ -107,8 +102,6 @@ def items_graph(start, end):
@gm_level(3) @gm_level(3)
def currency_by_date(date): def currency_by_date(date):
data = Reports.query.filter(Reports.date == date).filter(Reports.report_type == "currency").first().data data = Reports.query.filter(Reports.date == date).filter(Reports.report_type == "currency").first().data
data = gzip.decompress(data)
data = json.loads(data.decode('utf-8'))
return render_template('reports/currency/by_date.html.j2', data=data, date=date) return render_template('reports/currency/by_date.html.j2', data=data, date=date)
@ -126,8 +119,6 @@ def currency_graph(start, end):
datasets = [] datasets = []
# get stuff ready # get stuff ready
for entry in entries: for entry in entries:
entry.data = gzip.decompress(entry.data)
entry.data = json.loads(entry.data.decode('utf-8'))
labels.append(entry.date.strftime("%m/%d/%Y")) labels.append(entry.date.strftime("%m/%d/%Y"))
for character in characters: for character in characters:
data = [] data = []
@ -162,8 +153,6 @@ def currency_graph(start, end):
@gm_level(3) @gm_level(3)
def uscore_by_date(date): def uscore_by_date(date):
data = Reports.query.filter(Reports.date == date).filter(Reports.report_type == "uscore").first().data data = Reports.query.filter(Reports.date == date).filter(Reports.report_type == "uscore").first().data
data = gzip.decompress(data)
data = json.loads(data.decode('utf-8'))
return render_template('reports/uscore/by_date.html.j2', data=data, date=date) return render_template('reports/uscore/by_date.html.j2', data=data, date=date)
@ -181,8 +170,6 @@ def uscore_graph(start, end):
datasets = [] datasets = []
# get stuff ready # get stuff ready
for entry in entries: for entry in entries:
entry.data = gzip.decompress(entry.data)
entry.data = json.loads(entry.data.decode('utf-8'))
labels.append(entry.date.strftime("%m/%d/%Y")) labels.append(entry.date.strftime("%m/%d/%Y"))
for character in characters: for character in characters:
data = [] data = []
@ -237,7 +224,6 @@ def gen_item_report():
report_data = {} report_data = {}
for char_xml in char_xmls: for char_xml in char_xmls:
name = CharacterInfo.query.filter(CharacterInfo.id == char_xml.id).first().name
try: try:
character_json = xmltodict.parse( character_json = xmltodict.parse(
char_xml.xml_data, char_xml.xml_data,
@ -247,31 +233,15 @@ def gen_item_report():
if "i" in inv.keys() and type(inv["i"]) == list and (int(inv["attr_t"]) == 0 or int(inv["attr_t"]) == 1): if "i" in inv.keys() and type(inv["i"]) == list and (int(inv["attr_t"]) == 0 or int(inv["attr_t"]) == 1):
for item in inv["i"]: for item in inv["i"]:
if item["attr_l"] in report_data: if item["attr_l"] in report_data:
if ("attr_c" in item): report_data[item["attr_l"]] = report_data[item["attr_l"]] + int(item["attr_c"])
report_data[item["attr_l"]]["item_count"] = report_data[item["attr_l"]]["item_count"] + int(item["attr_c"])
else:
report_data[item["attr_l"]]["item_count"] = report_data[item["attr_l"]]["item_count"] + 1
else: else:
if ("attr_c" in item): report_data[item["attr_l"]] = int(item["attr_c"])
report_data[item["attr_l"]] = {"item_count": int(item["attr_c"]), "chars": {}}
else:
report_data[item["attr_l"]] = {"item_count": 1, "chars": {}}
if name in report_data[item["attr_l"]]["chars"]:
if ("attr_c" in item):
report_data[item["attr_l"]]["chars"][name] = report_data[item["attr_l"]]["chars"][name] + int(item["attr_c"])
else:
report_data[item["attr_l"]]["chars"][name] = report_data[item["attr_l"]]["chars"][name] + 1
else:
if ("attr_c" in item):
report_data[item["attr_l"]]["chars"][name] = int(item["attr_c"])
else:
report_data[item["attr_l"]]["chars"][name] = 1
except Exception as e: except Exception as e:
current_app.logger.error(f"REPORT::ITEMS - ERROR PARSING CHARACTER {char_xml.id}") current_app.logger.error(f"REPORT::ITEMS - ERROR PARSING CHARACTER {char_xml.id}")
current_app.logger.error(f"REPORT::ITEMS - {e}") current_app.logger.error(f"REPORT::ITEMS - {e}")
new_report = Reports( new_report = Reports(
data=gzip.compress(json.dumps(report_data).encode('utf-8')), data=report_data,
report_type="items", report_type="items",
date=date date=date
) )
@ -319,7 +289,7 @@ def gen_currency_report():
current_app.logger.error(f"REPORT::CURRENCY - {e}") current_app.logger.error(f"REPORT::CURRENCY - {e}")
new_report = Reports( new_report = Reports(
data=gzip.compress(json.dumps(report_data).encode('utf-8')), data=report_data,
report_type="currency", report_type="currency",
date=date date=date
) )
@ -367,7 +337,7 @@ def gen_uscore_report():
current_app.logger.error(f"REPORT::U-SCORE - {e}") current_app.logger.error(f"REPORT::U-SCORE - {e}")
new_report = Reports( new_report = Reports(
data=gzip.compress(json.dumps(report_data).encode('utf-8')), data=report_data,
report_type="uscore", report_type="uscore",
date=date date=date
) )

130
app/schemas.py Normal file
View File

@ -0,0 +1,130 @@
from flask_marshmallow import Marshmallow
from app.models import (
PlayKey,
PetNames,
Mail,
UGC,
PropertyContent,
Property,
CharacterXML,
CharacterInfo,
Account,
AccountInvitation,
ActivityLog,
CommandLog
)
ma = Marshmallow()
class PlayKeySchema(ma.SQLAlchemyAutoSchema):
class Meta:
model = PlayKey
include_relationships = False
load_instance = True
include_fk = True
class PetNamesSchema(ma.SQLAlchemyAutoSchema):
class Meta:
model = PetNames
include_relationships = False
load_instance = True
include_fk = False
class MailSchema(ma.SQLAlchemyAutoSchema):
class Meta:
model = Mail
include_relationships = False
load_instance = True
include_fk = False
class UGCSchema(ma.SQLAlchemyAutoSchema):
class Meta:
model = UGC
include_relationships = False
load_instance = True
include_fk = False
class PropertyContentSchema(ma.SQLAlchemyAutoSchema):
class Meta:
model = PropertyContent
include_relationships = True
load_instance = True
include_fk = True
ugc = ma.Nested(UGCSchema)
class PropertySchema(ma.SQLAlchemyAutoSchema):
class Meta:
model = Property
include_relationships = False
load_instance = True
include_fk = False
properties_contents = ma.Nested(PropertyContentSchema, many=True)
class CharacterXMLSchema(ma.SQLAlchemyAutoSchema):
class Meta:
model = CharacterXML
include_relationships = False
load_instance = True
include_fk = False
class CharacterInfoSchema(ma.SQLAlchemyAutoSchema):
class Meta:
model = CharacterInfo
include_relationships = False
load_instance = True
include_fk = False
charxml = ma.Nested(CharacterXMLSchema)
properties_owner = ma.Nested(PropertySchema, many=True)
pets = ma.Nested(PetNamesSchema, many=True)
mail = ma.Nested(MailSchema, many=True)
class AccountSchema(ma.SQLAlchemyAutoSchema):
class Meta:
model = Account
include_relationships = False
load_instance = True
include_fk = False
play_key = ma.Nested(PlayKeySchema)
charinfo = ma.Nested(CharacterInfoSchema, many=True)
class AccountInvitationSchema(ma.SQLAlchemyAutoSchema): # noqa
class Meta:
model = AccountInvitation
include_relationships = True
load_instance = True
include_fk = True
invite_by_user = ma.Nested(AccountSchema)
class ActivityLogSchema(ma.SQLAlchemyAutoSchema): # noqa
class Meta:
model = ActivityLog
include_relationships = True
load_instance = True
include_fk = True
character = ma.Nested(CharacterInfoSchema())
class CommandLogSchema(ma.SQLAlchemyAutoSchema): # noqa
class Meta:
model = CommandLog
include_relationships = True
load_instance = True
include_fk = True
character = ma.Nested(CharacterInfoSchema())

View File

@ -7,14 +7,8 @@ APP_SYSTEM_ERROR_SUBJECT_LINE = APP_NAME + " system error"
APP_SECRET_KEY = "" APP_SECRET_KEY = ""
APP_DATABASE_URI = "mysql+pymysql://<username>:<password>@<host>:<port>/<database>" APP_DATABASE_URI = "mysql+pymysql://<username>:<password>@<host>:<port>/<database>"
CLIENT_LOCATION = 'app/luclient/' # Send Analytics for Developers to better fix issues
CD_SQLITE_LOCATION = 'app/luclient/res/' ALLOW_ANALYTICS = False
CACHE_LOCATION = 'app/cache/'
CONFIG_LINK = False
CONFIG_LINK_TITLE = ""
CONFIG_LINK_HREF = ""
CONFIG_LINK_TEXT = ""
# Flask settings # Flask settings
CSRF_ENABLED = True CSRF_ENABLED = True
@ -58,16 +52,3 @@ USER_PASSLIB_CRYPTCONTEXT_SCHEMES = ['bcrypt'] # bcrypt for password hashing
# Flask-User routing settings # Flask-User routing settings
USER_AFTER_LOGIN_ENDPOINT = "main.index" USER_AFTER_LOGIN_ENDPOINT = "main.index"
USER_AFTER_LOGOUT_ENDPOINT = "main.index" USER_AFTER_LOGOUT_ENDPOINT = "main.index"
# Option will be removed once this feature is full implemeted
ENABLE_CHAR_XML_UPLOAD = False
# Recaptcha settings
# See: https://flask-wtf.readthedocs.io/en/1.2.x/form/#recaptcha
RECAPTCHA_ENABLE = False
RECAPTCHA_PUBLIC_KEY = ''
RECAPTCHA_PRIVATE_KEY = ''
# Optional
# RECAPTCHA_API_SERVER = ''
# RECAPTCHA_PARAMETERS = ''
RECAPTCHA_DATA_ATTRS = {'theme': 'white', 'size': 'invisible'}

View File

@ -14,13 +14,17 @@
<tr> <tr>
<th>Actions</th> <th>Actions</th>
<th>Name</th> <th>Name</th>
<th>Email</th> {% if config.USER_ENABLE_EMAIL %}
<th>Email</th>
{% endif %}
<th>GM Level</th> <th>GM Level</th>
<th>Locked</th> <th>Locked</th>
<th>Banned</th> <th>Banned</th>
<th>Muted</th> <th>Muted</th>
<th>Registered</th> <th>Registered</th>
<th>Email Confirmed</th> {% if config.USER_ENABLE_EMAIL %}
<th>Email Confirmed</th>
{% endif %}
</tr> </tr>
</thead> </thead>
<tbody></tbody> <tbody></tbody>

View File

@ -0,0 +1,188 @@
{% extends "bootstrap/base.html" %}
{% block title %}Key Creation{% endblock %}
{% block navbar %}
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="{{ url_for('dashboard') }}">Dashboard</a>
</div>
<ul class="nav navbar-nav">
</ul>
<ul class="nav navbar-nav" style="float: right">
<li class="active"><a href="#">Welcome {{ current_user.username }}!</a></li>
<li><a href="{{ url_for('logout') }}">Logout</a></li>
</ul>
</div>
</nav>
{% endblock navbar %}}
{% block content %}
{# LOGO #}
<div class="container" style="margin-top: 50px">
{# Display logo #}
<div style="margin-bottom: 50px">
<img
src="{{ url_for('static', filename=resources.LOGO) }}"
class="center-block img-responsive mx-auto d-block"
alt="Logo"
width="100"
height="100"
>
</div>
</div>
{# Key creation #}
<div class="container">
<div class="text-center">
<h3>Key Creation</h3>
</div>
<div class="col-lg-3">
</div>
<div class="col-lg-6">
{# If the error value is set, display the error in red text #}
{% if error %}
<div class="alert alert-danger">
{{ error }}
</div>
{% endif %}
{# If the message value is set, display the message in green text #}
{% if message %}
<div class="alert alert-success">
{{ message }}
</div>
{% endif %}
{# Form which takes in Admin Username, Admin Password, and the amount of keys to create. #}
<form action="{{ url_for('dashboard') }}" method="post">
{# Key count input #}
<div class="form-group">
<label for="key_count">Generate keys</label>
<input type="number" class="form-control" name="key_count" placeholder="Enter number of keys...">
<small class="form-text text-muted">Number of keys to create.</small>
</div>
{# Submit button #}
<div class="form-group">
<button type="submit" class="btn btn-primary">Generate Keys</button>
</div>
</form>
{# If the keys value is set, create a list for each key in keys #}
{% if keys %}
<div class="alert alert-success">
<ul>
{% for key in keys %}
<li>{{ key }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
</div>
<div class="col-lg-3">
</div>
</div>
</div>
{# Activity graphs #}
<div class="container">
<div class="text-center">
<h3>Activity</h3>
</div>
<div class="col-lg-3">
</div>
<div class="col-lg-6">
<canvas id="sessions_graph" width="400" height="400"></canvas>
<canvas id="play_time_graph" width="400" height="400"></canvas>
<canvas id="zone_play_time_graph" width="400" height="400"></canvas>
</div>
<div class="col-lg-3">
</div>
</div>
{% endblock %}
{% block scripts %}
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.5.1/dist/chart.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
// Make a get request to the server to load the activity data
$.get("{{ url_for('load_activities') }}", function(data) {
});
// Make a get request to the server to get the activity data for "sessions"
$.get("{{ url_for('activity_data', name='sessions') }}", function(data) {
// Load data as a json object
data = JSON.parse(data);
var ctx = document.getElementById('sessions_graph').getContext('2d');
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: data.labels,
datasets: data.datasets
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});
});
// Make a get request to the server to get the activity data for "play_time"
$.get("{{ url_for('activity_data', name='play_time') }}", function(data) {
// Load data as a json object
data = JSON.parse(data);
var ctx = document.getElementById('play_time_graph').getContext('2d');
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: data.labels,
datasets: data.datasets
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});
});
// Make a get request to the server to get the activity data for "zone_play_time"
$.get("{{ url_for('activity_data', name='zone_play_time') }}", function(data) {
// Load data as a json object
data = JSON.parse(data);
var ctx = document.getElementById('zone_play_time_graph').getContext('2d');
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: data.labels,
datasets: data.datasets
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});
});
</script>
{% endblock scripts %}}

View File

@ -90,29 +90,30 @@
let target_nav = '#{{request.endpoint}}'.replace('\.', '-'); let target_nav = '#{{request.endpoint}}'.replace('\.', '-');
$(target_nav).addClass('active'); $(target_nav).addClass('active');
}); });
// make tooltips with data work
$(function () { $(function () {
$('[data-toggle="tooltip"]').tooltip() $('[data-toggle="tooltip"]').tooltip()
}) })
function setInnerHTML(elm, html) { {% if config.ALLOW_ANALYTICS %}
elm.innerHTML = html; // Matomo JS analytics
$("body").tooltip({ selector: '[data-toggle=tooltip]' }); var _paq = window._paq = window._paq || [];
Array.from(elm.querySelectorAll("script")) /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
.forEach( oldScriptEl => { _paq.push(["setDocumentTitle", document.domain + "/" + document.title]);
const newScriptEl = document.createElement("script"); _paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
Array.from(oldScriptEl.attributes).forEach( attr => { (function() {
newScriptEl.setAttribute(attr.name, attr.value) var u="https://matomo.aronwk.com/";
}); _paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '3']);
const scriptText = document.createTextNode(oldScriptEl.innerHTML); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
newScriptEl.appendChild(scriptText); g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
oldScriptEl.parentNode.replaceChild(newScriptEl, oldScriptEl); {% endif %}
});
}
</script> </script>
{% if config.ALLOW_ANALYTICS %}
<!-- Matomo no js analytics -->
<noscript><p><img src="https://matomo.aronwk.com/matomo.php?idsite=3&amp;rec=1" style="border:0;" alt="" /></p></noscript>
{% endif %}
{% endblock %} {% endblock %}
</body> </body>

View File

@ -1,34 +0,0 @@
{% extends 'base.html.j2' %}
{% block title %}
Character XML Upload
{% endblock title %}
{% block content_before %}
Character XML Upload
{% endblock content_before %}
{% block content %}
<style>
.blink {
animation: blinker .5s linear infinite;
color: red;
font-family: sans-serif;
}
@keyframes blinker {
50% {
opacity: 0;
}
}
</style>
<h3 class="text-center blink">PROCEED WITH CAUTION</h3>
<form method=post>
{{ form.csrf_token }}
<div class="card shadow-sm mx-auto pb-3 bg-dark border-primary" >
<div class="card-body">
{{ helper.render_field(form.char_xml) }}
{{ helper.render_submit_field(form.submit) }}
</div>
</div>
</form>
{% endblock %}

View File

@ -15,9 +15,8 @@
{% include 'partials/_character.html.j2' %} {% include 'partials/_character.html.j2' %}
{% endwith %} {% endwith %}
</div> </div>
<div class="col-sm" id="charxml"> <div class="col-sm">
Loading Character Data {% include 'partials/_charxml.html.j2'%}
{% include 'partials/_loading.html' %}
</div> </div>
</div> </div>
{% endblock content %} {% endblock content %}
@ -33,14 +32,3 @@
{% endfor %} {% endfor %}
</div> </div>
{% endblock content_after %} {% endblock content_after %}
{% block js %}
{{ super() }}
<script>
fetch({{ url_for("characters.chardata", id=character_data.id)|tojson }})
.then(response => response.text())
.then(text => {
setInnerHTML(document.getElementById("charxml"), text);
})
</script>
{% endblock js %}

View File

@ -60,12 +60,7 @@
{# Remember me #} {# Remember me #}
{% if user_manager.USER_ENABLE_REMEMBER_ME %} {% if user_manager.USER_ENABLE_REMEMBER_ME %}
{{ render_checkbox_field(login_form.remember_me, tabindex=130) }} {{ render_checkbox_field(login_form.remember_me, tabindex=130) }}
{% endif %}
{# recaptcha #}
{% if config.RECAPTCHA_ENABLE %}
{{ render_field(form.recaptcha, tabindex=250) }}
{% endif %} {% endif %}
{# Submit button #} {# Submit button #}

View File

@ -29,11 +29,6 @@
{{ render_checkbox_field(login_form.remember_me, tabindex=130) }} {{ render_checkbox_field(login_form.remember_me, tabindex=130) }}
{% endif %} {% endif %}
{# recaptcha #}
{% if config.RECAPTCHA_ENABLE %}
{{ form.recaptcha }}
{% endif %}
{# Submit button #} {# Submit button #}
{{ render_submit_field(login_form.submit, tabindex=180) }} {{ render_submit_field(login_form.submit, tabindex=180) }}
</form> </form>
@ -68,11 +63,6 @@
{{ render_field(register_form.retype_password, tabindex=240) }} {{ render_field(register_form.retype_password, tabindex=240) }}
{% endif %} {% endif %}
{# recaptcha #}
{% if config.RECAPTCHA_ENABLE %}
{{ register_form.recaptcha }}
{% endif %}
{{ render_submit_field(register_form.submit, tabindex=280) }} {{ render_submit_field(register_form.submit, tabindex=280) }}
</form> </form>

View File

@ -47,11 +47,6 @@
{{ render_field(form.retype_password, tabindex=240) }} {{ render_field(form.retype_password, tabindex=240) }}
{% endif %} {% endif %}
{# recaptcha #}
{% if config.RECAPTCHA_ENABLE %}
{{ render_field(form.recaptcha, tabindex=250) }}
{% endif %}
{{ render_submit_field(form.submit, tabindex=280) }} {{ render_submit_field(form.submit, tabindex=280) }}
</form> </form>

View File

@ -46,7 +46,7 @@
<a id='property-index' class='nav-link' href='{{ url_for('properties.index') }}'>Properties</a> <a id='property-index' class='nav-link' href='{{ url_for('properties.index') }}'>Properties</a>
{% endif %} {% endif %}
{% if current_user.is_authenticated and current_user.gm_level >= 5 and config.REQUIRE_PLAY_KEY %} {% if current_user.is_authenticated and current_user.gm_level == 9 and config.REQUIRE_PLAY_KEY %}
{# Play Keys #} {# Play Keys #}
<a id='play_keys-index' class='nav-link' href='{{ url_for('play_keys.index') }}'>Play Keys</a> <a id='play_keys-index' class='nav-link' href='{{ url_for('play_keys.index') }}'>Play Keys</a>
{% endif %} {% endif %}
@ -71,8 +71,8 @@
{% if current_user.is_authenticated and current_user.gm_level >= 8 %} {% if current_user.is_authenticated and current_user.gm_level >= 8 %}
<hr/> <hr/>
<h3 class="text-center">Logs</h3> <h3 class="text-center">Logs</h3>
<a class="dropdown-item text-center" href='{{ url_for('log.command') }}'>Command Log</a> <a class="dropdown-item text-center" href='{{ url_for('log.activity') }}'>Command Log</a>
<a class="dropdown-item text-center" href='{{ url_for('log.activity') }}'>Activity Log</a> <a class="dropdown-item text-center" href='{{ url_for('log.command') }}'>Activity Log</a>
<a class="dropdown-item text-center" href='{{ url_for('log.audit') }}'>Audit Log</a> <a class="dropdown-item text-center" href='{{ url_for('log.audit') }}'>Audit Log</a>
<a class="dropdown-item text-center" href='{{ url_for('log.system') }}'>System Log</a> <a class="dropdown-item text-center" href='{{ url_for('log.system') }}'>System Log</a>
{% endif %} {% endif %}

View File

@ -35,6 +35,29 @@
<script type="text/javascript" src="{{ url_for('static', filename='lddviewer/base64-binary.js') }}"></script> <script type="text/javascript" src="{{ url_for('static', filename='lddviewer/base64-binary.js') }}"></script>
{% if config.ALLOW_ANALYTICS %}
<script>
// Matomo JS analytics
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(["setDocumentTitle", document.domain + "/" + document.title]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://matomo.aronwk.com/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '3']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
{% endif %}
{% if config.ALLOW_ANALYTICS %}
<!-- Matomo no js analytics -->
<noscript><p><img src="https://matomo.aronwk.com/matomo.php?idsite=3&amp;rec=1" style="border:0;" alt="" /></p></noscript>
{% endif %}
<script type='module'> <script type='module'>
import {MTLLoader} from 'https://cdn.jsdelivr.net/npm/three@0.116.0/examples/jsm/loaders/MTLLoader.js' import {MTLLoader} from 'https://cdn.jsdelivr.net/npm/three@0.116.0/examples/jsm/loaders/MTLLoader.js'
import {OBJLoader} from 'https://cdn.jsdelivr.net/npm/three@0.116.0/examples/jsm/loaders/OBJLoader.js' import {OBJLoader} from 'https://cdn.jsdelivr.net/npm/three@0.116.0/examples/jsm/loaders/OBJLoader.js'

View File

@ -22,9 +22,7 @@
<tr> <tr>
<th>ID</th> <th>ID</th>
<th>Account:Character</th> <th>Account:Character</th>
<th>Activity</th> <th>Command</th>
<th>Time</th>
<th>Map</th>
</tr> </tr>
</thead> </thead>
<tbody></tbody> <tbody></tbody>
@ -40,7 +38,7 @@
"order": [[0, "desc"]], "order": [[0, "desc"]],
"processing": true, "processing": true,
"serverSide": true, "serverSide": true,
"ajax": "{{ url_for('log.get_activities') }}", "ajax": "{{ url_for('log.get_commands') }}",
}); });
}); });
</script> </script>

View File

@ -22,7 +22,9 @@
<tr> <tr>
<th>ID</th> <th>ID</th>
<th>Account:Character</th> <th>Account:Character</th>
<th>Command</th> <th>Activity</th>
<th>Time</th>
<th>Map</th>
</tr> </tr>
</thead> </thead>
<tbody></tbody> <tbody></tbody>
@ -38,7 +40,7 @@
"order": [[0, "desc"]], "order": [[0, "desc"]],
"processing": true, "processing": true,
"serverSide": true, "serverSide": true,
"ajax": "{{ url_for('log.get_commands') }}", "ajax": "{{ url_for('log.get_activities') }}",
}); });
}); });
</script> </script>

View File

@ -4,47 +4,9 @@
{% block content_before %} {% block content_before %}
Online Players: {{ online }} Online Players: {{ online }}
{% endblock %} {% endblock %}
{% block content %} {% block content %}
{# show general zone info to everyone #}
{% if zones %}
<div class='card mx-auto mt-5 shadow-sm bg-dark border-primary'>
<div class="card-body">
{% for zone, players in zones.items() %}
<div class="row">
<div class="col text-right">
{{ zone|get_zone_name }}
</div>
<div class="col">
{{ players }}
</div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
{# only show this info to high level admina #}
{% if current_user.gm_level >= 8 and users|length > 0 %}
<div class='card mx-auto mt-5 shadow-sm bg-dark border-primary'>
<div class="card-body">
{% for user in users %}
<div class="row">
<div class="col text-right">
{{ user[0] }}
</div>
<div class="col">
{{ user[1]|get_zone_name }}
</div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
<div class='card mx-auto mt-5 shadow-sm bg-dark border-primary'> <div class='card mx-auto mt-5 shadow-sm bg-dark border-primary'>
<div class="card-body"> <div class="card-body">
<h4 class="text-center">Staff</h4> <h4 class="text-center">Staff</h4>
@ -62,26 +24,7 @@
</div> </div>
{% endfor %} {% endfor %}
</div> <hr>
</div>
<div class='card mx-auto mt-5 shadow-sm bg-dark border-primary'>
<div class="card-body">
<h4 class="text-center">Links</h4>
{% if config.CONFIG_LINK %}
<div class="row">
<div class="col text-right">
{{ config.CONFIG_LINK_TITLE }}
</div>
<div class="col">
<a href="{{ url_for('static', filename=config.CONFIG_LINK_HREF) }}">
{{ config.CONFIG_LINK_TEXT }}
</a>
</div>
</div>
{% endif %}
<div class="row"> <div class="row">
<div class="col text-right"> <div class="col text-right">
Source Source

View File

@ -108,12 +108,6 @@
</div> </div>
{% endif %} {% endif %}
</div> </div>
{% elif current_user.gm_level == 9 %}
<div class="col">
<a role="button" class="btn btn-danger btn btn-block" href='{{ url_for('accounts.pass_reset', id= account_data.id) }}'>
Reset User's Password
</a>
</div>
{% endif %} {% endif %}
{% if account_data.play_key and current_user.gm_level > 3 and config.REQUIRE_PLAY_KEY %} {% if account_data.play_key and current_user.gm_level > 3 and config.REQUIRE_PLAY_KEY %}

View File

@ -41,35 +41,29 @@
</div> </div>
</div> </div>
{% if request.endpoint != "characters.view" %} {% if request.endpoint != "characters.view" %}
<br/> <br/>
<div class="row"> <div class="row">
<div class="col text-center"> <div class="col text-center">
<a role="button" class="btn btn-primary btn-block" <a role="button" class="btn btn-primary btn-block"
href='{{ url_for('characters.view', id=character.id) }}'> href='{{ url_for('characters.view', id=character.id) }}'>
View Character View Character
</a> </a>
</div>
</div> </div>
</div>
{% else %} {% else %}
<br/> <br/>
<a role="button" class="btn btn-primary btn-block" <a role="button" class="btn btn-primary btn-block"
href='{{ url_for('characters.view_xml', id=character.id) }}'> href='{{ url_for('characters.view_xml', id=character.id) }}'>
View XML View XML
</a> </a>
<a role="button" class="btn btn-primary btn-block" <a role="button" class="btn btn-primary btn-block"
href='{{ url_for('characters.get_xml', id=character.id) }}'> href='{{ url_for('characters.get_xml', id=character.id) }}'>
Download XML Download XML
</a> </a>
{% if config.ENABLE_CHAR_XML_UPLOAD and current_user.gm_level >= 8 %} <a role="button" class="btn btn-primary btn-block"
<a role="button" class="btn btn-primary btn-block" href='{{ url_for('accounts.view', id=character.account_id) }}'>
href='{{ url_for('characters.upload', id=character.id) }}'> View Account: {{character.account.username}}
Upload XML </a>
</a>
{% endif %}
<a role="button" class="btn btn-primary btn-block"
href='{{ url_for('accounts.view', id=character.account_id) }}'>
View Account: {{character.account.username}}
</a>
{% endif %} {% endif %}
{% if current_user.gm_level > 2 %} {% if current_user.gm_level > 2 %}

View File

@ -11,11 +11,9 @@
<div class="col text-right"> <div class="col text-right">
U-Score: {{ character_json.obj.char.attr_ls }} U-Score: {{ character_json.obj.char.attr_ls }}
</div> </div>
{% if "lvl" in character_json.obj %} <div class="col">
<div class="col"> Level: {{ character_json.obj.lvl.attr_l }}
Level: {{ character_json.obj.lvl.attr_l }} </div>
</div>
{% endif %}
</div> </div>
<br/> <br/>
<div class="row"> <div class="row">
@ -65,13 +63,9 @@
Play time: Play time:
</div> </div>
<div class="col"> <div class="col">
{% if character_json.obj.char.attr_time %}
{{ (character_json.obj.char.attr_time|int/60/60/24)|int }} Days {{ (character_json.obj.char.attr_time|int/60/60/24)|int }} Days
{{ (character_json.obj.char.attr_time|int/60/60)|int - ((character_json.obj.char.attr_time|int/60/60/24)|int) * 24}} Hours {{ (character_json.obj.char.attr_time|int/60/60)|int - ((character_json.obj.char.attr_time|int/60/60/24)|int) * 24}} Hours
{{ (character_json.obj.char.attr_time|int/60 - (character_json.obj.char.attr_time|int/60/60)|int*60)|int }} Minutes {{ (character_json.obj.char.attr_time|int/60 - (character_json.obj.char.attr_time|int/60/60)|int*60)|int }} Minutes
{% else %}
None
{% endif %}
</div> </div>
</div> </div>
<hr class="bg-primary"/> <hr class="bg-primary"/>
@ -114,33 +108,63 @@
<div class="tab-content mt-3" id="nav-invContent"> <div class="tab-content mt-3" id="nav-invContent">
<div class="tab-pane fade show active" id="nav-items" role="tabpanel" aria-labelledby="nav-items-tab"> <div class="tab-pane fade show active" id="nav-items" role="tabpanel" aria-labelledby="nav-items-tab">
{# Inv ID 0 - Index: 0 #} {# Inv ID 0 - Index: 0 #}
Loading Inventory {% for item in character_json.obj.inv.holdings.in %}
{% include 'partials/_loading.html' %} {% if item.attr_t == "0" %}
{% for inv_item in item.i %}
{% include 'partials/charxml/_inv_grid.html.j2' %}
{% endfor %}
{% endif %}
{% endfor %}
</div> </div>
<div class="tab-pane fade" id="nav-vault" role="tabpanel" aria-labelledby="nav-vault-tab"> <div class="tab-pane fade" id="nav-vault" role="tabpanel" aria-labelledby="nav-vault-tab">
{# Inv ID 1 - Index: 1 #} {# Inv ID 1 - Index: 1 #}
Loading Inventory {% for item in character_json.obj.inv.holdings.in %}
{% include 'partials/_loading.html' %} {% if item.attr_t == "1" %}
{% for inv_item in item.i %}
{% include 'partials/charxml/_inv_grid.html.j2' %}
{% endfor %}
{% endif %}
{% endfor %}
</div> </div>
<div class="tab-pane fade" id="nav-vault-models" role="tabpanel" aria-labelledby="nav-vault-models-tab"> <div class="tab-pane fade" id="nav-vault-models" role="tabpanel" aria-labelledby="nav-vault-models-tab">
{# Inv ID 14 - Index: 10 #} {# Inv ID 14 - Index: 10 #}
Loading Inventory {% for item in character_json.obj.inv.holdings.in %}
{% include 'partials/_loading.html' %} {% if item.attr_t == "14" %}
{% for inv_item in item.i %}
{% include 'partials/charxml/_inv_grid.html.j2' %}
{% endfor %}
{% endif %}
{% endfor %}
</div> </div>
<div class="tab-pane fade" id="nav-bricks" role="tabpanel" aria-labelledby="nav-bricks-tab"> <div class="tab-pane fade" id="nav-bricks" role="tabpanel" aria-labelledby="nav-bricks-tab">
{# Inv ID 2 - Index: 2 #} {# Inv ID 2 - Index: 2 #}
Loading Inventory {% for item in character_json.obj.inv.holdings.in %}
{% include 'partials/_loading.html' %} {% if item.attr_t == "2" %}
{% for inv_item in item.i %}
{% include 'partials/charxml/_inv_grid.html.j2' %}
{% endfor %}
{% endif %}
{% endfor %}
</div> </div>
<div class="tab-pane fade" id="nav-models" role="tabpanel" aria-labelledby="nav-models-tab"> <div class="tab-pane fade" id="nav-models" role="tabpanel" aria-labelledby="nav-models-tab">
{# Inv ID 5 - Index: 6 #} {# Inv ID 5 - Index: 6 #}
Loading Inventory {% for item in character_json.obj.inv.holdings.in %}
{% include 'partials/_loading.html' %} {% if item.attr_t == "5" %}
{% for inv_item in item.i %}
{% include 'partials/charxml/_inv_grid.html.j2' %}
{% endfor %}
{% endif %}
{% endfor %}
</div> </div>
<div class="tab-pane fade" id="nav-behaviors" role="tabpanel" aria-labelledby="nav-behaviors-tab"> <div class="tab-pane fade" id="nav-behaviors" role="tabpanel" aria-labelledby="nav-behaviors-tab">
{# Inv ID 7 - Index: 8 #} {# Inv ID 7 - Index: 8 #}
Loading Inventory {% for item in character_json.obj.inv.holdings.in %}
{% include 'partials/_loading.html' %} {% if item.attr_t == "7" %}
{% for inv_item in item.i %}
{% include 'partials/charxml/_inv_grid.html.j2' %}
{% endfor %}
{% endif %}
{% endfor %}
</div> </div>
</div> </div>
</div> </div>
@ -163,14 +187,10 @@
</button> </button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
{% if character_json.obj.char.zs %} {% for zone in character_json.obj.char.zs.s %}
{% for zone in character_json.obj.char.zs.s %} {% include 'partials/charxml/_zone_stats.html.j2' %}
{% include 'partials/charxml/_zone_stats.html.j2' %} {{ '<hr class="bg-primary"/>' if not loop.last else "" }}
{{ '<hr class="bg-primary"/>' if not loop.last else "" }} {% endfor %}
{% endfor %}
{% else %}
No Stats Yet
{% endif %}
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
@ -199,40 +219,3 @@
</div> </div>
</div> </div>
</div> </div>
<script>
fetch({{ url_for("characters.inventory", id=character_data.id, inventory_id=0)|tojson }})
.then(response => response.text())
.then(text => {
setInnerHTML(document.getElementById("nav-items"), text);
})
fetch({{ url_for("characters.inventory", id=character_data.id, inventory_id=1)|tojson }})
.then(response => response.text())
.then(text => {
setInnerHTML(document.getElementById("nav-vault"), text);
})
fetch({{ url_for("characters.inventory", id=character_data.id, inventory_id=14)|tojson }})
.then(response => response.text())
.then(text => {
setInnerHTML(document.getElementById("nav-vault-models"), text);
})
fetch({{ url_for("characters.inventory", id=character_data.id, inventory_id=2)|tojson }})
.then(response => response.text())
.then(text => {
setInnerHTML(document.getElementById("nav-bricks"), text);
})
fetch({{ url_for("characters.inventory", id=character_data.id, inventory_id=5)|tojson }})
.then(response => response.text())
.then(text => {
setInnerHTML(document.getElementById("nav-models"), text);
})
fetch({{ url_for("characters.inventory", id=character_data.id, inventory_id=7)|tojson }})
.then(response => response.text())
.then(text => {
setInnerHTML(document.getElementById("nav-behaviors"), text);
})
</script>

View File

@ -14,7 +14,7 @@
{% if gm_level==0 %} {% if gm_level==0 %}
Player Player
{% elif gm_level==1 %} {% elif gm_level==1 %}
Elevevated Civilan {# Unused #} Key Distributor
{% elif gm_level==2 %} {% elif gm_level==2 %}
Junior Moderator Junior Moderator
{% elif gm_level==3 %} {% elif gm_level==3 %}

View File

@ -1,21 +0,0 @@
<div class="spinner-grow text-light" role="status" style="animation-duration: 6s;">
<span class="sr-only">Loading 0</span>
</div>
<div class="spinner-grow text-light" role="status" style="animation-duration: 6s; animation-delay: 1s;">
<span class="sr-only">Loading 1</span>
</div>
<div class="spinner-grow text-light" role="status" style="animation-duration: 6s; animation-delay: 2s;">
<span class="sr-only">Loading 2</span>
</div>
<div class="spinner-grow text-light" role="status" style="animation-duration: 6s; animation-delay: 3s;">
<span class="sr-only">Loading 3</span>
</div>
<div class="spinner-grow text-light" role="status" style="animation-duration: 6s; animation-delay: 4s;">
<span class="sr-only">Loading 4</span>
</div>
<div class="spinner-grow text-light" role="status" style="animation-duration: 6s; animation-delay: 5s;">
<span class="sr-only">Loading 5</span>
</div>
<div class="spinner-grow text-light" role="status" style="animation-duration: 6s; animation-delay: 6s;">
<span class="sr-only">Loading 6</span>
</div>

View File

@ -77,14 +77,6 @@
{{ property.performance_cost }} {{ property.performance_cost }}
</div> </div>
</div> </div>
<div class="row">
<div class="col text-right">
Clone ID:
</div>
<div class="col">
{{ property.clone_id }}
</div>
</div>
{% if request.endpoint != "properties.view" %} {% if request.endpoint != "properties.view" %}
<br/> <br/>
<div class="row"> <div class="row">

View File

@ -4,29 +4,21 @@
alt="{{ inv_item.attr_l|get_lot_name }}" alt="{{ inv_item.attr_l|get_lot_name }}"
class="border p-1 border-primary rounded m-1" class="border p-1 border-primary rounded m-1"
width="60" width="60"
{% if 'attr_eq' in inv_item %} {% if inv_item.attr_eq == "true" %}style="background-color:#d16f05;"{% endif %}
{% if inv_item.attr_eq == "true" %}style="background-color:#d16f05;"{% endif %}
{% endif %}
height="60" height="60"
data-html="true" data-html="true"
data-toggle="tooltip" data-toggle="tooltip"
data-placement="left" data-placement="left"
title="{% include 'partials/charxml/_item_tooltip.html.j2' %}" title="{% include 'partials/charxml/_item_tooltip.html.j2' %}"
> >
{% if 'attr_c' in inv_item %} {% if inv_item.attr_c != "1" %}
<span class="inventory-count text-bold"> <span class="inventory-count text-bold">
{%if inv_item.attr_c|int > 999 %} {{ inv_item.attr_c }}
+999
{% elif inv_item.attr_c|int > 1 %}
{{ inv_item.attr_c }}
{% endif %}
</span> </span>
{% endif %} {% endif %}
{% if 'attr_b' in inv_item %} {% if inv_item.attr_b == "true" %}
{% if inv_item.attr_b == "true" %} <span class="inventory-lock">
<span class="inventory-lock"> <i class='fas fa-lock'></i>
<i class='fas fa-lock'></i> </span>
</span>
{% endif %}
{% endif %} {% endif %}
</div> </div>

View File

@ -1,9 +0,0 @@
{% if inventory.i is iterable and (inventory.i is not string and inventory.i is not mapping) %}
{% for inv_item in inventory.i %}
{% include 'partials/charxml/_inv_grid.html.j2' %}
{% endfor %}
{% else %}
{% with inv_item=inventory.i %}
{% include 'partials/charxml/_inv_grid.html.j2' %}
{% endwith %}
{% endif %}

View File

@ -66,8 +66,3 @@
{% endwith %} {% endwith %}
{% endif %} {% endif %}
{% if 'attr_c' in inv_item %}
{%if inv_item.attr_c|int > 999 %}
<br />Count: {{ inv_item.attr_c|numberFormat }}
{% endif %}
{% endif %}

View File

@ -20,34 +20,18 @@
<th scope="col"> <th scope="col">
Count Count
</th> </th>
<th scope="col">
Breakdown
</th>
<th scope="col"> <th scope="col">
Rarity Rarity
</th> </th>
</thead> </thead>
<tbody> <tbody>
{% for lot, details in data.items() %} {% for lot, count in data.items() %}
<tr> <tr>
<td> <td>
{{ lot|get_lot_name }} {{ lot|get_lot_name }}
</td> </td>
<td> <td>
{% if details.chars %} {{ count }}
{{ details.item_count }}
{% else %}
{{ details }}
{% endif %}
</td>
<td>
{% if details.chars %}
{% for char, value in details.chars|dictsort(false, 'value')|reverse %}
{{char}}: {{value}}<br/>
{% endfor %}
{% else %}
Missing
{% endif %}
</td> </td>
<td> <td>
{{ lot|get_lot_rarity }} {{ lot|get_lot_rarity }}

View File

@ -1,2 +0,0 @@
python3 -m flask db upgrade
python3 wsgi.py

View File

@ -1,5 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# unzip brickdb from client to the right places
unzip -n -q /app/luclient/res/brickdb.zip -d app/luclient/res/
# TODO: preconvert images options # TODO: preconvert images options
# TODO: preconvery models options # TODO: preconvery models options

View File

View File

@ -22,8 +22,8 @@ logger = logging.getLogger('alembic.env')
# target_metadata = mymodel.Base.metadata # target_metadata = mymodel.Base.metadata
config.set_main_option( config.set_main_option(
'sqlalchemy.url', 'sqlalchemy.url',
current_app.config.get('SQLALCHEMY_DATABASE_URI') str(current_app.extensions['migrate'].db.get_engine().url).replace(
) '%', '%%'))
target_metadata = current_app.extensions['migrate'].db.metadata target_metadata = current_app.extensions['migrate'].db.metadata
# other values from the config, defined by the needs of env.py, # other values from the config, defined by the needs of env.py,

View File

@ -1,164 +0,0 @@
"""compressss reports
Revision ID: 1164e037907f
Revises: a6e42ef03da7
Create Date: 2023-11-18 01:38:00.127472
"""
from alembic import op
from sqlalchemy.orm.session import Session
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
from sqlalchemy.types import JSON
from sqlalchemy.ext.declarative import declarative_base
import gzip
import json
Base = declarative_base()
# revision identifiers, used by Alembic.
revision = '1164e037907f'
down_revision = 'a6e42ef03da7'
branch_labels = None
depends_on = None
class ReportsUpgradeNew(Base):
__tablename__ = 'reports'
__table_args__ = {'extend_existing': True}
data = sa.Column(
mysql.MEDIUMBLOB(),
nullable=False
)
report_type = sa.Column(
sa.VARCHAR(35),
nullable=False,
primary_key=True,
autoincrement=False
)
date = sa.Column(
sa.Date(),
primary_key=True,
autoincrement=False
)
def save(self):
sa.session.add(self)
sa.session.commit()
sa.session.refresh(self)
class ReportsUpgradeOld(Base):
__tablename__ = 'reports_old'
__table_args__ = {'extend_existing': True}
data = sa.Column(
JSON(),
nullable=False
)
report_type = sa.Column(
sa.VARCHAR(35),
nullable=False,
primary_key=True,
autoincrement=False
)
date = sa.Column(
sa.Date(),
primary_key=True,
autoincrement=False
)
class ReportsDowngradeOld(Base):
__tablename__ = 'reports'
__table_args__ = {'extend_existing': True}
data = sa.Column(
mysql.MEDIUMBLOB(),
nullable=False
)
report_type = sa.Column(
sa.VARCHAR(35),
nullable=False,
primary_key=True,
autoincrement=False
)
date = sa.Column(
sa.Date(),
primary_key=True,
autoincrement=False
)
def save(self):
sa.session.add(self)
sa.session.commit()
sa.session.refresh(self)
class ReportsDowngradeNew(Base):
__tablename__ = 'reports_old'
__table_args__ = {'extend_existing': True}
data = sa.Column(
JSON(),
nullable=False
)
report_type = sa.Column(
sa.VARCHAR(35),
nullable=False,
primary_key=True,
autoincrement=False
)
date = sa.Column(
sa.Date(),
primary_key=True,
autoincrement=False
)
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.rename_table('reports', 'reports_old')
bind = op.get_bind()
session = Session(bind=bind)
reports = session.query(ReportsUpgradeOld)
op.create_table('reports',
sa.Column('data', mysql.MEDIUMBLOB(), nullable=False),
sa.Column('report_type', sa.VARCHAR(length=35), autoincrement=False, nullable=False),
sa.Column('date', sa.Date(), autoincrement=False, nullable=False),
sa.PrimaryKeyConstraint('report_type', 'date')
)
# insert records
new_reports = []
# insert records
for report in reports:
new_reports.append({
"data":gzip.compress(json.dumps(report.data).encode('utf-8')),
"report_type":report.report_type,
"date":report.date
})
op.bulk_insert(ReportsUpgradeNew.__table__, new_reports)
op.drop_table('reports_old')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('reports')
op.create_table('reports',
sa.Column('data', JSON(), nullable=False),
sa.Column('report_type', sa.VARCHAR(length=35), autoincrement=False, nullable=False),
sa.Column('date', sa.Date(), autoincrement=False, nullable=False),
sa.PrimaryKeyConstraint('report_type', 'date')
)
# ### end Alembic commands ###

View File

@ -77,11 +77,11 @@ def upgrade():
sa.Column('created_at', mysql.TIMESTAMP(), server_default=sa.text('now()'), nullable=False), sa.Column('created_at', mysql.TIMESTAMP(), server_default=sa.text('now()'), nullable=False),
sa.Column('play_key_id', mysql.INTEGER(), nullable=True), sa.Column('play_key_id', mysql.INTEGER(), nullable=True),
sa.Column('mute_expire', mysql.BIGINT(unsigned=True), server_default='0', nullable=False), sa.Column('mute_expire', mysql.BIGINT(unsigned=True), server_default='0', nullable=False),
sa.ForeignKeyConstraint(['play_key_id'], ['play_keys.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id'), sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name') sa.UniqueConstraint('name')
) )
op.create_foreign_key(None, 'accounts', 'play_keys', ['play_key_id'], ['id'], ondelete='CASCADE')
op.add_column('accounts', sa.Column('active', sa.BOOLEAN(), server_default='1', nullable=False)) op.add_column('accounts', sa.Column('active', sa.BOOLEAN(), server_default='1', nullable=False))
op.add_column('accounts', sa.Column('email_confirmed_at', sa.DateTime(), nullable=True)) op.add_column('accounts', sa.Column('email_confirmed_at', sa.DateTime(), nullable=True))
op.add_column('accounts', sa.Column('email', sa.Unicode(length=255), server_default='', nullable=True)) op.add_column('accounts', sa.Column('email', sa.Unicode(length=255), server_default='', nullable=True))
@ -103,13 +103,14 @@ def upgrade():
sa.Column('other_player_id', mysql.TEXT(), nullable=False), sa.Column('other_player_id', mysql.TEXT(), nullable=False),
sa.Column('selection', mysql.TEXT(), nullable=False), sa.Column('selection', mysql.TEXT(), nullable=False),
sa.Column('submitted', mysql.TIMESTAMP(), server_default=sa.text('now()'), nullable=False), sa.Column('submitted', mysql.TIMESTAMP(), server_default=sa.text('now()'), nullable=False),
sa.ForeignKeyConstraint(['resoleved_by_id'], ['accounts.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id') sa.PrimaryKeyConstraint('id')
) )
op.add_column('bug_reports', sa.Column('resolved_time', mysql.TIMESTAMP(), nullable=True)) op.add_column('bug_reports', sa.Column('resolved_time', mysql.TIMESTAMP(), nullable=True))
op.add_column('bug_reports', sa.Column('resoleved_by_id', sa.Integer(), nullable=True)) op.add_column('bug_reports', sa.Column('resoleved_by_id', sa.Integer(), nullable=True))
op.add_column('bug_reports', sa.Column('resolution', mysql.TEXT(), nullable=True)) op.add_column('bug_reports', sa.Column('resolution', mysql.TEXT(), nullable=True))
op.create_foreign_key(None, 'bug_reports', 'accounts', ['resoleved_by_id'], ['id'], ondelete='CASCADE') op.create_foreign_key(None, 'bug_reports', 'accounts', ['resoleved_by_id'], ['id'])
if 'charinfo' not in tables: if 'charinfo' not in tables:
op.create_table('charinfo', op.create_table('charinfo',

View File

@ -1,33 +0,0 @@
"""force play_key_id to be nullable
Revision ID: a6e42ef03da7
Revises: 8e52b5c7568a
Create Date: 2022-11-29 19:14:22.645911
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
# revision identifiers, used by Alembic.
revision = 'a6e42ef03da7'
down_revision = '8e52b5c7568a'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('accounts', 'play_key_id',
existing_type=mysql.INTEGER(display_width=11),
nullable=True)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('accounts', 'play_key_id',
existing_type=mysql.INTEGER(display_width=11),
nullable=False)
# ### end Alembic commands ###

View File

@ -1,20 +1,61 @@
alembic==1.7.5 alembic==1.7.5
APScheduler==3.8.1
astroid==2.9.1
autopep8==1.6.0 autopep8==1.6.0
bcrypt==3.2.0
blinker==1.4
cffi==1.14.6
click==8.0.1
colorama==0.4.4
cryptography==36.0.0
dnspython==2.1.0
dominate==2.6.0
email-validator==1.1.3 email-validator==1.1.3
Flask==3.0.0 Flask==2.0.1
Flask-APScheduler==1.12.3 Flask-APScheduler==1.12.3
Flask-Assets==2.1.0 Flask-Assets==2.0
Flask-Login==0.5.0
Flask-Mail==0.9.1
flask-marshmallow==0.14.0
Flask-Migrate==3.1.0 Flask-Migrate==3.1.0
Flask-SQLAlchemy==3.1.1 Flask-SQLAlchemy==2.5.1
Flask-User==1.0.2.2 Flask-User==1.0.2.2
Flask-WTF==1.2.1 Flask-WTF==1.0.0
gunicorn==21.2.0 greenlet==1.1.0
idna==3.3
isort==5.10.1
itsdangerous==2.0.1
Jinja2==3.0.1
lazy-object-proxy==1.7.1
libsass==0.21.0 libsass==0.21.0
Mako==1.1.6
MarkupSafe==2.0.1
marshmallow==3.14.1
marshmallow-sqlalchemy==0.26.1
mccabe==0.6.1
passlib==1.7.4
platformdirs==2.4.1
pycodestyle==2.8.0
pycparser==2.20
pydocstyle==6.1.1
pyflakes==2.4.0
pylama==8.3.3
pylint==2.12.2
PyMySQL==1.0.2 PyMySQL==1.0.2
SQLAlchemy==2.0.23 python-dateutil==2.8.2
pytz==2021.3
pytz-deprecation-shim==0.1.0.post0
six==1.16.0
snowballstemmer==2.2.0
SQLAlchemy==1.4.22
sqlalchemy-datatables==2.0.1 sqlalchemy-datatables==2.0.1
toml==0.10.2
tzdata==2021.5
tzlocal==4.1
visitor==0.1.3
Wand==0.6.7 Wand==0.6.7
webassets==2.0 webassets==2.0
Werkzeug==3.0.1 Werkzeug==2.0.1
wrapt==1.13.3
WTForms==3.0.0 WTForms==3.0.0
xmltodict==0.12.0 xmltodict==0.12.0

View File

@ -18,7 +18,7 @@ else:
from logging.handlers import RotatingFileHandler from logging.handlers import RotatingFileHandler
gunicorn_logger = logging.getLogger('gunicorn.error') gunicorn_logger = logging.getLogger('gunicorn.error')
app.logger.handlers = gunicorn_logger.handlers app.logger.handlers = gunicorn_logger.handlers
file_handler = RotatingFileHandler('logs/nexus_dashboard.log', maxBytes=1024 * 1024 * 100, backupCount=20) file_handler = RotatingFileHandler('nexus_dashboard.log', maxBytes=1024 * 1024 * 100, backupCount=20)
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
file_handler.setFormatter(formatter) file_handler.setFormatter(formatter)
app.logger.addHandler(file_handler) app.logger.addHandler(file_handler)