mirror of
https://github.com/DarkflameUniverse/NexusDashboard.git
synced 2024-11-25 15:07:18 +00:00
allow players to view their bug reports
This commit is contained in:
parent
e45fb3233a
commit
1113295c5b
@ -1,4 +1,4 @@
|
|||||||
from flask import render_template, Blueprint, redirect, url_for, request, flash
|
from flask import render_template, Blueprint, redirect, url_for, request, flash, redirect
|
||||||
from flask_user import login_required, current_user
|
from flask_user import login_required, current_user
|
||||||
from app.models import db, BugReport, CharacterInfo
|
from app.models import db, BugReport, CharacterInfo
|
||||||
from datatables import ColumnDT, DataTables
|
from datatables import ColumnDT, DataTables
|
||||||
@ -11,16 +11,21 @@ bug_report_blueprint = Blueprint('bug_reports', __name__)
|
|||||||
|
|
||||||
@bug_report_blueprint.route('/<status>', methods=['GET'])
|
@bug_report_blueprint.route('/<status>', methods=['GET'])
|
||||||
@login_required
|
@login_required
|
||||||
@gm_level(3)
|
|
||||||
def index(status):
|
def index(status):
|
||||||
return render_template('bug_reports/index.html.j2', status=status)
|
return render_template('bug_reports/index.html.j2', status=status)
|
||||||
|
|
||||||
|
|
||||||
@bug_report_blueprint.route('/view/<id>', methods=['GET'])
|
@bug_report_blueprint.route('/view/<id>', methods=['GET'])
|
||||||
@login_required
|
@login_required
|
||||||
@gm_level(3)
|
|
||||||
def view(id):
|
def view(id):
|
||||||
report = BugReport.query.filter(BugReport.id == id).first()
|
report = BugReport.query.filter(BugReport.id == id).first()
|
||||||
|
if current_user.gm_level < 3:
|
||||||
|
chars = CharacterInfo.query.with_entities(CharacterInfo.id).filter(CharacterInfo.account_id == current_user.id).all()
|
||||||
|
char_ids = []
|
||||||
|
for char in chars:
|
||||||
|
char_ids.append(char[0])
|
||||||
|
if report.reporter_id not in char_ids:
|
||||||
|
return redirect(url_for('bug_reports.index', status=all))
|
||||||
if report.resoleved_by:
|
if report.resoleved_by:
|
||||||
rb = report.resoleved_by.username
|
rb = report.resoleved_by.username
|
||||||
else:
|
else:
|
||||||
@ -64,14 +69,28 @@ def get(status):
|
|||||||
]
|
]
|
||||||
|
|
||||||
query = None
|
query = None
|
||||||
if status == "all":
|
if current_user.gm_level > 0:
|
||||||
query = db.session.query().select_from(BugReport)
|
if status == "all":
|
||||||
elif status == "resolved":
|
query = db.session.query().select_from(BugReport)
|
||||||
query = db.session.query().select_from(BugReport).filter(BugReport.resolved_time != None)
|
elif status == "resolved":
|
||||||
elif status == "unresolved":
|
query = db.session.query().select_from(BugReport).filter(BugReport.resolved_time != None)
|
||||||
query = db.session.query().select_from(BugReport).filter(BugReport.resolved_time == None)
|
elif status == "unresolved":
|
||||||
|
query = db.session.query().select_from(BugReport).filter(BugReport.resolved_time == None)
|
||||||
|
else:
|
||||||
|
raise Exception("Not a valid filter")
|
||||||
else:
|
else:
|
||||||
raise Exception("Not a valid filter")
|
chars = CharacterInfo.query.with_entities(CharacterInfo.id).filter(CharacterInfo.account_id == current_user.id).all()
|
||||||
|
char_ids = []
|
||||||
|
for char in chars:
|
||||||
|
char_ids.append(char[0])
|
||||||
|
if status == "all":
|
||||||
|
query = db.session.query().select_from(BugReport).filter(BugReport.reporter_id.in_(char_ids))
|
||||||
|
elif status == "resolved":
|
||||||
|
query = db.session.query().select_from(BugReport).filter(BugReport.reporter_id.in_(char_ids)).filter(BugReport.resolved_time != None)
|
||||||
|
elif status == "unresolved":
|
||||||
|
query = db.session.query().select_from(BugReport).filter(BugReport.reporter_id.in_(char_ids)).filter(BugReport.resolved_time == None)
|
||||||
|
else:
|
||||||
|
raise Exception("Not a valid filter")
|
||||||
|
|
||||||
params = request.args.to_dict()
|
params = request.args.to_dict()
|
||||||
|
|
||||||
@ -116,12 +135,15 @@ def get(status):
|
|||||||
else:
|
else:
|
||||||
character = CharacterInfo.query.filter(CharacterInfo.id == int(report["4"]) & 0xFFFFFFFF).first()
|
character = CharacterInfo.query.filter(CharacterInfo.id == int(report["4"]) & 0xFFFFFFFF).first()
|
||||||
if character:
|
if character:
|
||||||
report["4"] = f"""
|
if current_user.gm_level > 3:
|
||||||
<a role="button" class="btn btn-primary btn btn-block"
|
report["4"] = f"""
|
||||||
href='{url_for('characters.view', id=(int(report["4"]) & 0xFFFFFFFF))}'>
|
<a role="button" class="btn btn-primary btn btn-block"
|
||||||
{character.name}
|
href='{url_for('characters.view', id=(int(report["4"]) & 0xFFFFFFFF))}'>
|
||||||
</a>
|
{character.name}
|
||||||
"""
|
</a>
|
||||||
|
"""
|
||||||
|
else:
|
||||||
|
report["4"] = character.name
|
||||||
else:
|
else:
|
||||||
report["4"] = "Player Deleted"
|
report["4"] = "Player Deleted"
|
||||||
|
|
||||||
|
@ -73,6 +73,15 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
{% else %}
|
||||||
|
<li class="nav-item dropdown">
|
||||||
|
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Bug Reports</a>
|
||||||
|
<div class="dropdown-menu">
|
||||||
|
<a class="dropdown-item text-center" href='{{ url_for('bug_reports.index', status='unresolved') }}'>Unresolved Reports</a>
|
||||||
|
<a class="dropdown-item text-center" href='{{ url_for('bug_reports.index', status='resolved') }}'>Resolved Reports</a>
|
||||||
|
<a class="dropdown-item text-center" href='{{ url_for('bug_reports.index', status='all') }}'>All Reports</a>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if current_user.is_authenticated and current_user.gm_level == 9 and config.REQUIRE_PLAY_KEY %}
|
{% if current_user.is_authenticated and current_user.gm_level == 9 and config.REQUIRE_PLAY_KEY %}
|
||||||
|
Loading…
Reference in New Issue
Block a user