mirror of
https://github.com/DarkflameUniverse/NexusDashboard.git
synced 2024-11-21 21:17:23 +00:00
Merge pull request #22 from DarkflameUniverse/character-rescue
Character rescue
This commit is contained in:
commit
6303a86778
@ -5,8 +5,12 @@ from datatables import ColumnDT, DataTables
|
||||
import datetime, time
|
||||
from app.models import CharacterInfo, CharacterXML, Account, db
|
||||
from app.schemas import CharacterInfoSchema
|
||||
from app.forms import RescueForm
|
||||
from app import gm_level, log_audit
|
||||
from app.luclient import translate_from_locale
|
||||
import xmltodict
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
|
||||
character_blueprint = Blueprint('characters', __name__)
|
||||
|
||||
@ -92,7 +96,6 @@ def view(id):
|
||||
|
||||
@character_blueprint.route('/view_xml/<id>', methods=['GET'])
|
||||
@login_required
|
||||
@gm_level(9)
|
||||
def view_xml(id):
|
||||
|
||||
character_data = CharacterInfo.query.filter(CharacterInfo.id == id).first()
|
||||
@ -101,6 +104,11 @@ def view_xml(id):
|
||||
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_xml = CharacterXML.query.filter(
|
||||
CharacterXML.id==id
|
||||
).first().xml_data
|
||||
@ -111,7 +119,6 @@ def view_xml(id):
|
||||
|
||||
@character_blueprint.route('/get_xml/<id>', methods=['GET'])
|
||||
@login_required
|
||||
@gm_level(9)
|
||||
def get_xml(id):
|
||||
|
||||
character_data = CharacterInfo.query.filter(CharacterInfo.id == id).first()
|
||||
@ -119,6 +126,10 @@ def get_xml(id):
|
||||
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_xml = CharacterXML.query.filter(
|
||||
CharacterXML.id==id
|
||||
@ -158,6 +169,42 @@ def restrict(id, bit):
|
||||
return redirect(request.referrer if request.referrer else url_for("main.index"))
|
||||
|
||||
|
||||
@character_blueprint.route('/rescue/<id>', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
@gm_level(3)
|
||||
def rescue(id):
|
||||
|
||||
form = RescueForm()
|
||||
|
||||
character_data = CharacterXML.query.filter(
|
||||
CharacterXML.id==id
|
||||
).first()
|
||||
|
||||
character_xml = ET.XML(character_data.xml_data)
|
||||
for zone in character_xml.findall('.//r'):
|
||||
if int(zone.attrib["w"]) % 100 == 0:
|
||||
form.save_world.choices.append(
|
||||
(
|
||||
zone.attrib["w"],
|
||||
translate_from_locale(f"ZoneTable_{zone.attrib['w']}_DisplayDescription")
|
||||
)
|
||||
)
|
||||
|
||||
if form.validate_on_submit():
|
||||
new_zone = character_xml.find(f'.//r[@w="{form.save_world.data}"]')
|
||||
char = character_xml.find(".//char")
|
||||
char.attrib["lzx"] = new_zone.attrib["x"]
|
||||
char.attrib["lzy"] = new_zone.attrib["y"]
|
||||
char.attrib["lzz"] = new_zone.attrib["z"]
|
||||
char.attrib["lwid"] = form.save_world.data
|
||||
|
||||
character_data.xml_data = ET.tostring(character_xml)
|
||||
character_data.save()
|
||||
|
||||
return redirect(url_for('characters.view', id=id))
|
||||
|
||||
return render_template("character/rescue.html.j2", form=form)
|
||||
|
||||
@character_blueprint.route('/get/<status>', methods=['GET'])
|
||||
@login_required
|
||||
@gm_level(3)
|
||||
|
14
app/forms.py
14
app/forms.py
@ -171,3 +171,17 @@ class SendMailForm(FlaskForm):
|
||||
)
|
||||
|
||||
submit = SubmitField('Submit')
|
||||
|
||||
|
||||
class RescueForm(FlaskForm):
|
||||
|
||||
save_world = SelectField(
|
||||
'Move to:',
|
||||
coerce=str,
|
||||
choices=[
|
||||
("",""),
|
||||
],
|
||||
validators=[validators.DataRequired()]
|
||||
)
|
||||
|
||||
submit = SubmitField('Submit')
|
||||
|
@ -25,7 +25,6 @@ def send():
|
||||
form = SendMailForm()
|
||||
|
||||
if request.method == "POST":
|
||||
# if form.validate_on_submit():
|
||||
if form.attachment.data != "0" and form.attachment_count.data == 0:
|
||||
form.attachment_count.data = 1
|
||||
if form.recipient.data == "0":
|
||||
|
@ -1,11 +1,11 @@
|
||||
{% extends 'base.html.j2' %}
|
||||
|
||||
{% block title %}
|
||||
Account Management
|
||||
Character Management
|
||||
{% endblock title %}
|
||||
|
||||
{% block content_before %}
|
||||
Account Management
|
||||
Character Management
|
||||
{% endblock content_before %}
|
||||
|
||||
{% block content %}
|
||||
|
21
app/templates/character/rescue.html.j2
Normal file
21
app/templates/character/rescue.html.j2
Normal file
@ -0,0 +1,21 @@
|
||||
{% extends 'base.html.j2' %}
|
||||
|
||||
{% block title %}
|
||||
Character Rescue
|
||||
{% endblock title %}
|
||||
|
||||
{% block content_before %}
|
||||
Character Rescue
|
||||
{% endblock content_before %}
|
||||
|
||||
{% block content %}
|
||||
<form method=post>
|
||||
{{ form.csrf_token }}
|
||||
<div class="card shadow-sm mx-auto pb-3 bg-dark border-primary" style="width: 20rem;">
|
||||
<div class="card-body">
|
||||
{{ helper.render_field(form.save_world) }}
|
||||
{{ helper.render_submit_field(form.submit) }}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
@ -52,6 +52,24 @@
|
||||
</div>
|
||||
{% else %}
|
||||
<br/>
|
||||
<div class="row">
|
||||
<div class="col text-center">
|
||||
<a role="button" class="btn btn-primary btn-block"
|
||||
href='{{ url_for('characters.view_xml', id=character.id) }}'>
|
||||
View XML
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="row">
|
||||
<div class="col text-center">
|
||||
<a role="button" class="btn btn-primary btn-block"
|
||||
href='{{ url_for('characters.get_xml', id=character.id) }}'>
|
||||
Download XML
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="row">
|
||||
<div class="col text-center">
|
||||
<a role="button" class="btn btn-primary btn-block"
|
||||
@ -62,7 +80,7 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if current_user.id != character.account_id and current_user.gm_level > 2 %}
|
||||
{% if current_user.gm_level > 2 %}
|
||||
<hr class="bg-primary"/>
|
||||
<div class="row">
|
||||
<div class="col text-center">
|
||||
@ -83,6 +101,10 @@
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
<a role="button" class="btn btn-warning btn-block"
|
||||
href='{{ url_for('characters.rescue', id=character.id) }}'>
|
||||
Rescue
|
||||
</a>
|
||||
<a role="button" class="btn btn-primary btn-block"
|
||||
href='{{ url_for('characters.restrict', id=character.id, bit=4) }}'>
|
||||
{% if character.permission_map|check_perm_map(4) %}Unrestrict{% else %}Restrict{% endif %} Trade
|
||||
|
@ -19,7 +19,7 @@
|
||||
<div class="row">
|
||||
<div class="col text-center">
|
||||
{% set parsed_lzid = character_json.obj.char.attr_lzid|parse_lzid %}
|
||||
Zone: {{ parsed_lzid[0]|get_zone_name }}<br>
|
||||
Zone: {{ character_json.obj.char.attr_lwid|get_zone_name }}<br>
|
||||
Zone Instance: {{ parsed_lzid[1] }}<br>
|
||||
Zone Clone: {{ parsed_lzid[2] }}<br>
|
||||
</div>
|
||||
|
@ -3,5 +3,11 @@
|
||||
# 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: preconvery models options
|
||||
|
||||
# update the DB
|
||||
flask db upgrade
|
||||
|
||||
# RUNNNNNNNNNNNNN
|
||||
gunicorn -b :8000 -w 4 wsgi:app
|
||||
|
Loading…
Reference in New Issue
Block a user