add reporter id to bug reports

fix moderation status filters
This commit is contained in:
Aaron Kimbre 2022-04-02 18:17:16 -05:00
parent 70aed00d97
commit 6fa7ade6a3
6 changed files with 100 additions and 29 deletions

View File

@ -54,21 +54,22 @@ def resolve(id):
def get(status):
columns = [
ColumnDT(BugReport.id), # 0
ColumnDT(BugReport.body), # 1
ColumnDT(BugReport.client_version), # 2
ColumnDT(BugReport.other_player_id), # 3
ColumnDT(BugReport.selection), # 4
ColumnDT(BugReport.submitted), # 5
ColumnDT(BugReport.resolved_time), # 6
ColumnDT(BugReport.reporter_id), # 1
ColumnDT(BugReport.body), # 2
ColumnDT(BugReport.client_version), # 3
ColumnDT(BugReport.other_player_id), # 4
ColumnDT(BugReport.selection), # 5
ColumnDT(BugReport.submitted), # 6
ColumnDT(BugReport.resolved_time), # 7
]
query = None
if status == "all":
query = db.session.query().select_from(BugReport)
elif status == "resolved":
query = db.session.query().select_from(BugReport).filter(BugReport.resolved_time is not 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 == "")
query = db.session.query().select_from(BugReport).filter(BugReport.resolved_time == None)
else:
raise Exception("Not a valid filter")
@ -86,31 +87,44 @@ def get(status):
</a>
"""
if not report["6"]:
if report["7"] is not None:
report["0"] += f"""
<a role="button" class="btn btn-danger btn btn-block"
href='{url_for('bug_reports.resolve', id=id)}'>
Resolve
</a>
"""
if report["3"] == "0":
report["3"] = "None"
<a role="button" class="btn btn-danger btn btn-block"
href='{url_for('bug_reports.resolve', id=id)}'>
Resolve
</a>
"""
else:
character = CharacterInfo.query.filter(CharacterInfo.id == int(report["3"]) & 0xFFFFFFFF).first()
report["7"] = '''<h1 class="far fa-times-circle text-danger"></h1>'''
if report["1"]:
report["1"] = "None"
else:
character = CharacterInfo.query.filter(CharacterInfo.id == int(report["1"])).first()
if character:
report["3"] = f"""
report["1"] = f"""
<a role="button" class="btn btn-primary btn btn-block"
href='{url_for('characters.view', id=(int(report["3"]) & 0xFFFFFFFF))}'>
href='{url_for('characters.view', id=report['1'])}'>
{character.name}
</a>
"""
else:
report["3"] = "Player Deleted"
report["1"] = "Player Deleted"
report["4"] = translate_from_locale(report["4"][2:-1])
if report["4"] == "0":
report["4"] = "None"
else:
character = CharacterInfo.query.filter(CharacterInfo.id == int(report["4"]) & 0xFFFFFFFF).first()
if character:
report["4"] = f"""
<a role="button" class="btn btn-primary btn btn-block"
href='{url_for('characters.view', id=(int(report["4"]) & 0xFFFFFFFF))}'>
{character.name}
</a>
"""
else:
report["4"] = "Player Deleted"
if not report["6"]:
report["6"] = '''<h1 class="far fa-times-circle text-danger"></h1>'''
report["5"] = translate_from_locale(report["5"][2:-1])
return data

View File

@ -228,9 +228,9 @@ def get(status):
if status == "all":
query = db.session.query().select_from(CharacterInfo).join(Account)
elif status == "approved":
query = db.session.query().select_from(CharacterInfo).join(Account).filter((CharacterInfo.pending_name == "") & (CharacterInfo.needs_rename is False))
query = db.session.query().select_from(CharacterInfo).join(Account).filter((CharacterInfo.pending_name == "") & (CharacterInfo.needs_rename == False))
elif status == "unapproved":
query = db.session.query().select_from(CharacterInfo).join(Account).filter((CharacterInfo.pending_name != "") | (CharacterInfo.needs_rename is True))
query = db.session.query().select_from(CharacterInfo).join(Account).filter((CharacterInfo.pending_name != "") | (CharacterInfo.needs_rename == True))
else:
raise Exception("Not a valid filter")

View File

@ -8,7 +8,6 @@ from flask_sqlalchemy import BaseQuery
from sqlalchemy.dialects import mysql
from sqlalchemy.exc import OperationalError, StatementError
from sqlalchemy.types import JSON
from sqlalchemy.ext.hybrid import hybrid_property
from time import sleep
import random
import string
@ -956,6 +955,12 @@ class BugReport(db.Model):
nullable=True
)
reporter_id = db.Column(
mysql.INTEGER(),
nullable=False,
server_default='0'
)
def save(self):
db.session.add(self)
db.session.commit()

View File

@ -199,11 +199,11 @@ def get(status="all"):
elif status == "approved":
query = db.session.query().select_from(Property).join(
CharacterInfo, CharacterInfo.id == Property.owner_id
).join(Account).filter(Property.mod_approved is True).filter(Property.privacy_option == 2)
).join(Account).filter(Property.mod_approved == True).filter(Property.privacy_option == 2)
elif status == "unapproved":
query = db.session.query().select_from(Property).join(
CharacterInfo, CharacterInfo.id == Property.owner_id
).join(Account).filter(Property.mod_approved is False).filter(Property.privacy_option == 2)
).join(Account).filter(Property.mod_approved == False).filter(Property.privacy_option == 2)
else:
raise Exception("Not a valid filter")

View File

@ -14,6 +14,7 @@
<thead>
<tr>
<th>Actions</th>
<th>Reporter</th>
<th>Body</th>
<th>Client Version</th>
<th>Other Player</th>

View File

@ -0,0 +1,51 @@
"""reporter_id
Revision ID: 8e52b5c7568a
Revises: fa97b0d0c351
Create Date: 2022-04-02 17:35:54.814007
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
from sqlalchemy import engine_from_config
from sqlalchemy.engine import reflection
# revision identifiers, used by Alembic.
revision = '8e52b5c7568a'
down_revision = 'fa97b0d0c351'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
if not _table_has_column('bug_reports', 'reporter_id'):
op.add_column(
'bug_reports',
sa.Column(
'reporter_id',
mysql.INTEGER(),
server_default='0',
nullable=False
)
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('bug_reports', 'reporter_id')
# ### end Alembic commands ###
def _table_has_column(table, column):
config = op.get_context().config
engine = engine_from_config(
config.get_section(config.config_ini_section), prefix='sqlalchemy.')
insp = reflection.Inspector.from_engine(engine)
has_column = False
for col in insp.get_columns(table):
if column not in col['name']:
continue
has_column = True
return has_column