Fix some untranslatable text
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
import re
|
||||
import validators
|
||||
from flask_babel import lazy_gettext
|
||||
|
||||
from app.logic.LogicError import LogicError
|
||||
from app.models import User, Package, PackageType, MetaPackage, Tag, ContentWarning, db, Permission, AuditSeverity, \
|
||||
@@ -35,7 +36,7 @@ def get_license(name):
|
||||
|
||||
license = License.query.filter(License.name.ilike(name)).first()
|
||||
if license is None:
|
||||
raise LogicError(400, "Unknown license: " + name)
|
||||
raise LogicError(400, "Unknown license " + name)
|
||||
return license
|
||||
|
||||
|
||||
@@ -89,7 +90,7 @@ def validate(data: dict):
|
||||
name = data["name"]
|
||||
check(isinstance(name, str), "Name must be a string")
|
||||
check(bool(name_re.match(name)),
|
||||
"Name can only contain lower case letters (a-z), digits (0-9), and underscores (_)")
|
||||
lazy_gettext("Name can only contain lower case letters (a-z), digits (0-9), and underscores (_)"))
|
||||
|
||||
for key in ["repo", "website", "issue_tracker", "issueTracker"]:
|
||||
value = data.get(key)
|
||||
@@ -103,11 +104,11 @@ def validate(data: dict):
|
||||
def do_edit_package(user: User, package: Package, was_new: bool, was_web: bool, data: dict,
|
||||
reason: str = None):
|
||||
if not package.checkPerm(user, Permission.EDIT_PACKAGE):
|
||||
raise LogicError(403, "You do not have permission to edit this package")
|
||||
raise LogicError(403, lazy_gettext("You do not have permission to edit this package"))
|
||||
|
||||
if "name" in data and package.name != data["name"] and \
|
||||
not package.checkPerm(user, Permission.CHANGE_NAME):
|
||||
raise LogicError(403, "You do not have permission to change the package name")
|
||||
raise LogicError(403, lazy_gettext("You do not have permission to change the package name"))
|
||||
|
||||
for alias, to in ALIASES.items():
|
||||
if alias in data:
|
||||
@@ -154,7 +155,7 @@ def do_edit_package(user: User, package: Package, was_new: bool, was_web: bool,
|
||||
break
|
||||
|
||||
if tag.is_protected and tag not in old_tags and not user.rank.atLeast(UserRank.EDITOR):
|
||||
raise LogicError(400, f"Unable to add protected tag {tag.title} to package")
|
||||
raise LogicError(400, lazy_gettext("Unable to add protected tag {tag.title} to package"))
|
||||
|
||||
package.tags.append(tag)
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
import datetime, re
|
||||
|
||||
from celery import uuid
|
||||
from flask_babel import lazy_gettext
|
||||
|
||||
from app.logic.LogicError import LogicError
|
||||
from app.logic.uploads import upload_file
|
||||
@@ -28,12 +29,12 @@ from app.utils import AuditSeverity, addAuditLog, nonEmptyOrNone
|
||||
|
||||
def check_can_create_release(user: User, package: Package):
|
||||
if not package.checkPerm(user, Permission.MAKE_RELEASE):
|
||||
raise LogicError(403, "You do not have permission to make releases")
|
||||
raise LogicError(403, lazy_gettext("You do not have permission to make releases"))
|
||||
|
||||
five_minutes_ago = datetime.datetime.now() - datetime.timedelta(minutes=5)
|
||||
count = package.releases.filter(PackageRelease.releaseDate > five_minutes_ago).count()
|
||||
if count >= 5:
|
||||
raise LogicError(429, "You've created too many releases for this package in the last 5 minutes, please wait before trying again")
|
||||
raise LogicError(429, lazy_gettext("You've created too many releases for this package in the last 5 minutes, please wait before trying again"))
|
||||
|
||||
|
||||
def do_create_vcs_release(user: User, package: Package, title: str, ref: str,
|
||||
@@ -70,7 +71,7 @@ def do_create_zip_release(user: User, package: Package, title: str, file,
|
||||
if commit_hash:
|
||||
commit_hash = commit_hash.lower()
|
||||
if not (len(commit_hash) == 40 and re.match(r"^[0-9a-f]+$", commit_hash)):
|
||||
raise LogicError(400, "Invalid commit hash; it must be a 40 character long base16 string")
|
||||
raise LogicError(400, lazy_gettext("Invalid commit hash; it must be a 40 character long base16 string"))
|
||||
|
||||
uploaded_url, uploaded_path = upload_file(file, "zip", "a zip file")
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@ def do_create_screenshot(user: User, package: Package, title: str, file, reason:
|
||||
thirty_minutes_ago = datetime.datetime.now() - datetime.timedelta(minutes=30)
|
||||
count = package.screenshots.filter(PackageScreenshot.created_at > thirty_minutes_ago).count()
|
||||
if count >= 20:
|
||||
raise LogicError(429, "Too many requests, please wait before trying again")
|
||||
raise LogicError(429, lazy_gettext("Too many requests, please wait before trying again"))
|
||||
|
||||
uploaded_url, uploaded_path = upload_file(file, "image", "a PNG or JPG image file")
|
||||
uploaded_url, uploaded_path = upload_file(file, "image", lazy_gettext("a PNG or JPG image file"))
|
||||
|
||||
counter = 1
|
||||
for screenshot in package.screenshots.all():
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
import imghdr
|
||||
import os
|
||||
|
||||
from flask_babel import lazy_gettext
|
||||
|
||||
from app.logic.LogicError import LogicError
|
||||
from app.models import *
|
||||
from app.utils import randomString
|
||||
@@ -47,10 +49,10 @@ def upload_file(file, fileType, fileTypeDesc):
|
||||
|
||||
ext = get_extension(file.filename)
|
||||
if ext is None or not ext in allowedExtensions:
|
||||
raise LogicError(400, "Please upload " + fileTypeDesc)
|
||||
raise LogicError(400, lazy_gettext("Please upload %(file_desc)s", file_desc=fileTypeDesc))
|
||||
|
||||
if isImage and not isAllowedImage(file.stream.read()):
|
||||
raise LogicError(400, "Uploaded image isn't actually an image")
|
||||
raise LogicError(400, lazy_gettext("Uploaded image isn't actually an image"))
|
||||
|
||||
file.stream.seek(0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user