mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 06:22:24 +01:00
parent
28d967e3e2
commit
743d1d909f
@ -142,11 +142,18 @@ class PackagePropertyKey(enum.Enum):
|
||||
shortDesc = "Short Description"
|
||||
desc = "Description"
|
||||
type = "Type"
|
||||
tags = "Tags"
|
||||
repo = "Repository"
|
||||
website = "Website"
|
||||
issueTracker = "Issue Tracker"
|
||||
forums = "Forum Topic ID"
|
||||
|
||||
def convert(self, value):
|
||||
if self == PackagePropertyKey.tags:
|
||||
return ','.join([t.title for t in value])
|
||||
else:
|
||||
return str(value)
|
||||
|
||||
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)
|
||||
@ -370,6 +377,12 @@ class EditRequestChange(db.Model):
|
||||
newValue = db.Column(db.Text, nullable=True)
|
||||
|
||||
def apply(self, package):
|
||||
if self.key == PackagePropertyKey.tags:
|
||||
package.tags.clear()
|
||||
for tagTitle in self.newValue.split(","):
|
||||
tag = Tag.query.filter_by(title=tagTitle.strip()).first()
|
||||
package.tags.append(tag)
|
||||
else:
|
||||
setattr(package, self.key.name, self.newValue)
|
||||
|
||||
# Setup Flask-User
|
||||
|
@ -14,6 +14,7 @@
|
||||
{{ render_field(form.shortDesc) }}
|
||||
{{ render_field(form.desc) }}
|
||||
{{ render_field(form.type) }}
|
||||
{{ render_field(form.tags) }}
|
||||
{{ render_field(form.repo) }}
|
||||
{{ render_field(form.website) }}
|
||||
{{ render_field(form.issueTracker) }}
|
||||
|
@ -265,8 +265,8 @@ def create_editrequest_page(ptype, author, name):
|
||||
change = EditRequestChange()
|
||||
change.request = erequest
|
||||
change.key = e
|
||||
change.oldValue = str(oldValue)
|
||||
change.newValue = str(newValue)
|
||||
change.oldValue = e.convert(oldValue)
|
||||
change.newValue = e.convert(newValue)
|
||||
db.session.add(change)
|
||||
wasChangeMade = True
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user