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/>.
|
|
|
|
|
2019-11-16 00:51:42 +01:00
|
|
|
from flask import Blueprint
|
2022-01-07 23:11:12 +01:00
|
|
|
from flask_babel import gettext
|
2019-11-16 00:51:42 +01:00
|
|
|
|
2022-06-25 01:32:32 +02:00
|
|
|
from app.models import User, Package, Permission, PackageType
|
2021-05-04 04:15:26 +02:00
|
|
|
|
2019-11-16 00:51:42 +01: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):
|
2023-06-18 22:56:19 +02:00
|
|
|
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"),
|
2023-06-18 22:56:19 +02:00
|
|
|
"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"),
|
2023-06-18 22:56:19 +02:00
|
|
|
"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"),
|
2023-06-18 22:56:19 +02:00
|
|
|
"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"),
|
2023-06-18 22:56:19 +02:00
|
|
|
"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"),
|
2023-06-18 22:56:19 +02:00
|
|
|
"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"),
|
2023-06-18 22:56:19 +02:00
|
|
|
"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"),
|
2023-06-18 22:56:19 +02:00
|
|
|
"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"),
|
2023-06-18 22:56:19 +02:00
|
|
|
"url": package.get_url("packages.remove")
|
2021-05-04 04:15:26 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2023-01-12 22:10:58 +01: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"),
|
2023-06-18 22:56:19 +02:00
|
|
|
"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
|
|
|
|
2024-06-11 22:24:39 +02:00
|
|
|
from . import packages, advanced_search, screenshots, releases, reviews, game_hub
|