mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-08 22:17:34 +01:00
Improve token form
This commit is contained in:
parent
2f66db5989
commit
64a897b52f
@ -79,7 +79,7 @@ def create_edit_token(username, id=None):
|
||||
access_token = session.pop("token_" + str(token.id), None)
|
||||
|
||||
form = CreateAPIToken(formdata=request.form, obj=token)
|
||||
form.package.query_factory = lambda: Package.query.filter_by(author=user).all()
|
||||
form.package.query_factory = lambda: user.maintained_packages.all()
|
||||
|
||||
if form.validate_on_submit():
|
||||
if is_new:
|
||||
|
@ -909,6 +909,14 @@ class PackageScreenshot(db.Model):
|
||||
def getThumbnailURL(self, level=2):
|
||||
return self.url.replace("/uploads/", "/thumbnails/{:d}/".format(level))
|
||||
|
||||
def getAsDictionary(self):
|
||||
return {
|
||||
"id": self.id,
|
||||
"title": self.title,
|
||||
"url": self.url,
|
||||
"approved": self.approved,
|
||||
}
|
||||
|
||||
|
||||
class PackageUpdateTrigger(enum.Enum):
|
||||
COMMIT = "New Commit"
|
||||
|
@ -167,9 +167,9 @@ class User(db.Model, UserMixin):
|
||||
audit_log_entries = db.relationship("AuditLogEntry", foreign_keys="AuditLogEntry.causer_id", back_populates="causer",
|
||||
order_by=desc("audit_log_entry_created_at"), lazy="dynamic")
|
||||
|
||||
maintained_packages = db.relationship("Package", lazy="dynamic", secondary="maintainers")
|
||||
maintained_packages = db.relationship("Package", lazy="dynamic", secondary="maintainers", order_by=db.asc("package_title"))
|
||||
|
||||
packages = db.relationship("Package", back_populates="author", lazy="dynamic")
|
||||
packages = db.relationship("Package", back_populates="author", lazy="dynamic", order_by=db.asc("package_title"))
|
||||
reviews = db.relationship("PackageReview", back_populates="author", order_by=db.desc("package_review_created_at"), cascade="all, delete, delete-orphan")
|
||||
tokens = db.relationship("APIToken", back_populates="owner", lazy="dynamic", cascade="all, delete, delete-orphan")
|
||||
threads = db.relationship("Thread", back_populates="author", lazy="dynamic", cascade="all, delete, delete-orphan")
|
||||
|
@ -47,8 +47,8 @@
|
||||
<form method="POST" action="" enctype="multipart/form-data">
|
||||
{{ form.hidden_tag() }}
|
||||
|
||||
{{ render_field(form.name, placeholder="Human readable") }}
|
||||
{{ render_field(form.package) }}
|
||||
{{ render_field(form.name, placeholder="Human readable", hint=_("Human-readable name to tell tokens apart.")) }}
|
||||
{{ render_field(form.package, hint=_("Recommended: Only allows token to interact with a particular package.")) }}
|
||||
|
||||
{{ render_submit_field(form.submit) }}
|
||||
</form>
|
||||
|
Loading…
Reference in New Issue
Block a user