diff --git a/app/bug_reports.py b/app/bug_reports.py index bc9c714..7d5e2ac 100644 --- a/app/bug_reports.py +++ b/app/bug_reports.py @@ -68,7 +68,7 @@ def get(status): elif status == "resolved": query = db.session.query().select_from(BugReport).filter(BugReport.resolved_time is not None) elif status == "unresolved": - query = db.session.query().select_from(BugReport).filter(BugReport.resolved_time is None) + query = db.session.query().select_from(BugReport).filter(BugReport.resolved_time == "") else: raise Exception("Not a valid filter") diff --git a/app/forms.py b/app/forms.py index 0e37688..e265aee 100644 --- a/app/forms.py +++ b/app/forms.py @@ -187,3 +187,13 @@ class RescueForm(FlaskForm): ) submit = SubmitField('Submit') + + +class RejectPropertyForm(FlaskForm): + rejection_reason = StringField( + 'Rejection Reason', + widget=TextArea(), + validators=[validators.DataRequired()] + ) + + submit = SubmitField('Submit') diff --git a/app/properties.py b/app/properties.py index bbf1877..42b3999 100644 --- a/app/properties.py +++ b/app/properties.py @@ -12,10 +12,11 @@ from flask import ( from flask_user import login_required, current_user from datatables import ColumnDT, DataTables import time -from app.models import Property, db, UGC, CharacterInfo, PropertyContent, Account +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.luclient import query_cdclient +from app.forms import RejectPropertyForm import zlib import app.pylddlib as ldd @@ -70,7 +71,7 @@ def approve(id): log_audit(message) flash( message, - "danger" + "warning" ) property_data.save() @@ -88,6 +89,67 @@ def approve(id): return redirect(go_to) +@property_blueprint.route('/reject/', methods=['GET', 'POST']) +@login_required +@gm_level(3) +def reject(id): + + property_data = Property.query.filter(Property.id == id).first() + + form = RejectPropertyForm() + + if form.validate_on_submit(): + char_name = CharacterInfo.query.filter(CharacterInfo.id==property_data.owner_id).first().name + zone_name = query_cdclient( + 'select DisplayDescription from ZoneTable where zoneID = ?', + [property_data.zone_id], + one=True + )[0] + property_data.mod_approved = False + property_data.rejection_reason = form.rejection_reason.data + message = f"""Rejected Property + {property_data.name if property_data.name else zone_name} + from {char_name} with reason \"{form.rejection_reason.data}\"""" + log_audit(message) + flash( + message, + "danger" + ) + + property_data.save() + + # send rejection reason to their mailbox + # cause the game doesn't present it otherwise + Mail( + sender_id=0, + sender_name=f"[GM] {current_user.username}", + receiver_id=property_data.owner_id, + receiver_name=char_name, + time_sent=time.time(), + subject=f"Property {property_data.name} on {zone_name} Rejected", + body=message, + attachment_id=0, + attachment_lot=0, + attachment_count=0 + ).save() + + go_to = "" + + if request.referrer: + if "view_models" in request.referrer: + go_to = url_for('properties.view', id=id) + else: + go_to = url_for('properties.index') + else: + go_to = url_for('main.index') + + return redirect(go_to) + + form.rejection_reason.data = property_data.rejection_reason + + return render_template('properties/reject.html.j2', property_data=property_data, form=form) + + @property_blueprint.route('/view/', methods=['GET']) @login_required def view(id): @@ -172,6 +234,13 @@ def get(status="all"): Unapprove """ + if not property_data["10"]: + property_data["0"] += f""" + + Reject + + """ property_data["1"] = f""" - +{% block content_override %} +
+ + @@ -20,9 +21,10 @@ - - -
Actions BodySubmitted Resolved
+ + + +
{% endblock %} diff --git a/app/templates/moderation/index.html.j2 b/app/templates/moderation/index.html.j2 index 923b61d..2f93857 100644 --- a/app/templates/moderation/index.html.j2 +++ b/app/templates/moderation/index.html.j2 @@ -8,60 +8,62 @@ Moderation of {{ status|capitalize }} Items {% endblock content_before %} -{% block content %} -

Characters

-
- - - - - - - - - - - - - -
ActionsAccountNamePending NameNeeds RenameLast LoginPermission Map
-
-

Pets

-
- - - - - - - - - - -
ActionsNameStatusOwner
-
-

Properties

-
- - - - - - - - - - - - - - - - - - - -
ActionsOwnerTemplate IDClone IDNameDescriptionPrivacyApprovedUpdatedClaimedRejection ReasonReputationLocation
+{% block content_override %} +
+

Characters

+
+ + + + + + + + + + + + + +
ActionsAccountNamePending NameNeeds RenameLast LoginPermission Map
+
+

Pets

+
+ + + + + + + + + + +
ActionsNameStatusOwner
+
+

Properties

+
+ + + + + + + + + + + + + + + + + + + +
ActionsOwnerTemplate IDClone IDNameDescriptionPrivacyApprovedUpdatedClaimedRejection ReasonReputationLocation
+
{% endblock %} {% block js %} diff --git a/app/templates/properties/index.html.j2 b/app/templates/properties/index.html.j2 index 8c5635c..a898ff9 100644 --- a/app/templates/properties/index.html.j2 +++ b/app/templates/properties/index.html.j2 @@ -8,36 +8,38 @@ Property Management {% endblock content_before %} -{% block content %} - {% if message %} -
-
-

{{ message }}

+{% block content_override %} +
+ {% if message %} +
+
+

{{ message }}

+
-
-
- {% endif %} - - - - - - - - - - - - - - - - - - - - -
ActionsOwnerTemplate IDClone IDNameDescriptionPrivacyApprovedUpdatedClaimedRejection ReasonReputationPerformance CostLocation
+
+ {% endif %} + + + + + + + + + + + + + + + + + + + + +
ActionsOwnerTemplate IDClone IDNameDescriptionPrivacyApprovedUpdatedClaimedRejection ReasonReputationPerformance CostLocation
+
{% endblock %} diff --git a/app/templates/properties/reject.html.j2 b/app/templates/properties/reject.html.j2 new file mode 100644 index 0000000..7d5f826 --- /dev/null +++ b/app/templates/properties/reject.html.j2 @@ -0,0 +1,32 @@ +{% extends 'base.html.j2' %} + +{% block title %} + Viewing {{property_data.owner.name}}'s + {% if property_data.name %} + {{ property_data.name }} + {% else %} + {{ property_data.zone_id|get_zone_name }} + {% endif %} +{% endblock %} + +{% block content_before %} + Viewing {{property_data.owner.name}}'s + {% if property_data.name %} + {{ property_data.name }} + {% else %} + {{ property_data.zone_id|get_zone_name }} + {% endif %} +{% endblock %} + +{% block content %} +
+ {{ form.csrf_token }} +
+
+ {{ helper.render_field(form.rejection_reason) }} + {{ helper.render_submit_field(form.submit) }} +
+
+
+{% endblock content %} +