add reporter id to bug reports
fix moderation status filters
This commit is contained in:
parent
70aed00d97
commit
6fa7ade6a3
@ -54,21 +54,22 @@ def resolve(id):
|
|||||||
def get(status):
|
def get(status):
|
||||||
columns = [
|
columns = [
|
||||||
ColumnDT(BugReport.id), # 0
|
ColumnDT(BugReport.id), # 0
|
||||||
ColumnDT(BugReport.body), # 1
|
ColumnDT(BugReport.reporter_id), # 1
|
||||||
ColumnDT(BugReport.client_version), # 2
|
ColumnDT(BugReport.body), # 2
|
||||||
ColumnDT(BugReport.other_player_id), # 3
|
ColumnDT(BugReport.client_version), # 3
|
||||||
ColumnDT(BugReport.selection), # 4
|
ColumnDT(BugReport.other_player_id), # 4
|
||||||
ColumnDT(BugReport.submitted), # 5
|
ColumnDT(BugReport.selection), # 5
|
||||||
ColumnDT(BugReport.resolved_time), # 6
|
ColumnDT(BugReport.submitted), # 6
|
||||||
|
ColumnDT(BugReport.resolved_time), # 7
|
||||||
]
|
]
|
||||||
|
|
||||||
query = None
|
query = None
|
||||||
if status == "all":
|
if status == "all":
|
||||||
query = db.session.query().select_from(BugReport)
|
query = db.session.query().select_from(BugReport)
|
||||||
elif status == "resolved":
|
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":
|
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:
|
else:
|
||||||
raise Exception("Not a valid filter")
|
raise Exception("Not a valid filter")
|
||||||
|
|
||||||
@ -86,31 +87,44 @@ def get(status):
|
|||||||
</a>
|
</a>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not report["6"]:
|
if report["7"] is not None:
|
||||||
report["0"] += f"""
|
report["0"] += f"""
|
||||||
<a role="button" class="btn btn-danger btn btn-block"
|
<a role="button" class="btn btn-danger btn btn-block"
|
||||||
href='{url_for('bug_reports.resolve', id=id)}'>
|
href='{url_for('bug_reports.resolve', id=id)}'>
|
||||||
Resolve
|
Resolve
|
||||||
</a>
|
</a>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if report["3"] == "0":
|
|
||||||
report["3"] = "None"
|
|
||||||
else:
|
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:
|
if character:
|
||||||
report["3"] = f"""
|
report["1"] = f"""
|
||||||
<a role="button" class="btn btn-primary btn btn-block"
|
<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}
|
{character.name}
|
||||||
</a>
|
</a>
|
||||||
"""
|
"""
|
||||||
else:
|
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["5"] = translate_from_locale(report["5"][2:-1])
|
||||||
report["6"] = '''<h1 class="far fa-times-circle text-danger"></h1>'''
|
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
@ -228,9 +228,9 @@ def get(status):
|
|||||||
if status == "all":
|
if status == "all":
|
||||||
query = db.session.query().select_from(CharacterInfo).join(Account)
|
query = db.session.query().select_from(CharacterInfo).join(Account)
|
||||||
elif status == "approved":
|
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":
|
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:
|
else:
|
||||||
raise Exception("Not a valid filter")
|
raise Exception("Not a valid filter")
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ 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 sqlalchemy.types import JSON
|
||||||
from sqlalchemy.ext.hybrid import hybrid_property
|
|
||||||
from time import sleep
|
from time import sleep
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
@ -956,6 +955,12 @@ class BugReport(db.Model):
|
|||||||
nullable=True
|
nullable=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
reporter_id = db.Column(
|
||||||
|
mysql.INTEGER(),
|
||||||
|
nullable=False,
|
||||||
|
server_default='0'
|
||||||
|
)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
db.session.add(self)
|
db.session.add(self)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
@ -199,11 +199,11 @@ def get(status="all"):
|
|||||||
elif status == "approved":
|
elif status == "approved":
|
||||||
query = db.session.query().select_from(Property).join(
|
query = db.session.query().select_from(Property).join(
|
||||||
CharacterInfo, CharacterInfo.id == Property.owner_id
|
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":
|
elif status == "unapproved":
|
||||||
query = db.session.query().select_from(Property).join(
|
query = db.session.query().select_from(Property).join(
|
||||||
CharacterInfo, CharacterInfo.id == Property.owner_id
|
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:
|
else:
|
||||||
raise Exception("Not a valid filter")
|
raise Exception("Not a valid filter")
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
|
<th>Reporter</th>
|
||||||
<th>Body</th>
|
<th>Body</th>
|
||||||
<th>Client Version</th>
|
<th>Client Version</th>
|
||||||
<th>Other Player</th>
|
<th>Other Player</th>
|
||||||
|
51
migrations/versions/8e52b5c7568a_reporter_id.py
Normal file
51
migrations/versions/8e52b5c7568a_reporter_id.py
Normal 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
|
Loading…
Reference in New Issue
Block a user