mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 14:02:24 +01:00
Add min and max Minetest version support
This commit is contained in:
parent
e9fe936aa9
commit
d77403c0be
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,4 @@
|
|||||||
config.cfg
|
config.cfg
|
||||||
config.prod.cfg
|
|
||||||
*.env
|
*.env
|
||||||
*.sqlite
|
*.sqlite
|
||||||
custom.css
|
custom.css
|
||||||
|
@ -8,9 +8,10 @@ RUN pip install gunicorn
|
|||||||
RUN pip install psycopg2
|
RUN pip install psycopg2
|
||||||
|
|
||||||
COPY runprodguni.sh ./
|
COPY runprodguni.sh ./
|
||||||
|
COPY rundebug.sh ./
|
||||||
RUN chmod +x runprodguni.sh
|
RUN chmod +x runprodguni.sh
|
||||||
|
|
||||||
COPY setup.py ./setup.py
|
COPY setup.py ./setup.py
|
||||||
COPY app app
|
COPY app app
|
||||||
COPY migrations migrations
|
COPY migrations migrations
|
||||||
COPY config.prod.cfg ./config.prod.cfg
|
COPY config.cfg ./config.cfg
|
||||||
|
@ -21,4 +21,7 @@ FLASK_CONFIG=../config.cfg FLASK_APP=app/__init__.py flask db migrate
|
|||||||
|
|
||||||
# Run migration
|
# Run migration
|
||||||
FLASK_CONFIG=../config.cfg FLASK_APP=app/__init__.py flask db upgrade
|
FLASK_CONFIG=../config.cfg FLASK_APP=app/__init__.py flask db upgrade
|
||||||
|
|
||||||
|
# Enter docker
|
||||||
|
docker exec -it contentdb_app_1 bash
|
||||||
```
|
```
|
||||||
|
@ -612,6 +612,18 @@ class Tag(db.Model):
|
|||||||
regex = re.compile("[^a-z_]")
|
regex = re.compile("[^a-z_]")
|
||||||
self.name = regex.sub("", self.title.lower().replace(" ", "_"))
|
self.name = regex.sub("", self.title.lower().replace(" ", "_"))
|
||||||
|
|
||||||
|
|
||||||
|
class MinetestRelease(db.Model):
|
||||||
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
name = db.Column(db.String(100), unique=True, nullable=False)
|
||||||
|
|
||||||
|
def __init__(self, name=None):
|
||||||
|
self.name = name
|
||||||
|
|
||||||
|
def getActual(self):
|
||||||
|
return None if self.name == "None" else self
|
||||||
|
|
||||||
|
|
||||||
class PackageRelease(db.Model):
|
class PackageRelease(db.Model):
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
|
||||||
@ -623,6 +635,12 @@ class PackageRelease(db.Model):
|
|||||||
task_id = db.Column(db.String(37), nullable=True)
|
task_id = db.Column(db.String(37), nullable=True)
|
||||||
commit_hash = db.Column(db.String(41), nullable=True, default=None)
|
commit_hash = db.Column(db.String(41), nullable=True, default=None)
|
||||||
|
|
||||||
|
min_rel_id = db.Column(db.Integer, db.ForeignKey("minetest_release.id"), nullable=True, server_default=None)
|
||||||
|
min_rel = db.relationship("MinetestRelease", foreign_keys=[min_rel_id])
|
||||||
|
|
||||||
|
max_rel_id = db.Column(db.Integer, db.ForeignKey("minetest_release.id"), nullable=True, server_default=None)
|
||||||
|
max_rel = db.relationship("MinetestRelease", foreign_keys=[max_rel_id])
|
||||||
|
|
||||||
|
|
||||||
def getEditURL(self):
|
def getEditURL(self):
|
||||||
return url_for("edit_release_page",
|
return url_for("edit_release_page",
|
||||||
|
@ -39,6 +39,11 @@
|
|||||||
Approved: {{ release.approved }}
|
Approved: {{ release.approved }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
{{ render_field(form.min_rel, class_="col-sm-6") }}
|
||||||
|
{{ render_field(form.max_rel, class_="col-sm-6") }}
|
||||||
|
</div>
|
||||||
|
|
||||||
{{ render_submit_field(form.submit) }}
|
{{ render_submit_field(form.submit) }}
|
||||||
</form>
|
</form>
|
||||||
|
@ -18,6 +18,12 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{{ render_field(form.fileUpload, fieldclass="form-control-file") }}
|
{{ render_field(form.fileUpload, fieldclass="form-control-file") }}
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
{{ render_field(form.min_rel, class_="col-sm-6") }}
|
||||||
|
{{ render_field(form.max_rel, class_="col-sm-6") }}
|
||||||
|
</div>
|
||||||
|
|
||||||
{{ render_submit_field(form.submit) }}
|
{{ render_submit_field(form.submit) }}
|
||||||
</form>
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -27,12 +27,18 @@ from celery import uuid
|
|||||||
from flask_wtf import FlaskForm
|
from flask_wtf import FlaskForm
|
||||||
from wtforms import *
|
from wtforms import *
|
||||||
from wtforms.validators import *
|
from wtforms.validators import *
|
||||||
|
from wtforms.ext.sqlalchemy.fields import QuerySelectField
|
||||||
|
|
||||||
|
|
||||||
class CreatePackageReleaseForm(FlaskForm):
|
class CreatePackageReleaseForm(FlaskForm):
|
||||||
title = StringField("Title", [InputRequired(), Length(1, 30)])
|
title = StringField("Title", [InputRequired(), Length(1, 30)])
|
||||||
uploadOpt = RadioField ("Method", choices=[("upload", "File Upload")], default="upload")
|
uploadOpt = RadioField ("Method", choices=[("upload", "File Upload")], default="upload")
|
||||||
vcsLabel = StringField("VCS Commit or Branch", default="master")
|
vcsLabel = StringField("VCS Commit or Branch", default="master")
|
||||||
fileUpload = FileField("File Upload")
|
fileUpload = FileField("File Upload")
|
||||||
|
min_rel = QuerySelectField("Minimum Minetest Version", [InputRequired()],
|
||||||
|
query_factory=lambda: MinetestRelease.query.order_by(db.asc(MinetestRelease.id)), get_pk=lambda a: a.id, get_label=lambda a: a.name)
|
||||||
|
max_rel = QuerySelectField("Maximum Minetest Version", [InputRequired()],
|
||||||
|
query_factory=lambda: MinetestRelease.query.order_by(db.asc(MinetestRelease.id)), get_pk=lambda a: a.id, get_label=lambda a: a.name)
|
||||||
submit = SubmitField("Save")
|
submit = SubmitField("Save")
|
||||||
|
|
||||||
class EditPackageReleaseForm(FlaskForm):
|
class EditPackageReleaseForm(FlaskForm):
|
||||||
@ -40,6 +46,10 @@ class EditPackageReleaseForm(FlaskForm):
|
|||||||
url = StringField("URL", [URL])
|
url = StringField("URL", [URL])
|
||||||
task_id = StringField("Task ID")
|
task_id = StringField("Task ID")
|
||||||
approved = BooleanField("Is Approved")
|
approved = BooleanField("Is Approved")
|
||||||
|
min_rel = QuerySelectField("Minimum Minetest Version", [InputRequired()],
|
||||||
|
query_factory=lambda: MinetestRelease.query.order_by(db.asc(MinetestRelease.id)), get_pk=lambda a: a.id, get_label=lambda a: a.name)
|
||||||
|
max_rel = QuerySelectField("Maximum Minetest Version", [InputRequired()],
|
||||||
|
query_factory=lambda: MinetestRelease.query.order_by(db.asc(MinetestRelease.id)), get_pk=lambda a: a.id, get_label=lambda a: a.name)
|
||||||
submit = SubmitField("Save")
|
submit = SubmitField("Save")
|
||||||
|
|
||||||
@app.route("/packages/<author>/<name>/releases/new/", methods=["GET", "POST"])
|
@app.route("/packages/<author>/<name>/releases/new/", methods=["GET", "POST"])
|
||||||
@ -63,6 +73,8 @@ def create_release_page(package):
|
|||||||
rel.title = form["title"].data
|
rel.title = form["title"].data
|
||||||
rel.url = ""
|
rel.url = ""
|
||||||
rel.task_id = uuid()
|
rel.task_id = uuid()
|
||||||
|
rel.min_rel = form["min_rel"].data.getActual()
|
||||||
|
rel.max_rel = form["max_rel"].data.getActual()
|
||||||
db.session.add(rel)
|
db.session.add(rel)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
@ -80,6 +92,8 @@ def create_release_page(package):
|
|||||||
rel.package = package
|
rel.package = package
|
||||||
rel.title = form["title"].data
|
rel.title = form["title"].data
|
||||||
rel.url = uploadedPath
|
rel.url = uploadedPath
|
||||||
|
rel.min_rel = form["min_rel"].data.getActual()
|
||||||
|
rel.max_rel = form["max_rel"].data.getActual()
|
||||||
db.session.add(rel)
|
db.session.add(rel)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
@ -128,6 +142,8 @@ def edit_release_page(package, id):
|
|||||||
wasApproved = release.approved
|
wasApproved = release.approved
|
||||||
if canEdit:
|
if canEdit:
|
||||||
release.title = form["title"].data
|
release.title = form["title"].data
|
||||||
|
release.min_rel = form["min_rel"].data.getActual()
|
||||||
|
release.max_rel = form["max_rel"].data.getActual()
|
||||||
|
|
||||||
if package.checkPerm(current_user, Permission.CHANGE_RELEASE_URL):
|
if package.checkPerm(current_user, Permission.CHANGE_RELEASE_URL):
|
||||||
release.url = form["url"].data
|
release.url = form["url"].data
|
||||||
|
@ -15,12 +15,13 @@ services:
|
|||||||
|
|
||||||
app:
|
app:
|
||||||
build: .
|
build: .
|
||||||
command: ./runprodguni.sh
|
command: ./rundebug.sh
|
||||||
ports:
|
ports:
|
||||||
- 5123:5123
|
- 5123:5123
|
||||||
volumes:
|
volumes:
|
||||||
- "./data/uploads:/home/cdb/app/public/uploads"
|
- "./data/uploads:/home/cdb/app/public/uploads"
|
||||||
- "./app:/home/cdb/app"
|
- "./app:/home/cdb/app"
|
||||||
|
- "./migrations:/home/cdb/migrations"
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
- redis
|
- redis
|
||||||
|
41
migrations/versions/7def3e843d04_.py
Normal file
41
migrations/versions/7def3e843d04_.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: 7def3e843d04
|
||||||
|
Revises: dce69ad1e4eb
|
||||||
|
Create Date: 2019-01-28 20:27:33.760232
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.dialects import postgresql
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '7def3e843d04'
|
||||||
|
down_revision = 'dce69ad1e4eb'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.create_table('minetest_release',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('name', sa.String(length=100), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id'),
|
||||||
|
sa.UniqueConstraint('name')
|
||||||
|
)
|
||||||
|
op.add_column('package_release', sa.Column('max_rel_id', sa.Integer(), nullable=True, server_default=None))
|
||||||
|
op.add_column('package_release', sa.Column('min_rel_id', sa.Integer(), nullable=True, server_default=None))
|
||||||
|
op.create_foreign_key(None, 'package_release', 'minetest_release', ['max_rel_id'], ['id'])
|
||||||
|
op.create_foreign_key(None, 'package_release', 'minetest_release', ['min_rel_id'], ['id'])
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_constraint(None, 'package_release', type_='foreignkey')
|
||||||
|
op.drop_constraint(None, 'package_release', type_='foreignkey')
|
||||||
|
op.drop_column('package_release', 'min_rel_id')
|
||||||
|
op.drop_column('package_release', 'max_rel_id')
|
||||||
|
op.drop_table('minetest_release')
|
||||||
|
# ### end Alembic commands ###
|
@ -1,3 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
FLASK_APP=app/__init__.py FLASK_CONFIG=../config.cfg FLASK_DEBUG=1 python3 -m flask run
|
FLASK_APP=app/__init__.py FLASK_CONFIG=../config.cfg FLASK_DEBUG=1 python3 -m flask run -h 0.0.0.0 -p 5123
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
FLASK_APP=app/__init__.py FLASK_CONFIG=../config.prod.cfg FLASK_DEBUG=0 python3 -m flask run -h 0.0.0.0 -p 5123
|
FLASK_APP=app/__init__.py FLASK_CONFIG=../config.cfg FLASK_DEBUG=0 python3 -m flask run -h 0.0.0.0 -p 5123
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
gunicorn -w 4 -b :5123 -e FLASK_APP=app/__init__.py -e FLASK_CONFIG=../config.prod.cfg -e FLASK_DEBUG=1 app:app
|
gunicorn -w 4 -b :5123 -e FLASK_APP=app/__init__.py -e FLASK_CONFIG=../config.cfg -e FLASK_DEBUG=0 app:app
|
||||||
|
Loading…
Reference in New Issue
Block a user