Add non-free warning

This commit is contained in:
rubenwardy 2018-05-29 21:24:50 +01:00
parent fa2f17526f
commit 1600687449
No known key found for this signature in database
GPG Key ID: A1E29D52FF81513C
6 changed files with 77 additions and 9 deletions

@ -184,11 +184,13 @@ class Notification(db.Model):
class License(db.Model): class License(db.Model):
id = db.Column(db.Integer, primary_key=True) id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(50), nullable=False, unique=True) name = db.Column(db.String(50), nullable=False, unique=True)
is_foss = db.Column(db.Boolean, nullable=False, default=True)
def __init__(self, v): def __init__(self, v, is_foss=True):
self.name = v self.name = v
self.is_foss = is_foss
def __str__(self): def __str__(self):
return self.name return self.name

@ -8,6 +8,21 @@
<p> <p>
{{ package.shortDesc }} {{ package.shortDesc }}
</p> </p>
{% if not package.license.is_foss and not package.media_license.is_foss and package.type != package.type.TXP %}
<p style="color:#f33;">
<b>Warning:</b> Non-free code and media.
</p>
{% elif not package.license.is_foss and package.type != package.type.TXP %}
<p style="color:#f33;">
<b>Warning:</b> Non-free code.
</p>
{% elif not package.media_license.is_foss %}
<p style="color:#f33;">
<b>Warning:</b> Non-free media.
</p>
{% endif %}
</div> </div>
</a></li> </a></li>
{% endmacro %} {% endmacro %}

@ -26,7 +26,9 @@
{{ render_field(form.shortDesc, class_="pkg_meta") }} {{ render_field(form.shortDesc, class_="pkg_meta") }}
{{ render_field(form.desc, class_="pkg_meta") }} {{ render_field(form.desc, class_="pkg_meta") }}
{{ render_multiselect_field(form.tags, class_="pkg_meta") }} {{ render_multiselect_field(form.tags, class_="pkg_meta") }}
{{ render_field(form.license, class_="pkg_meta") }} <div class="pkg_meta">
{{ render_field(form.license, class_="not_txp") }}
</div>
{{ render_field(form.media_license, class_="pkg_meta") }} {{ render_field(form.media_license, class_="pkg_meta") }}
<div class="pkg_meta"> <div class="pkg_meta">

@ -61,7 +61,21 @@
<aside class="asideright box box_grey"> <aside class="asideright box box_grey">
<h3>Details</h3> <h3>Details</h3>
<div class="box-body"> <div class="box-body">
{% if not package.license.is_foss and not package.media_license.is_foss and package.type != package.type.TXP %}
<div class="box box_grey alert alert-error" style="margin-top: 0;">
<b>Warning:</b> Non-free code and media.
</div>
{% elif not package.license.is_foss and package.type != package.type.TXP %}
<div class="box box_grey alert alert-error" style="margin-top: 0;">
<b>Warning:</b> Non-free code.
</div>
{% elif not package.media_license.is_foss %}
<div class="box box_grey alert alert-error" style="margin-top: 0;">
<b>Warning:</b> Non-free media.
</div>
{% endif %}
<table> <table>
<tr> <tr>
<td>Name</td> <td>Name</td>
@ -93,11 +107,13 @@
<tr> <tr>
<td>License</td> <td>License</td>
<td> <td>
{% if package.license != package.media_license %} {% if package.license == package.media_license %}
{{ package.license.name }}
{% elif package.type == package.type.TXP %}
{{ package.media_license.name }}
{% else %}
{{ package.license.name }} for code,<br /> {{ package.license.name }} for code,<br />
{{ package.media_license.name }} for media. {{ package.media_license.name }} for media.
{% else %}
{{ package.license.name }}
{% endif %} {% endif %}
</td> </td>
</tr> </tr>
@ -108,7 +124,7 @@
</table> </table>
<ul class="buttonset linedbuttonset"> <ul class="buttonset linedbuttonset">
{% if package.getDownloadRelease() %}<li><a href="{{ package.getDownloadURL() }}">Download</a></li>{% endif %} {% if package.getDownloadRelease() %}<li><a href="{{ package.getDownloadURL() }}" class="btn_green">Download</a></li>{% endif %}
{% if package.repo %}<li><a href="{{ package.repo }}">View Source</a></li>{% endif %} {% if package.repo %}<li><a href="{{ package.repo }}">View Source</a></li>{% endif %}
{% if package.forums %}<li><a href="https://forum.minetest.net/viewtopic.php?t={{ package.forums }}">Forums</a></li>{% endif %} {% if package.forums %}<li><a href="https://forum.minetest.net/viewtopic.php?t={{ package.forums }}">Forums</a></li>{% endif %}
{% if package.issueTracker %}<li><a href="{{ package.issueTracker }}">Issue Tracker</a></li>{% endif %} {% if package.issueTracker %}<li><a href="{{ package.issueTracker }}">Issue Tracker</a></li>{% endif %}

@ -0,0 +1,28 @@
"""empty message
Revision ID: d0bec9e5698e
Revises: aa6d7b595a94
Create Date: 2018-05-29 21:23:43.847738
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'd0bec9e5698e'
down_revision = 'aa6d7b595a94'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('license', sa.Column('is_foss', sa.Boolean(), nullable=False, server_default="true"))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('license', 'is_foss')
# ### end Alembic commands ###

@ -359,11 +359,16 @@ for tag in ["Inventory", "Mapgen", "Building", \
licenses = {} licenses = {}
for license in ["GPLv2.1", "GPLv3", "LGPLv2.1", "LGPLv3", "AGPLv2.1", "AGPLv3", for license in ["GPLv2.1", "GPLv3", "LGPLv2.1", "LGPLv3", "AGPLv2.1", "AGPLv3",
"Apache", "BSD 3-Clause", "BSD 2-Clause", "CC0", "CC-BY-SA", "Apache", "BSD 3-Clause", "BSD 2-Clause", "CC0", "CC-BY-SA",
"CC-BY", "CC-BY-NC-SA", "MIT", "ZLib"]: "CC-BY", "MIT", "ZLib"]:
row = License(license) row = License(license)
licenses[row.name] = row licenses[row.name] = row
db.session.add(row) db.session.add(row)
for license in ["CC-BY-NC-SA"]:
row = License(license, False)
licenses[row.name] = row
db.session.add(row)
if test_data: if test_data:
defineDummyData(licenses, tags, ruben) defineDummyData(licenses, tags, ruben)