mirror of
				https://github.com/DarkflameUniverse/NexusDashboard.git
				synced 2025-11-03 21:51:53 +00:00 
			
		
		
		
	Property rejection handling
fixe some table to be wider make search and pagination float right
This commit is contained in:
		@@ -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")
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										10
									
								
								app/forms.py
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								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')
 | 
			
		||||
 
 | 
			
		||||
@@ -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/<id>', 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/<id>', methods=['GET'])
 | 
			
		||||
@login_required
 | 
			
		||||
def view(id):
 | 
			
		||||
@@ -172,6 +234,13 @@ def get(status="all"):
 | 
			
		||||
                    Unapprove
 | 
			
		||||
                </a>
 | 
			
		||||
            """
 | 
			
		||||
        if not property_data["10"]:
 | 
			
		||||
            property_data["0"] += f"""
 | 
			
		||||
                <a role="button" class="btn btn-danger btn btn-block"
 | 
			
		||||
                    href='{url_for('properties.reject', id=id)}'>
 | 
			
		||||
                    Reject
 | 
			
		||||
                </a>
 | 
			
		||||
            """
 | 
			
		||||
 | 
			
		||||
        property_data["1"] = f"""
 | 
			
		||||
            <a role="button" class="btn btn-primary btn btn-block"
 | 
			
		||||
 
 | 
			
		||||
@@ -92,3 +92,13 @@ body { font-family:'Nunito', Helvetica, Arial, sans-serif; }
 | 
			
		||||
  color: rgba(255, 255, 255, 0.5);
 | 
			
		||||
  border-color: rgba(255, 255, 255, 0.5);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
