mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 06:22:24 +01:00
parent
c19f93e36d
commit
05444e8018
@ -147,6 +147,10 @@ class PackagePropertyKey(enum.Enum):
|
|||||||
issueTracker = "Issue Tracker"
|
issueTracker = "Issue Tracker"
|
||||||
forums = "Forum Topic ID"
|
forums = "Forum Topic ID"
|
||||||
|
|
||||||
|
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)
|
||||||
|
)
|
||||||
|
|
||||||
class Package(db.Model):
|
class Package(db.Model):
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
@ -167,7 +171,10 @@ class Package(db.Model):
|
|||||||
issueTracker = db.Column(db.String(200), nullable=True)
|
issueTracker = db.Column(db.String(200), nullable=True)
|
||||||
forums = db.Column(db.Integer, nullable=False)
|
forums = db.Column(db.Integer, nullable=False)
|
||||||
|
|
||||||
# Releases
|
|
||||||
|
tags = db.relationship('Tag', secondary=tags, lazy='subquery',
|
||||||
|
backref=db.backref('packages', lazy=True))
|
||||||
|
|
||||||
releases = db.relationship("PackageRelease", backref="package",
|
releases = db.relationship("PackageRelease", backref="package",
|
||||||
lazy="dynamic", order_by=db.desc("package_release_releaseDate"))
|
lazy="dynamic", order_by=db.desc("package_release_releaseDate"))
|
||||||
|
|
||||||
@ -266,6 +273,22 @@ class Package(db.Model):
|
|||||||
else:
|
else:
|
||||||
raise Exception("Permission {} is not related to packages".format(perm.name))
|
raise Exception("Permission {} is not related to packages".format(perm.name))
|
||||||
|
|
||||||
|
class Tag(db.Model):
|
||||||
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
title = db.Column(db.String(100), nullable=False)
|
||||||
|
backgroundColor = db.Column(db.String(6), nullable=False)
|
||||||
|
textColor = db.Column(db.String(6), nullable=False)
|
||||||
|
|
||||||
|
def __init__(self, title, backgroundColor="000000", textColor="ffffff"):
|
||||||
|
self.title = title
|
||||||
|
self.backgroundColor = backgroundColor
|
||||||
|
self.textColor = textColor
|
||||||
|
|
||||||
|
def getName(self):
|
||||||
|
import re
|
||||||
|
regex = re.compile('[^a-z_]')
|
||||||
|
return regex.sub("", self.title.lower().replace(" ", "_"))
|
||||||
|
|
||||||
class PackageRelease(db.Model):
|
class PackageRelease(db.Model):
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
|
||||||
|
@ -19,4 +19,18 @@
|
|||||||
<li><i>No packages available</i></ul>
|
<li><i>No packages available</i></ul>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<h3>Tags</h3>
|
||||||
|
<div class="box box_grey alert alert-warning">
|
||||||
|
Filtering by tag doesn't actually work yet!
|
||||||
|
</div>
|
||||||
|
<ul>
|
||||||
|
{% for t in tags %}
|
||||||
|
<li><a href="{{ url_for('packages_page', q=(query or '')+' tag:'+t.getName()) }}">
|
||||||
|
{{ t.title }}
|
||||||
|
</a></li>
|
||||||
|
{% else %}
|
||||||
|
<li><i>No tags available</i></ul>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -98,6 +98,15 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<h3>Tags</h3>
|
||||||
|
<ul>
|
||||||
|
{% for t in package.tags %}
|
||||||
|
<li>{{ t.title }}</li>
|
||||||
|
{% else %}
|
||||||
|
<li>No tags.</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
{% if current_user.is_authenticated or requests %}
|
{% if current_user.is_authenticated or requests %}
|
||||||
<h3>Edit Requests</h3>
|
<h3>Edit Requests</h3>
|
||||||
|
|
||||||
|
@ -29,7 +29,8 @@ def doPackageList(type):
|
|||||||
if shouldReturnJson():
|
if shouldReturnJson():
|
||||||
return jsonify([package.getAsDictionary(app.config["BASE_URL"]) for package in query.all()])
|
return jsonify([package.getAsDictionary(app.config["BASE_URL"]) for package in query.all()])
|
||||||
else:
|
else:
|
||||||
return render_template("packages/list.html", title=title, packages=query.all(), query=search)
|
tags = Tag.query.all()
|
||||||
|
return render_template("packages/list.html", title=title, packages=query.all(), query=search, tags=tags)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/packages/")
|
@app.route("/packages/")
|
||||||
|
16
setup.py
16
setup.py
@ -34,12 +34,23 @@ if not os.path.isfile("db.sqlite"):
|
|||||||
sam.rank = UserRank.EDITOR
|
sam.rank = UserRank.EDITOR
|
||||||
db.session.add(sam)
|
db.session.add(sam)
|
||||||
|
|
||||||
|
tags = {}
|
||||||
|
for tag in ["Inventory", "Mapgen", "Building", \
|
||||||
|
"Animals, monsters and NPCs", "Tools", "Player effects", \
|
||||||
|
"Environment", "Transport", "Maintenance", "Plants and farming", \
|
||||||
|
"Player vs Player", "Survival", "Creative", "Puzzle", "Multiplayer focused"]:
|
||||||
|
row = Tag(tag)
|
||||||
|
tags[row.getName()] = row
|
||||||
|
db.session.add(row)
|
||||||
|
|
||||||
|
|
||||||
mod1 = Package()
|
mod1 = Package()
|
||||||
mod1.approved = True
|
mod1.approved = True
|
||||||
mod1.name = "awards"
|
mod1.name = "awards"
|
||||||
mod1.title = "Awards"
|
mod1.title = "Awards"
|
||||||
mod1.type = PackageType.MOD
|
mod1.type = PackageType.MOD
|
||||||
mod1.author = ruben
|
mod1.author = ruben
|
||||||
|
mod1.tags.append(tags["player_effects"])
|
||||||
mod1.repo = "https://github.com/rubenwardy/awards"
|
mod1.repo = "https://github.com/rubenwardy/awards"
|
||||||
mod1.issueTracker = "https://github.com/rubenwardy/awards/issues"
|
mod1.issueTracker = "https://github.com/rubenwardy/awards/issues"
|
||||||
mod1.forums = 4870
|
mod1.forums = 4870
|
||||||
@ -70,6 +81,7 @@ awards.register_achievement("award_mesefind",{
|
|||||||
mod2.approved = True
|
mod2.approved = True
|
||||||
mod2.name = "mesecons"
|
mod2.name = "mesecons"
|
||||||
mod2.title = "Mesecons"
|
mod2.title = "Mesecons"
|
||||||
|
mod2.tags.append(tags["tools"])
|
||||||
mod2.type = PackageType.MOD
|
mod2.type = PackageType.MOD
|
||||||
mod2.author = jeija
|
mod2.author = jeija
|
||||||
mod2.repo = "https://github.com/minetest-mods/mesecons/"
|
mod2.repo = "https://github.com/minetest-mods/mesecons/"
|
||||||
@ -169,6 +181,9 @@ No warranty is provided, express or implied, for any part of the project.
|
|||||||
game1.title = "Capture The Flag"
|
game1.title = "Capture The Flag"
|
||||||
game1.type = PackageType.GAME
|
game1.type = PackageType.GAME
|
||||||
game1.author = ruben
|
game1.author = ruben
|
||||||
|
game1.tags.append(tags["player_vs_player"])
|
||||||
|
game1.tags.append(tags["survival"])
|
||||||
|
game1.tags.append(tags["multiplayer_focused"])
|
||||||
game1.repo = "https://github.com/rubenwardy/capturetheflag"
|
game1.repo = "https://github.com/rubenwardy/capturetheflag"
|
||||||
game1.issueTracker = "https://github.com/rubenwardy/capturetheflag/issues"
|
game1.issueTracker = "https://github.com/rubenwardy/capturetheflag/issues"
|
||||||
game1.forums = 12835
|
game1.forums = 12835
|
||||||
@ -182,7 +197,6 @@ Uses the CTF PvP Engine.
|
|||||||
db.session.add(game1)
|
db.session.add(game1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
else:
|
else:
|
||||||
print("Database already exists")
|
print("Database already exists")
|
||||||
|
Loading…
Reference in New Issue
Block a user