contentdb/app/blueprints/packages/__init__.py

88 lines
2.3 KiB
Python
Raw Normal View History

2020-07-12 17:34:25 +02:00
# ContentDB
2021-01-30 17:59:42 +01:00
# Copyright (C) 2018-21 rubenwardy
2018-05-25 18:28:32 +02:00
#
# This program is free software: you can redistribute it and/or modify
2021-01-30 17:59:42 +01:00
# it under the terms of the GNU Affero General Public License as published by
2018-05-25 18:28:32 +02:00
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2021-01-30 17:59:42 +01:00
# GNU Affero General Public License for more details.
2018-05-25 18:28:32 +02:00
#
2021-01-30 17:59:42 +01:00
# You should have received a copy of the GNU Affero General Public License
2018-05-25 18:28:32 +02:00
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from flask import Blueprint
2022-01-07 23:11:12 +01:00
from flask_babel import gettext
2022-06-25 01:32:32 +02:00
from app.models import User, Package, Permission, PackageType
2021-05-04 04:15:26 +02:00
bp = Blueprint("packages", __name__)
2018-05-25 18:28:32 +02:00
2021-05-04 04:15:26 +02:00
def get_package_tabs(user: User, package: Package):
if package is None or not package.check_perm(user, Permission.EDIT_PACKAGE):
2021-05-04 04:15:26 +02:00
return []
2022-06-25 01:32:32 +02:00
retval = [
2021-05-04 04:15:26 +02:00
{
"id": "edit",
2022-01-07 23:11:12 +01:00
"title": gettext("Edit Details"),
"url": package.get_url("packages.create_edit")
2021-05-04 04:15:26 +02:00
},
2024-02-25 18:50:33 +01:00
{
"id": "translation",
"title": gettext("Translation"),
"url": package.get_url("packages.translation")
},
2021-05-04 04:15:26 +02:00
{
"id": "releases",
2022-01-07 23:11:12 +01:00
"title": gettext("Releases"),
"url": package.get_url("packages.list_releases")
2021-05-04 04:15:26 +02:00
},
{
"id": "screenshots",
2022-01-07 23:11:12 +01:00
"title": gettext("Screenshots"),
"url": package.get_url("packages.screenshots")
2021-05-04 04:15:26 +02:00
},
{
"id": "maintainers",
2022-01-07 23:11:12 +01:00
"title": gettext("Maintainers"),
"url": package.get_url("packages.edit_maintainers")
2021-05-04 04:15:26 +02:00
},
2021-07-24 04:56:43 +02:00
{
"id": "audit",
2022-01-07 23:11:12 +01:00
"title": gettext("Audit Log"),
"url": package.get_url("packages.audit")
2021-07-24 04:56:43 +02:00
},
2022-11-06 18:58:35 +01:00
{
"id": "stats",
"title": gettext("Statistics"),
"url": package.get_url("packages.statistics")
2022-11-06 18:58:35 +01:00
},
2021-07-24 04:56:43 +02:00
{
"id": "share",
2022-01-07 23:11:12 +01:00
"title": gettext("Share and Badges"),
"url": package.get_url("packages.share")
2021-07-24 04:56:43 +02:00
},
2021-05-04 04:15:26 +02:00
{
"id": "remove",
2023-10-15 23:16:05 +02:00
"title": gettext("Remove / Unpublish"),
"url": package.get_url("packages.remove")
2021-05-04 04:15:26 +02:00
}
]
if package.type == PackageType.MOD or package.type == PackageType.TXP:
2024-02-25 18:50:33 +01:00
retval.insert(2, {
2022-06-25 01:32:32 +02:00
"id": "game_support",
"title": gettext("Supported Games"),
"url": package.get_url("packages.game_support")
2022-06-25 01:32:32 +02:00
})
return retval
2021-05-04 04:15:26 +02:00
2022-02-01 22:22:28 +01:00
from . import packages, screenshots, releases, reviews, game_hub