div.dataTables_paginate {
 | 
			
		||||
  float: right;
 | 
			
		||||
  margin: 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
div.dataTables_filter{
 | 
			
		||||
  float: right;
 | 
			
		||||
  margin: 0;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -8,9 +8,10 @@
 | 
			
		||||
  {{ status|capitalize }} Bug Reports
 | 
			
		||||
{% endblock content_before %}
 | 
			
		||||
 | 
			
		||||
{% block content %}
 | 
			
		||||
  <table class="table table-dark table-striped table-bordered table-hover" id="accounts_table">
 | 
			
		||||
    <thead>
 | 
			
		||||
{% block content_override %}
 | 
			
		||||
  <div class="mx-5">
 | 
			
		||||
    <table class="table table-dark table-striped table-bordered table-hover" id="accounts_table">
 | 
			
		||||
      <thead>
 | 
			
		||||
        <tr>
 | 
			
		||||
            <th>Actions</th>
 | 
			
		||||
            <th>Body</th>
 | 
			
		||||
@@ -20,9 +21,10 @@
 | 
			
		||||
            <th>Submitted</th>
 | 
			
		||||
            <th>Resolved</th>
 | 
			
		||||
        </tr>
 | 
			
		||||
    </thead>
 | 
			
		||||
    <tbody></tbody>
 | 
			
		||||
</table>
 | 
			
		||||
      </thead>
 | 
			
		||||
      <tbody></tbody>
 | 
			
		||||
    </table>
 | 
			
		||||
  </div>
 | 
			
		||||
{% endblock  %}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -8,60 +8,62 @@
 | 
			
		||||
  Moderation of {{ status|capitalize }} Items
 | 
			
		||||
{% endblock content_before %}
 | 
			
		||||
 | 
			
		||||
{% block content %}
 | 
			
		||||
  <h4> Characters </h4>
 | 
			
		||||
  <hr class="bg-primary"/>
 | 
			
		||||
  <table class="table table-dark table-striped table-bordered table-hover" id="character_table">
 | 
			
		||||
    <thead>
 | 
			
		||||
        <tr>
 | 
			
		||||
          <th>Actions</th>
 | 
			
		||||
          <th>Account</th>
 | 
			
		||||
          <th>Name</th>
 | 
			
		||||
          <th>Pending Name</th>
 | 
			
		||||
          <th>Needs Rename</th>
 | 
			
		||||
          <th>Last Login</th>
 | 
			
		||||
          <th>Permission Map</th>
 | 
			
		||||
        </tr>
 | 
			
		||||
    </thead>
 | 
			
		||||
    <tbody></tbody>
 | 
			
		||||
  </table>
 | 
			
		||||
  <br/>
 | 
			
		||||
  <h4> Pets </h4>
 | 
			
		||||
  <hr class="bg-primary"/>
 | 
			
		||||
  <table class="table table-dark table-striped table-bordered table-hover" id="pet_table">
 | 
			
		||||
    <thead>
 | 
			
		||||
        <tr>
 | 
			
		||||
          <th>Actions</th>
 | 
			
		||||
          <th>Name</th>
 | 
			
		||||
          <th>Status</th>
 | 
			
		||||
          <th>Owner</th>
 | 
			
		||||
        </tr>
 | 
			
		||||
    </thead>
 | 
			
		||||
    <tbody></tbody>
 | 
			
		||||
  </table>
 | 
			
		||||
  <br/>
 | 
			
		||||
  <h4> Properties </h4>
 | 
			
		||||
  <hr class="bg-primary"/>
 | 
			
		||||
  <table class="table table-dark table-striped table-bordered table-hover" id="property_table">
 | 
			
		||||
    <thead>
 | 
			
		||||
        <tr>
 | 
			
		||||
          <th>Actions</th>
 | 
			
		||||
          <th>Owner</th>
 | 
			
		||||
          <th>Template ID</th>
 | 
			
		||||
          <th>Clone ID</th>
 | 
			
		||||
          <th>Name</th>
 | 
			
		||||
          <th>Description</th>
 | 
			
		||||
          <th>Privacy</th>
 | 
			
		||||
          <th>Approved</th>
 | 
			
		||||
          <th>Updated</th>
 | 
			
		||||
          <th>Claimed</th>
 | 
			
		||||
          <th>Rejection Reason</th>
 | 
			
		||||
          <th>Reputation</th>
 | 
			
		||||
          <th>Location</th>
 | 
			
		||||
        </tr>
 | 
			
		||||
    </thead>
 | 
			
		||||
    <tbody></tbody>
 | 
			
		||||
  </table>
 | 
			
		||||
{% block content_override %}
 | 
			
		||||
  <div class="mx-5">
 | 
			
		||||
    <h4> Characters </h4>
 | 
			
		||||
    <hr class="bg-primary"/>
 | 
			
		||||
    <table class="table table-dark table-striped table-bordered table-hover" id="character_table">
 | 
			
		||||
      <thead>
 | 
			
		||||
          <tr>
 | 
			
		||||
            <th>Actions</th>
 | 
			
		||||
            <th>Account</th>
 | 
			
		||||
            <th>Name</th>
 | 
			
		||||
            <th>Pending Name</th>
 | 
			
		||||
            <th>Needs Rename</th>
 | 
			
		||||
            <th>Last Login</th>
 | 
			
		||||
            <th>Permission Map</th>
 | 
			
		||||
          </tr>
 | 
			
		||||
      </thead>
 | 
			
		||||
      <tbody></tbody>
 | 
			
		||||
    </table>
 | 
			
		||||
    <br/>
 | 
			
		||||
    <h4> Pets </h4>
 | 
			
		||||
    <hr class="bg-primary"/>
 | 
			
		||||
    <table class="table table-dark table-striped table-bordered table-hover" id="pet_table">
 | 
			
		||||
      <thead>
 | 
			
		||||
          <tr>
 | 
			
		||||
            <th>Actions</th>
 | 
			
		||||
            <th>Name</th>
 | 
			
		||||
            <th>Status</th>
 | 
			
		||||
            <th>Owner</th>
 | 
			
		||||
          </tr>
 | 
			
		||||
      </thead>
 | 
			
		||||
      <tbody></tbody>
 | 
			
		||||
    </table>
 | 
			
		||||
    <br/>
 | 
			
		||||
    <h4> Properties </h4>
 | 
			
		||||
    <hr class="bg-primary"/>
 | 
			
		||||
    <table class="table table-dark table-striped table-bordered table-hover" id="property_table">
 | 
			
		||||
      <thead>
 | 
			
		||||
          <tr>
 | 
			
		||||
            <th>Actions</th>
 | 
			
		||||
            <th>Owner</th>
 | 
			
		||||
            <th>Template ID</th>
 | 
			
		||||
            <th>Clone ID</th>
 | 
			
		||||
            <th>Name</th>
 | 
			
		||||
            <th>Description</th>
 | 
			
		||||
            <th>Privacy</th>
 | 
			
		||||
            <th>Approved</th>
 | 
			
		||||
            <th>Updated</th>
 | 
			
		||||
            <th>Claimed</th>
 | 
			
		||||
            <th>Rejection Reason</th>
 | 
			
		||||
            <th>Reputation</th>
 | 
			
		||||
            <th>Location</th>
 | 
			
		||||
          </tr>
 | 
			
		||||
      </thead>
 | 
			
		||||
      <tbody></tbody>
 | 
			
		||||
    </table>
 | 
			
		||||
  </div>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 | 
			
		||||
{% block js %}
 | 
			
		||||
 
 | 
			
		||||
@@ -8,36 +8,38 @@
 | 
			
		||||
  Property Management
 | 
			
		||||
{% endblock content_before %}
 | 
			
		||||
 | 
			
		||||
{% block content %}
 | 
			
		||||
  {% if message %}
 | 
			
		||||
    <div class="row">
 | 
			
		||||
      <div class="col text-center">
 | 
			
		||||
        <h3>{{ message }}</h3>
 | 
			
		||||
{% block content_override %}
 | 
			
		||||
  <div class="mx-5">
 | 
			
		||||
    {% if message %}
 | 
			
		||||
      <div class="row">
 | 
			
		||||
        <div class="col text-center">
 | 
			
		||||
          <h3>{{ message }}</h3>
 | 
			
		||||
        </div>
 | 
			
		||||
      </div>
 | 
			
		||||
    </div>
 | 
			
		||||
    <br/>
 | 
			
		||||
  {% endif %}
 | 
			
		||||
  <table class="table table-dark table-striped table-bordered table-hover" id="properties_table">
 | 
			
		||||
    <thead>
 | 
			
		||||
        <tr>
 | 
			
		||||
            <th>Actions</th>
 | 
			
		||||
            <th>Owner</th>
 | 
			
		||||
            <th>Template ID</th>
 | 
			
		||||
            <th>Clone ID</th>
 | 
			
		||||
            <th>Name</th>
 | 
			
		||||
            <th>Description</th>
 | 
			
		||||
            <th>Privacy</th>
 | 
			
		||||
            <th>Approved</th>
 | 
			
		||||
            <th>Updated</th>
 | 
			
		||||
            <th>Claimed</th>
 | 
			
		||||
            <th>Rejection Reason</th>
 | 
			
		||||
            <th>Reputation</th>
 | 
			
		||||
            <th>Performance Cost</th>
 | 
			
		||||
            <th>Location</th>
 | 
			
		||||
        </tr>
 | 
			
		||||
    </thead>
 | 
			
		||||
    <tbody></tbody>
 | 
			
		||||
  </table>
 | 
			
		||||
      <br/>
 | 
			
		||||
    {% endif %}
 | 
			
		||||
    <table class="table table-dark table-striped table-bordered table-hover" id="properties_table">
 | 
			
		||||
      <thead>
 | 
			
		||||
          <tr>
 | 
			
		||||
              <th>Actions</th>
 | 
			
		||||
              <th>Owner</th>
 | 
			
		||||
              <th>Template ID</th>
 | 
			
		||||
              <th>Clone ID</th>
 | 
			
		||||
              <th>Name</th>
 | 
			
		||||
              <th>Description</th>
 | 
			
		||||
              <th>Privacy</th>
 | 
			
		||||
              <th>Approved</th>
 | 
			
		||||
              <th>Updated</th>
 | 
			
		||||
              <th>Claimed</th>
 | 
			
		||||
              <th>Rejection Reason</th>
 | 
			
		||||
              <th>Reputation</th>
 | 
			
		||||
              <th>Performance Cost</th>
 | 
			
		||||
              <th>Location</th>
 | 
			
		||||
          </tr>
 | 
			
		||||
      </thead>
 | 
			
		||||
      <tbody></tbody>
 | 
			
		||||
    </table>
 | 
			
		||||
  </div>
 | 
			
		||||
{% endblock  %}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										32
									
								
								app/templates/properties/reject.html.j2
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								app/templates/properties/reject.html.j2
									
									
									
									
									
										Normal file
									
								
							@@ -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 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.rejection_reason) }}
 | 
			
		||||
        {{ helper.render_submit_field(form.submit) }}
 | 
			
		||||
      </div>
 | 
			
		||||
    </div>
 | 
			
		||||
  </form>
 | 
			
		||||
{% endblock content %}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user