mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-08 22:17:34 +01:00
Revert "Add ability to delete threads"
This reverts commit 15821fe7965078d3833a36cfd7d2bd71b9e236e9.
This commit is contained in:
parent
15063d92cd
commit
78630b3071
@ -21,7 +21,10 @@ bp = Blueprint("threads", __name__)
|
||||
|
||||
from flask_user import *
|
||||
from app.models import *
|
||||
from app.utils import addNotification, isYes, addAuditLog
|
||||
from app.utils import addNotification, clearNotifications, isYes, addAuditLog
|
||||
|
||||
import datetime
|
||||
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import *
|
||||
from wtforms.validators import *
|
||||
@ -104,29 +107,6 @@ def set_lock(id):
|
||||
return redirect(thread.getViewURL())
|
||||
|
||||
|
||||
@bp.route("/threads/<int:id>/delete/", methods=["GET", "POST"])
|
||||
@login_required
|
||||
def delete_thread(id):
|
||||
thread = Thread.query.get(id)
|
||||
if thread is None or not thread.checkPerm(current_user, Permission.DELETE_THREAD):
|
||||
abort(404)
|
||||
|
||||
if request.method == "GET":
|
||||
return render_template("threads/delete_thread.html", thread=thread)
|
||||
|
||||
summary = "\n\n".join([("<{}> {}".format(reply.author.display_name, reply.comment)) for reply in thread.replies])
|
||||
|
||||
msg = "Deleted thread {} by {}".format(thread.title, thread.author.display_name)
|
||||
|
||||
db.session.delete(thread)
|
||||
|
||||
addAuditLog(AuditSeverity.MODERATION, current_user, msg, None, thread.package, summary)
|
||||
|
||||
db.session.commit()
|
||||
|
||||
return redirect(url_for("homepage.home"))
|
||||
|
||||
|
||||
@bp.route("/threads/<int:id>/delete/", methods=["GET", "POST"])
|
||||
@login_required
|
||||
def delete_reply(id):
|
||||
|
@ -95,7 +95,6 @@ class Permission(enum.Enum):
|
||||
CREATE_THREAD = "CREATE_THREAD"
|
||||
COMMENT_THREAD = "COMMENT_THREAD"
|
||||
LOCK_THREAD = "LOCK_THREAD"
|
||||
DELETE_THREAD = "DELETE_THREAD"
|
||||
DELETE_REPLY = "DELETE_REPLY"
|
||||
EDIT_REPLY = "EDIT_REPLY"
|
||||
UNAPPROVE_PACKAGE = "UNAPPROVE_PACKAGE"
|
||||
@ -131,7 +130,7 @@ class Permission(enum.Enum):
|
||||
return perm.check(user)
|
||||
|
||||
def display_name_default(context):
|
||||
return context.get_current_parameters()["username"]
|
||||
return context.get_current_parameters()["username"]
|
||||
|
||||
class User(db.Model, UserMixin):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
@ -411,22 +410,22 @@ class PackagePropertyKey(enum.Enum):
|
||||
|
||||
provides = db.Table("provides",
|
||||
db.Column("package_id", db.Integer, db.ForeignKey("package.id"), primary_key=True),
|
||||
db.Column("metapackage_id", db.Integer, db.ForeignKey("meta_package.id"), primary_key=True)
|
||||
db.Column("metapackage_id", db.Integer, db.ForeignKey("meta_package.id"), primary_key=True)
|
||||
)
|
||||
|
||||
Tags = db.Table("tags",
|
||||
db.Column("tag_id", db.Integer, db.ForeignKey("tag.id"), primary_key=True),
|
||||
db.Column("package_id", db.Integer, db.ForeignKey("package.id"), primary_key=True)
|
||||
db.Column("tag_id", db.Integer, db.ForeignKey("tag.id"), primary_key=True),
|
||||
db.Column("package_id", db.Integer, db.ForeignKey("package.id"), primary_key=True)
|
||||
)
|
||||
|
||||
ContentWarnings = db.Table("content_warnings",
|
||||
db.Column("content_warning_id", db.Integer, db.ForeignKey("content_warning.id"), primary_key=True),
|
||||
db.Column("package_id", db.Integer, db.ForeignKey("package.id"), primary_key=True)
|
||||
db.Column("content_warning_id", db.Integer, db.ForeignKey("content_warning.id"), primary_key=True),
|
||||
db.Column("package_id", db.Integer, db.ForeignKey("package.id"), primary_key=True)
|
||||
)
|
||||
|
||||
maintainers = db.Table("maintainers",
|
||||
db.Column("user_id", db.Integer, db.ForeignKey("user.id"), primary_key=True),
|
||||
db.Column("package_id", db.Integer, db.ForeignKey("package.id"), primary_key=True)
|
||||
db.Column("user_id", db.Integer, db.ForeignKey("user.id"), primary_key=True),
|
||||
db.Column("package_id", db.Integer, db.ForeignKey("package.id"), primary_key=True)
|
||||
)
|
||||
|
||||
class Dependency(db.Model):
|
||||
@ -1244,8 +1243,8 @@ class EditRequestChange(db.Model):
|
||||
|
||||
|
||||
watchers = db.Table("watchers",
|
||||
db.Column("user_id", db.Integer, db.ForeignKey("user.id"), primary_key=True),
|
||||
db.Column("thread_id", db.Integer, db.ForeignKey("thread.id"), primary_key=True)
|
||||
db.Column("user_id", db.Integer, db.ForeignKey("user.id"), primary_key=True),
|
||||
db.Column("thread_id", db.Integer, db.ForeignKey("thread.id"), primary_key=True)
|
||||
)
|
||||
|
||||
class Thread(db.Model):
|
||||
@ -1255,7 +1254,7 @@ class Thread(db.Model):
|
||||
package = db.relationship("Package", foreign_keys=[package_id])
|
||||
|
||||
review_id = db.Column(db.Integer, db.ForeignKey("package_review.id"), nullable=True)
|
||||
review = db.relationship("PackageReview", foreign_keys=[review_id], cascade="all, delete")
|
||||
review = db.relationship("PackageReview", foreign_keys=[review_id])
|
||||
|
||||
author_id = db.Column(db.Integer, db.ForeignKey("user.id"), nullable=False)
|
||||
title = db.Column(db.String(100), nullable=False)
|
||||
@ -1266,7 +1265,7 @@ class Thread(db.Model):
|
||||
created_at = db.Column(db.DateTime, nullable=False, default=datetime.datetime.utcnow)
|
||||
|
||||
replies = db.relationship("ThreadReply", backref="thread", lazy="dynamic", \
|
||||
order_by=db.asc("thread_reply_id"), cascade="all, delete")
|
||||
order_by=db.asc("thread_reply_id"))
|
||||
|
||||
watchers = db.relationship("User", secondary=watchers, lazy="subquery", \
|
||||
backref=db.backref("watching", lazy=True))
|
||||
@ -1301,7 +1300,7 @@ class Thread(db.Model):
|
||||
elif perm == Permission.COMMENT_THREAD:
|
||||
return canSee and (not self.locked or user.rank.atLeast(UserRank.MODERATOR))
|
||||
|
||||
elif perm == Permission.LOCK_THREAD or perm == Permission.DELETE_THREAD:
|
||||
elif perm == Permission.LOCK_THREAD:
|
||||
return user.rank.atLeast(UserRank.MODERATOR)
|
||||
|
||||
else:
|
||||
|
@ -1,22 +0,0 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}
|
||||
Delete thread in {{ thread.title }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<form method="POST" action="" class="card box_grey">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
||||
|
||||
<h3 class="card-header">Delete {{ thread.title }} by {{ thread.author.display_name }}</h3>
|
||||
<div class="card-body">
|
||||
{{ thread.replies[0].comment | markdown }}
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>Deleting is permanent</p>
|
||||
|
||||
<a class="btn btn-secondary mr-3" href="{{ thread.getViewURL() }}">Cancel</a>
|
||||
<input type="submit" value="Delete" class="btn btn-danger" />
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
@ -17,19 +17,16 @@
|
||||
<input type="submit" class="btn btn-primary" value="Subscribe" />
|
||||
</form>
|
||||
{% endif %}
|
||||
{% if thread and thread.checkPerm(current_user, "DELETE_THREAD") %}
|
||||
<a href="{{ url_for('threads.delete_thread', id=thread.id) }}" class="float-right mr-2 btn btn-danger">{{ _('Delete') }}</a>
|
||||
{% endif %}
|
||||
{% if thread and thread.checkPerm(current_user, "LOCK_THREAD") %}
|
||||
{% if thread.locked %}
|
||||
<form method="post" action="{{ url_for('threads.set_lock', id=thread.id, lock=0) }}" class="float-right mr-2">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
||||
<input type="submit" class="btn btn-secondary" value="{{ _('Unlock') }}" />
|
||||
<input type="submit" class="btn btn-secondary" value="{{ _('Unlock Thread') }}" />
|
||||
</form>
|
||||
{% else %}
|
||||
<form method="post" action="{{ url_for('threads.set_lock', id=thread.id, lock=1) }}" class="float-right mr-2">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
||||
<input type="submit" class="btn btn-secondary" value="{{ _('Lock') }}" />
|
||||
<input type="submit" class="btn btn-secondary" value="{{ _('Lock Thread') }}" />
|
||||
</form>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
Loading…
Reference in New Issue
Block a user