mirror of
https://github.com/minetest/contentdb.git
synced 2024-11-09 17:13:45 +01:00
parent
f755c7d429
commit
e7acd7faa3
@ -186,7 +186,6 @@ class Notification(db.Model):
|
||||
class License(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String(50), nullable=False, unique=True)
|
||||
packages = db.relationship("Package", backref="license", lazy="dynamic")
|
||||
|
||||
def __init__(self, v):
|
||||
self.name = v
|
||||
@ -327,7 +326,10 @@ class Package(db.Model):
|
||||
type = db.Column(db.Enum(PackageType))
|
||||
created_at = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
|
||||
|
||||
license_id = db.Column(db.Integer, db.ForeignKey("license.id"))
|
||||
license_id = db.Column(db.Integer, db.ForeignKey("license.id"), nullable=False, default=1)
|
||||
license = db.relationship("License", foreign_keys=[license_id])
|
||||
media_license_id = db.Column(db.Integer, db.ForeignKey("license.id"), nullable=False, default=1)
|
||||
media_license = db.relationship("License", foreign_keys=[media_license_id])
|
||||
|
||||
approved = db.Column(db.Boolean, nullable=False, default=False)
|
||||
soft_deleted = db.Column(db.Boolean, nullable=False, default=False)
|
||||
|
@ -57,6 +57,7 @@
|
||||
{{ render_field(form.desc, class_="pkg_meta") }}
|
||||
{{ render_multiselect_field(form.tags, class_="pkg_meta") }}
|
||||
{{ render_field(form.license, class_="pkg_meta") }}
|
||||
{{ render_field(form.media_license, class_="pkg_meta") }}
|
||||
|
||||
<div class="pkg_meta">
|
||||
<h2 class="not_txp">Dependency Info</h2>
|
||||
|
@ -92,7 +92,14 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td>License</td>
|
||||
<td>{{ package.license.name }}</td>
|
||||
<td>
|
||||
{% if package.license != package.media_license %}
|
||||
{{ package.license.name }} for code,<br />
|
||||
{{ package.media_license.name }} for media.
|
||||
{% else %}
|
||||
{{ package.license.name }}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Added</td>
|
||||
|
@ -116,6 +116,7 @@ class PackageForm(FlaskForm):
|
||||
desc = TextAreaField("Long Description (Markdown)", [Optional(), Length(0,10000)])
|
||||
type = SelectField("Type", [InputRequired()], choices=PackageType.choices(), coerce=PackageType.coerce, default=PackageType.MOD)
|
||||
license = QuerySelectField("License", [InputRequired()], query_factory=lambda: License.query, get_pk=lambda a: a.id, get_label=lambda a: a.name)
|
||||
media_license = QuerySelectField("Media License", [InputRequired()], query_factory=lambda: License.query, get_pk=lambda a: a.id, get_label=lambda a: a.name)
|
||||
provides_str = StringField("Provides (mods included in package)", [Optional(), Length(0,1000)])
|
||||
tags = QuerySelectMultipleField('Tags', query_factory=lambda: Tag.query.order_by(db.asc(Tag.name)), get_pk=lambda a: a.id, get_label=lambda a: a.title)
|
||||
harddep_str = StringField("Hard Dependencies", [Optional(), Length(0,1000)])
|
||||
|
35
migrations/versions/aa6d7b595a94_.py
Normal file
35
migrations/versions/aa6d7b595a94_.py
Normal file
@ -0,0 +1,35 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: aa6d7b595a94
|
||||
Revises: aa6d21889d22
|
||||
Create Date: 2018-05-29 20:09:56.647358
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'aa6d7b595a94'
|
||||
down_revision = 'aa6d21889d22'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('package', sa.Column('media_license_id', sa.Integer()))
|
||||
op.execute('UPDATE package SET media_license_id=license_id')
|
||||
op.alter_column('package', 'media_license_id', nullable=False)
|
||||
op.alter_column('package', 'license_id', existing_type=sa.INTEGER(), nullable=False)
|
||||
op.create_foreign_key(None, 'package', 'license', ['media_license_id'], ['id'])
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('package', 'license_id',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=True)
|
||||
op.drop_column('package', 'media_license_id')
|
||||
# ### end Alembic commands ###
|
Loading…
Reference in New Issue
Block a user