diff --git a/Makefile b/Makefile index bf8faa8..cb137a5 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,7 @@ babel-update-po: venv/bin/pybabel extract -F babel.cfg -k lazy_gettext -o messages.pot app venv/bin/pybabel update -i messages.pot -d app/translations -babel-update-mo: +babel-update-mo: babel-update-po venv/bin/pybabel compile -d app/translations babel-translate-po: diff --git a/app/apis/file.py b/app/apis/file.py index 4b0a84b..cbe752b 100644 --- a/app/apis/file.py +++ b/app/apis/file.py @@ -156,7 +156,7 @@ def get(self, file: File): } """ if not self.current_user.can(file.project, ProjectPermission.ACCESS): - raise NoPermissionError(gettext("您没有权限移动文件")) + raise NoPermissionError(gettext("您没有此项目的访问权限")) query = self.get_query({}, FileGetSchema()) data = file.to_api() data["project_id"] = str(file.project.id) diff --git a/app/apis/role.py b/app/apis/role.py index 42540eb..485b598 100644 --- a/app/apis/role.py +++ b/app/apis/role.py @@ -1,15 +1,18 @@ +from typing import Union from app.core.responses import MoePagination from app.core.views import MoeAPIView from app.decorators.auth import token_required from app.decorators.url import fetch_group from app.exceptions import NoPermissionError +from app.models.team import Team +from app.models.project import Project from app.validators.role import RoleSchema class RoleListAPI(MoeAPIView): @token_required @fetch_group - def get(self, group): + def get(self, group: Union[Team, Project]): """ @api {get} /v1///roles 获取自定义角色 @apiVersion 1.0.0 @@ -71,7 +74,7 @@ def post(self, group): class RoleAPI(MoeAPIView): @token_required @fetch_group - def put(self, group, role_id): + def put(self, group: Union[Team, Project], role_id: str): """ @api {put} /v1///roles/ 修改自定义角色 @apiVersion 1.0.0 diff --git a/app/apis/urls.py b/app/apis/urls.py index 249200b..7d3951f 100644 --- a/app/apis/urls.py +++ b/app/apis/urls.py @@ -41,7 +41,8 @@ ProjectTargetOutputListAPI, ) from app.apis.project_set import ProjectSetAPI -from app.apis.role import RoleAPI, RoleListAPI + +# from app.apis.role import RoleAPI, RoleListAPI from app.apis.source import FileSourceListAPI, SourceAPI, SourceRankAPI from app.apis.team import ( TeamInsightProjectListAPI, @@ -386,16 +387,17 @@ methods=["PUT", "DELETE", "PATCH", "OPTIONS"], view_func=ApplicationAPI.as_view("application"), ) -group.add_url_rule( - "///roles", - methods=["GET", "POST", "OPTIONS"], - view_func=RoleListAPI.as_view("role_list"), -) -group.add_url_rule( - "///roles/", - methods=["PUT", "DELETE", "OPTIONS"], - view_func=RoleAPI.as_view("role"), -) +# disable custom role APIs for now +# group.add_url_rule( +# "///roles", +# methods=["GET", "POST", "OPTIONS"], +# view_func=RoleListAPI.as_view("role_list"), +# ) +# group.add_url_rule( +# "///roles/", +# methods=["PUT", "DELETE", "OPTIONS"], +# view_func=RoleAPI.as_view("role"), +# ) group.add_url_rule( "///users", methods=["GET", "OPTIONS"], diff --git a/app/core/rbac.py b/app/core/rbac.py index e0fe0dc..b3d2a0f 100644 --- a/app/core/rbac.py +++ b/app/core/rbac.py @@ -134,7 +134,7 @@ class RoleMixin: create_time: datetime = DateTimeField( db_field="m_c", default=datetime.datetime.utcnow ) - system_role_data = {} # type: dict + system_role_data: List[dict] = [] def clean(self): # ==处理permission== @@ -185,9 +185,9 @@ def init_system_roles(cls: Type[Document]): system_code=role["system_code"], intro=role.get("intro", ""), ).save() - logger.info(f"初始化{cls._class_name}表完成") + logger.info(f"Populated {cls._class_name} with default roles") else: - logger.info(f"已存在{cls._class_name}表,跳过初始化") + logger.info(f"{cls._class_name} already populated") @classmethod def system_roles(cls: Type[Document], without_creator=False): @@ -214,9 +214,11 @@ def by_id(cls: Type[Document], id): return role def to_api(self: Document): + name = gettext(self.name) + logger.debug('RoleMixin.to_api: name="%s" %s', self.name, name) return { "id": str(self.id), - "name": self.name, + "name": gettext(self.name), "level": self.level, "system": self.system, "system_code": self.system_code, diff --git a/app/factory.py b/app/factory.py index 996a02a..69b8cc0 100644 --- a/app/factory.py +++ b/app/factory.py @@ -117,12 +117,14 @@ def create_default_team(admin_user): from app.models.site_setting import SiteSetting if Team.objects().count() == 0: - logger.debug("已建立默认团队") + logger.debug("creating default team") team = Team.create( - name="默认团队", + name="Default Team", creator=admin_user, ) - team.intro = "所有新用户会自动加入此团队,如不需要,站点管理员可以在“站点管理-自动加入的团队 ID”中删除此团队 ID。" + team.intro = """ + All new users will automatically join this team. This can be disabled by site administrator. + 所有新用户会自动加入此团队,如不需要,站点管理员可以在“站点管理-自动加入的团队 ID”中删除此团队 ID。""".strip() team.allow_apply_type = AllowApplyType.ALL team.application_check_type = ApplicationCheckType.ADMIN_CHECK team.default_role = TeamRole.by_system_code("member") @@ -131,7 +133,7 @@ def create_default_team(admin_user): site_setting.auto_join_team_ids = [team.id] site_setting.save() else: - logger.debug("已有团队,跳过建立默认团队") + logger.debug("default team existed") def init_db(app: Flask): diff --git a/app/models/file.py b/app/models/file.py index 1f84ec7..46169a9 100644 --- a/app/models/file.py +++ b/app/models/file.py @@ -411,7 +411,7 @@ def rename(self, name): file.save() @need_activated - def move_to(self, parent: Union[str, ObjectId, "File"]): + def move_to(self, parent: Union[str, ObjectId, "File", None]): """将某个文件或文件夹移动到另一个地方""" # 强制从数据库更新自身,以免之前有删除、建立文件夹操作,影响最后的计数缓存 self.reload() diff --git a/app/models/project.py b/app/models/project.py index e4bc802..a3893ff 100644 --- a/app/models/project.py +++ b/app/models/project.py @@ -140,9 +140,9 @@ class ProjectPermission(PermissionMixin): class ProjectRole(RoleMixin, Document): permission_cls = ProjectPermission group = ReferenceField("Project", db_field="g") - system_role_data = [ + system_role_data: List[dict] = [ { - "name": gettext("创建人"), + "name": "创建人", "permissions": [ ProjectPermission.ACCESS, ProjectPermission.CHANGE, @@ -173,7 +173,7 @@ class ProjectRole(RoleMixin, Document): "system_code": "creator", }, { - "name": gettext("管理员"), + "name": "管理员", "permissions": [ ProjectPermission.ACCESS, ProjectPermission.CHANGE, @@ -204,7 +204,7 @@ class ProjectRole(RoleMixin, Document): "system_code": "admin", }, { - "name": gettext("监理"), + "name": "监理", "permissions": [ ProjectPermission.ACCESS, ProjectPermission.ADD_FILE, @@ -229,7 +229,7 @@ class ProjectRole(RoleMixin, Document): "system_code": "coordinator", }, { - "name": gettext("校对"), + "name": "校对", "permissions": [ ProjectPermission.ACCESS, ProjectPermission.OUTPUT_TRA, @@ -244,7 +244,7 @@ class ProjectRole(RoleMixin, Document): "system_code": "proofreader", }, { - "name": gettext("翻译"), + "name": "翻译", "permissions": [ ProjectPermission.ACCESS, ProjectPermission.OUTPUT_TRA, @@ -257,7 +257,7 @@ class ProjectRole(RoleMixin, Document): "system_code": "translator", }, { - "name": gettext("嵌字"), + "name": "嵌字", "permissions": [ ProjectPermission.ACCESS, ProjectPermission.OUTPUT_TRA, @@ -269,13 +269,23 @@ class ProjectRole(RoleMixin, Document): "system_code": "picture_editor", }, { - "name": gettext("见习翻译"), + "name": "见习翻译", "permissions": [ProjectPermission.ACCESS, ProjectPermission.ADD_TRA], "level": 100, "system_code": "supporter", }, ] + @classmethod + def unused_provide_babel_names(cls): + gettext("创建人") + gettext("管理员") + gettext("监理") + gettext("校对") + gettext("翻译") + gettext("嵌字") + gettext("见习翻译") + class ProjectSet(Document): """项目集""" diff --git a/app/models/team.py b/app/models/team.py index dcb113e..9360233 100644 --- a/app/models/team.py +++ b/app/models/team.py @@ -1,8 +1,9 @@ import datetime import re +from typing import List from flask import current_app -from flask_babel import gettext, lazy_gettext +from flask_babel import lazy_gettext, gettext from mongoengine import ( CASCADE, DENY, @@ -130,9 +131,9 @@ class TeamPermission(PermissionMixin): class TeamRole(RoleMixin, Document): permission_cls = TeamPermission group = ReferenceField("Team", db_field="g") - system_role_data = [ + system_role_data: List[dict] = [ { - "name": gettext("创建人"), + "name": "创建人", "permissions": [ TeamPermission.ACCESS, TeamPermission.DELETE, @@ -164,7 +165,7 @@ class TeamRole(RoleMixin, Document): "system_code": "creator", }, { - "name": gettext("管理员"), + "name": "管理员", "permissions": [ TeamPermission.ACCESS, TeamPermission.CHANGE, @@ -195,7 +196,7 @@ class TeamRole(RoleMixin, Document): "system_code": "admin", }, { - "name": gettext("资深成员"), + "name": "资深成员", "permissions": [ TeamPermission.ACCESS, TeamPermission.CREATE_TERM_BANK, @@ -216,7 +217,7 @@ class TeamRole(RoleMixin, Document): "system_code": "senior", }, { - "name": gettext("成员"), + "name": "成员", "permissions": [ TeamPermission.ACCESS, TeamPermission.CREATE_TERM_BANK, @@ -235,7 +236,7 @@ class TeamRole(RoleMixin, Document): "system_code": "member", }, { - "name": gettext("见习成员"), + "name": "见习成员", "permissions": [TeamPermission.ACCESS], "level": 100, "system_code": "beginner", @@ -247,6 +248,14 @@ def convert_to_project_role(self): if self.has_permission(self.permission_cls.AUTO_BECOME_PROJECT_ADMIN): return ProjectRole.by_system_code("admin") + @classmethod + def unused_provide_babel_names(cls): + gettext("创建人") + gettext("管理员") + gettext("资深成员") + gettext("成员") + gettext("见习成员") + class Team(GroupMixin, Document): name = StringField(db_field="n", unique=True) # 名称 diff --git a/app/models/user.py b/app/models/user.py index c658b38..dd92cd4 100644 --- a/app/models/user.py +++ b/app/models/user.py @@ -1,7 +1,7 @@ from app.models.output import Output import datetime import re -from typing import NoReturn, Union +from typing import NoReturn, Optional, Union from flask import current_app, g from flask_babel import gettext @@ -243,7 +243,13 @@ def to_api(self): return data # =====团队操作===== - def teams(self, role=None, skip: int = None, limit: int = None, word: str = None): + def teams( + self, + role=None, + skip: Optional[int] = None, + limit: Optional[int] = None, + word: Optional[str] = None, + ): """ 获取自己加入的团队 diff --git a/app/translations/en/LC_MESSAGES/messages.po b/app/translations/en/LC_MESSAGES/messages.po index 4e02285..7b1e519 100644 --- a/app/translations/en/LC_MESSAGES/messages.po +++ b/app/translations/en/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2024-11-04 02:29+0900\n" +"POT-Creation-Date: 2024-11-06 03:24+0900\n" "PO-Revision-Date: 2017-04-14 15:38+0800\n" "Last-Translator: FULL NAME \n" "Language: en_US\n" @@ -32,7 +32,7 @@ msgstr "Only the applicant can remove the application" #: app/apis/application.py:183 app/apis/file.py:254 app/apis/invitation.py:236 #: app/apis/project_set.py:102 app/apis/target.py:31 app/apis/term.py:151 -#: app/apis/term.py:311 app/core/rbac.py:483 +#: app/apis/term.py:311 app/core/rbac.py:485 msgid "删除成功" msgstr "Removed" @@ -51,7 +51,7 @@ msgstr "Missing id" msgid "修改成功" msgstr "Updated" -#: app/apis/file.py:57 app/apis/project.py:53 +#: app/apis/file.py:57 app/apis/file.py:159 app/apis/project.py:53 msgid "您没有此项目的访问权限" msgstr "Access permission not granted" @@ -59,7 +59,7 @@ msgstr "Access permission not granted" msgid "您没有此项目的上传文件权限" msgstr "Upload file permission not granted" -#: app/apis/file.py:159 app/apis/file.py:220 +#: app/apis/file.py:220 msgid "您没有权限移动文件" msgstr "Move file permission not granted" @@ -111,7 +111,7 @@ msgstr "Complete" msgid "只能修改邀请角色等级比您低的邀请" msgstr "You can only modify invitations for roles lower than your own." -#: app/apis/invitation.py:163 app/models/user.py:383 +#: app/apis/invitation.py:163 app/models/user.py:389 msgid "邀请的角色等级需要比您低" msgstr "The role level of the invitee needs to be lower than yours." @@ -530,61 +530,61 @@ msgstr "Can only modify characters with a lower role level than your own." msgid "修改用户备注" msgstr "Edit User Note" -#: app/core/rbac.py:284 app/core/rbac.py:322 +#: app/core/rbac.py:286 app/core/rbac.py:324 msgid "角色等级不能大于等于自己的角色等级" msgstr "" "Character level cannot be greater than or equal to your own character " "level." -#: app/core/rbac.py:286 app/core/rbac.py:324 +#: app/core/rbac.py:288 app/core/rbac.py:326 msgid "角色权限不能多于自己的角色权限" msgstr "Role permissions cannot exceed your own role permissions." -#: app/core/rbac.py:317 +#: app/core/rbac.py:319 msgid "不能修改系统角色" msgstr "Cannot modify system role." -#: app/core/rbac.py:339 +#: app/core/rbac.py:341 msgid "不能删除系统角色" msgstr "Cannot delete system role." -#: app/core/rbac.py:388 app/core/rbac.py:389 +#: app/core/rbac.py:390 app/core/rbac.py:391 msgid "此项目/团队不允许申请加入" msgstr "This project/team does not allow requests to join." -#: app/core/rbac.py:464 +#: app/core/rbac.py:466 msgid "用户不存在于团队" msgstr "User does not exist in the team." -#: app/core/rbac.py:474 +#: app/core/rbac.py:476 msgid "退出成功" msgstr "Logout successful." -#: app/core/rbac.py:478 +#: app/core/rbac.py:480 msgid "您没有删除用户权限" msgstr "You do not have permission to delete users." -#: app/core/rbac.py:481 +#: app/core/rbac.py:483 msgid "只能删除角色等级比您低的用户" msgstr "You can only delete users with a role level lower than yours." -#: app/core/rbac.py:501 +#: app/core/rbac.py:503 msgid "您不能修改自己的角色" msgstr "You cannot modify your role." -#: app/core/rbac.py:504 +#: app/core/rbac.py:506 msgid "您没有修改用户角色权限" msgstr "You do not have permission to modify user roles." -#: app/core/rbac.py:508 +#: app/core/rbac.py:510 msgid "只能为比您角色等级低的用户设置角色" msgstr "Can only assign roles to users with a lower role level than yours." -#: app/core/rbac.py:511 +#: app/core/rbac.py:513 msgid "只能为用户设置比您角色等级低的角色" msgstr "You can only assign roles to users that are lower than your role level." -#: app/core/rbac.py:539 +#: app/core/rbac.py:541 msgid "默认角色不能设置为创建者" msgstr "The default role cannot be set as the creator." @@ -1046,7 +1046,7 @@ msgstr "Team members only." #: app/models/project.py:114 msgid "访问项目" -msgstr "Visit project" +msgstr "View project" #: app/models/project.py:115 msgid "删除项目" @@ -1124,209 +1124,209 @@ msgstr "Modify target language." msgid "删除目标语言" msgstr "Delete target language." -#: app/models/project.py:145 app/models/team.py:135 +#: app/models/project.py:281 app/models/team.py:253 msgid "创建人" msgstr "Creator" -#: app/models/project.py:176 app/models/team.py:167 +#: app/models/project.py:282 app/models/team.py:254 msgid "管理员" -msgstr "Administrator" +msgstr "Admin" -#: app/models/project.py:207 +#: app/models/project.py:283 msgid "监理" -msgstr "Supervision" +msgstr "Supervisor" -#: app/models/project.py:232 +#: app/models/project.py:284 msgid "校对" -msgstr "Proofreading" +msgstr "Proofreader" -#: app/models/project.py:247 +#: app/models/project.py:285 msgid "翻译" -msgstr "Translate" +msgstr "Translator" -#: app/models/project.py:260 +#: app/models/project.py:286 msgid "嵌字" -msgstr "Kerning" +msgstr "Inpainter" -#: app/models/project.py:272 +#: app/models/project.py:287 msgid "见习翻译" msgstr "Trainee Translator" -#: app/models/project.py:425 +#: app/models/project.py:435 msgid "必须是Language对象" msgstr "Must be a Language object." -#: app/models/project.py:560 +#: app/models/project.py:570 msgid "只允许项目所属团队成员申请加入" msgstr "Only members of the project team are allowed to apply to join." -#: app/models/project.py:627 +#: app/models/project.py:637 msgid "暂不支持的文件格式" msgstr "File format not supported" -#: app/models/project.py:948 +#: app/models/project.py:958 msgid "框内" msgstr "In the box." -#: app/models/project.py:950 +#: app/models/project.py:960 msgid "框外" msgstr "Out of the box" -#: app/models/project.py:953 +#: app/models/project.py:963 msgid "可使用 LabelPlus Photoshop 脚本导入 psd 中" msgstr "You can use the LabelPlus Photoshop script to import into PSD." -#: app/models/team.py:59 +#: app/models/team.py:60 msgid "访问团队" -msgstr "Visit team" +msgstr "View team" -#: app/models/team.py:60 +#: app/models/team.py:61 msgid "解散团队" msgstr "Disband Team" -#: app/models/team.py:61 +#: app/models/team.py:62 msgid "设置团队" msgstr "Set Team" -#: app/models/team.py:64 +#: app/models/team.py:65 msgid "管理项目" msgstr "Manage Projects" -#: app/models/team.py:65 +#: app/models/team.py:66 msgid "自动获得团队内所有项目的管理员权限" msgstr "Automatically gain admin access to all projects within the team." -#: app/models/team.py:68 +#: app/models/team.py:69 msgid "创建术语库" msgstr "Create a termbase." -#: app/models/team.py:69 +#: app/models/team.py:70 msgid "在团队内创建术语库" msgstr "Create a term base within the team." -#: app/models/team.py:72 +#: app/models/team.py:73 msgid "查看他人术语库" msgstr "View others' termbase." -#: app/models/team.py:73 +#: app/models/team.py:74 msgid "若无此权限只能查看自己创建的术语库中的术语" msgstr "" "If you do not have this permission, you can only view the terms in the " "termbase you created." -#: app/models/team.py:76 +#: app/models/team.py:77 msgid "设置他人术语库" msgstr "Set others' termbase." -#: app/models/team.py:77 +#: app/models/team.py:78 msgid "若无此权限只能修改自己创建的术语库设置" msgstr "" "Without this permission, you can only modify the settings of the termbase" " you created." -#: app/models/team.py:80 +#: app/models/team.py:81 msgid "删除他人术语库" msgstr "Delete others' termbase." -#: app/models/team.py:81 +#: app/models/team.py:82 msgid "若无此权限只能删除自己创建的术语库" msgstr "Without this permission, you can only delete the term base you created." -#: app/models/team.py:84 +#: app/models/team.py:85 msgid "在他人术语库中增加术语" msgstr "Add a term to another's terminology database." -#: app/models/team.py:85 +#: app/models/team.py:86 msgid "若无此权限只能在自己创建的术语库中增加术语" msgstr "" "If you do not have this permission, you can only add terms to the " "termbase you created." -#: app/models/team.py:88 +#: app/models/team.py:89 msgid "修改他人术语" msgstr "Modify others' terms." -#: app/models/team.py:89 +#: app/models/team.py:90 msgid "若无此权限只能修改自己创建的术语或自己术语库中的术语" msgstr "" "If you do not have this permission, you can only modify terms you created" " or terms in your own termbase." -#: app/models/team.py:94 +#: app/models/team.py:95 msgid "删除他人术语" msgstr "Delete others' terms." -#: app/models/team.py:95 +#: app/models/team.py:96 msgid "若无此权限只能删除自己创建的术语或自己术语库中的术语" msgstr "" "If you do not have this permission, you can only delete terms you created" " or terms in your own termbase." -#: app/models/team.py:100 +#: app/models/team.py:101 msgid "创建项目" msgstr "Create Project" -#: app/models/team.py:101 +#: app/models/team.py:102 msgid "在团队内创建项目" msgstr "Create a project within the team." -#: app/models/team.py:104 +#: app/models/team.py:105 msgid "创建项目集" msgstr "Create Portfolio" -#: app/models/team.py:105 +#: app/models/team.py:106 msgid "在团队内创建项目集" msgstr "Create a project set within the team." -#: app/models/team.py:108 +#: app/models/team.py:109 msgid "设置项目集" msgstr "Set Portfolio" -#: app/models/team.py:109 +#: app/models/team.py:110 msgid "修改团队内项目集的设置" msgstr "Modify the settings of the project collection within the team." -#: app/models/team.py:112 +#: app/models/team.py:113 msgid "删除项目集" msgstr "Delete project set" -#: app/models/team.py:113 +#: app/models/team.py:114 msgid "删除团队内的项目集" msgstr "Delete the portfolio within the team." -#: app/models/team.py:116 +#: app/models/team.py:117 msgid "使用自动标记额度" msgstr "Use automatic tagging quota." -#: app/models/team.py:117 +#: app/models/team.py:118 msgid "可以使用团队的自动标记额度" msgstr "The team's automatic tagging quota can be used." -#: app/models/team.py:120 +#: app/models/team.py:121 msgid "使用机器翻译额度" msgstr "Use machine translation quota." -#: app/models/team.py:121 +#: app/models/team.py:122 msgid "可以使用团队的机器翻译额度" msgstr "The team's machine translation quota can be used." -#: app/models/team.py:124 +#: app/models/team.py:125 msgid "查看项目统计" msgstr "View project statistics" -#: app/models/team.py:125 +#: app/models/team.py:126 msgid "可以查看团队项目统计" msgstr "You can view team project statistics." -#: app/models/team.py:198 +#: app/models/team.py:255 msgid "资深成员" msgstr "Senior Member" -#: app/models/team.py:219 +#: app/models/team.py:256 msgid "成员" msgstr "Member" -#: app/models/team.py:238 +#: app/models/team.py:257 msgid "见习成员" msgstr "Trainee Member" @@ -1338,37 +1338,37 @@ msgstr "Token format error, should be like Bearer x.x.x." msgid "密码已修改,请重新登录" msgstr "Password has been changed, please log in again." -#: app/models/user.py:399 +#: app/models/user.py:405 msgid "此用户已有申请,已直接加入" msgstr "This user already has an application and has been directly added." -#: app/models/user.py:406 +#: app/models/user.py:412 msgid "此用户是项目所在团队成员,已直接加入" msgstr "This user is a member of the project team and has been directly added." -#: app/models/user.py:412 +#: app/models/user.py:418 msgid "邀请成功,请等待用户确认" msgstr "Invitation successful, please wait for user confirmation." -#: app/models/user.py:443 +#: app/models/user.py:449 msgid "加入成功,管理员继承自团队" msgstr "Joined successfully, administrator inherited from the team." -#: app/models/user.py:456 +#: app/models/user.py:462 msgid "管理员先前邀请了您,已直接加入" msgstr "" "The administrator previously invited you, and you have been directly " "added." -#: app/models/user.py:463 +#: app/models/user.py:469 msgid "项目不允许申请加入" msgstr "The project does not allow requests to join." -#: app/models/user.py:469 +#: app/models/user.py:475 msgid "加入成功" msgstr "Joined successfully." -#: app/models/user.py:472 +#: app/models/user.py:478 msgid "申请成功,请等待管理员审核" msgstr "Application successful, please wait for administrator review." diff --git a/app/translations/zh/LC_MESSAGES/messages.po b/app/translations/zh/LC_MESSAGES/messages.po index 1798241..3e44e43 100644 --- a/app/translations/zh/LC_MESSAGES/messages.po +++ b/app/translations/zh/LC_MESSAGES/messages.po @@ -3,12 +3,11 @@ # This file is distributed under the same license as the PROJECT project. # FIRST AUTHOR , 2024. # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2024-11-04 02:29+0900\n" +"POT-Creation-Date: 2024-11-06 03:24+0900\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language: zh\n" @@ -33,7 +32,7 @@ msgstr "只有申请人可以删除申请" #: app/apis/application.py:183 app/apis/file.py:254 app/apis/invitation.py:236 #: app/apis/project_set.py:102 app/apis/target.py:31 app/apis/term.py:151 -#: app/apis/term.py:311 app/core/rbac.py:483 +#: app/apis/term.py:311 app/core/rbac.py:485 msgid "删除成功" msgstr "删除成功" @@ -52,7 +51,7 @@ msgstr "缺少id" msgid "修改成功" msgstr "修改成功" -#: app/apis/file.py:57 app/apis/project.py:53 +#: app/apis/file.py:57 app/apis/file.py:159 app/apis/project.py:53 msgid "您没有此项目的访问权限" msgstr "您没有此项目的访问权限" @@ -60,7 +59,7 @@ msgstr "您没有此项目的访问权限" msgid "您没有此项目的上传文件权限" msgstr "您没有此项目的上传文件权限" -#: app/apis/file.py:159 app/apis/file.py:220 +#: app/apis/file.py:220 msgid "您没有权限移动文件" msgstr "您没有权限移动文件" @@ -112,7 +111,7 @@ msgstr "处理成功" msgid "只能修改邀请角色等级比您低的邀请" msgstr "只能修改邀请角色等级比您低的邀请" -#: app/apis/invitation.py:163 app/models/user.py:383 +#: app/apis/invitation.py:163 app/models/user.py:389 msgid "邀请的角色等级需要比您低" msgstr "邀请的角色等级需要比您低" @@ -511,59 +510,59 @@ msgstr "仅可修改比自己角色等级低的角色" msgid "修改用户备注" msgstr "修改用户备注" -#: app/core/rbac.py:284 app/core/rbac.py:322 +#: app/core/rbac.py:286 app/core/rbac.py:324 msgid "角色等级不能大于等于自己的角色等级" msgstr "角色等级不能大于等于自己的角色等级" -#: app/core/rbac.py:286 app/core/rbac.py:324 +#: app/core/rbac.py:288 app/core/rbac.py:326 msgid "角色权限不能多于自己的角色权限" msgstr "角色权限不能多于自己的角色权限" -#: app/core/rbac.py:317 +#: app/core/rbac.py:319 msgid "不能修改系统角色" msgstr "不能修改系统角色" -#: app/core/rbac.py:339 +#: app/core/rbac.py:341 msgid "不能删除系统角色" msgstr "不能删除系统角色" -#: app/core/rbac.py:388 app/core/rbac.py:389 +#: app/core/rbac.py:390 app/core/rbac.py:391 msgid "此项目/团队不允许申请加入" msgstr "此项目/团队不允许申请加入" -#: app/core/rbac.py:464 +#: app/core/rbac.py:466 msgid "用户不存在于团队" msgstr "用户不存在于团队" -#: app/core/rbac.py:474 +#: app/core/rbac.py:476 msgid "退出成功" msgstr "退出成功" -#: app/core/rbac.py:478 +#: app/core/rbac.py:480 msgid "您没有删除用户权限" msgstr "您没有删除用户权限" -#: app/core/rbac.py:481 +#: app/core/rbac.py:483 msgid "只能删除角色等级比您低的用户" msgstr "只能删除角色等级比您低的用户" -#: app/core/rbac.py:501 +#: app/core/rbac.py:503 msgid "您不能修改自己的角色" msgstr "您不能修改自己的角色" -#: app/core/rbac.py:504 +#: app/core/rbac.py:506 msgid "您没有修改用户角色权限" msgstr "您没有修改用户角色权限" -#: app/core/rbac.py:508 +#: app/core/rbac.py:510 msgid "只能为比您角色等级低的用户设置角色" msgstr "只能为比您角色等级低的用户设置角色" -#: app/core/rbac.py:511 +#: app/core/rbac.py:513 msgid "只能为用户设置比您角色等级低的角色" msgstr "只能为用户设置比您角色等级低的角色" -#: app/core/rbac.py:539 +#: app/core/rbac.py:541 msgid "默认角色不能设置为创建者" msgstr "默认角色不能设置为创建者" @@ -1095,201 +1094,201 @@ msgstr "修改目标语言" msgid "删除目标语言" msgstr "删除目标语言" -#: app/models/project.py:145 app/models/team.py:135 +#: app/models/project.py:281 app/models/team.py:253 msgid "创建人" -msgstr "创建人" +msgstr "" -#: app/models/project.py:176 app/models/team.py:167 +#: app/models/project.py:282 app/models/team.py:254 msgid "管理员" -msgstr "管理员" +msgstr "" -#: app/models/project.py:207 +#: app/models/project.py:283 msgid "监理" -msgstr "监理" +msgstr "" -#: app/models/project.py:232 +#: app/models/project.py:284 msgid "校对" -msgstr "校对" +msgstr "" -#: app/models/project.py:247 +#: app/models/project.py:285 msgid "翻译" -msgstr "翻译" +msgstr "" -#: app/models/project.py:260 +#: app/models/project.py:286 msgid "嵌字" -msgstr "嵌字" +msgstr "" -#: app/models/project.py:272 +#: app/models/project.py:287 msgid "见习翻译" -msgstr "见习翻译" +msgstr "" -#: app/models/project.py:425 +#: app/models/project.py:435 msgid "必须是Language对象" msgstr "必须是Language对象" -#: app/models/project.py:560 +#: app/models/project.py:570 msgid "只允许项目所属团队成员申请加入" msgstr "只允许项目所属团队成员申请加入" -#: app/models/project.py:627 +#: app/models/project.py:637 msgid "暂不支持的文件格式" msgstr "暂不支持的文件格式" -#: app/models/project.py:948 +#: app/models/project.py:958 msgid "框内" msgstr "框内" -#: app/models/project.py:950 +#: app/models/project.py:960 msgid "框外" msgstr "框外" -#: app/models/project.py:953 +#: app/models/project.py:963 msgid "可使用 LabelPlus Photoshop 脚本导入 psd 中" msgstr "可使用 LabelPlus Photoshop 脚本导入 psd 中" -#: app/models/team.py:59 +#: app/models/team.py:60 msgid "访问团队" msgstr "访问团队" -#: app/models/team.py:60 +#: app/models/team.py:61 msgid "解散团队" msgstr "解散团队" -#: app/models/team.py:61 +#: app/models/team.py:62 msgid "设置团队" msgstr "设置团队" -#: app/models/team.py:64 +#: app/models/team.py:65 msgid "管理项目" msgstr "管理项目" -#: app/models/team.py:65 +#: app/models/team.py:66 msgid "自动获得团队内所有项目的管理员权限" msgstr "自动获得团队内所有项目的管理员权限" -#: app/models/team.py:68 +#: app/models/team.py:69 msgid "创建术语库" msgstr "创建术语库" -#: app/models/team.py:69 +#: app/models/team.py:70 msgid "在团队内创建术语库" msgstr "在团队内创建术语库" -#: app/models/team.py:72 +#: app/models/team.py:73 msgid "查看他人术语库" msgstr "查看他人术语库" -#: app/models/team.py:73 +#: app/models/team.py:74 msgid "若无此权限只能查看自己创建的术语库中的术语" msgstr "若无此权限只能查看自己创建的术语库中的术语" -#: app/models/team.py:76 +#: app/models/team.py:77 msgid "设置他人术语库" msgstr "设置他人术语库" -#: app/models/team.py:77 +#: app/models/team.py:78 msgid "若无此权限只能修改自己创建的术语库设置" msgstr "若无此权限只能修改自己创建的术语库设置" -#: app/models/team.py:80 +#: app/models/team.py:81 msgid "删除他人术语库" msgstr "删除他人术语库" -#: app/models/team.py:81 +#: app/models/team.py:82 msgid "若无此权限只能删除自己创建的术语库" msgstr "若无此权限只能删除自己创建的术语库" -#: app/models/team.py:84 +#: app/models/team.py:85 msgid "在他人术语库中增加术语" msgstr "在他人术语库中增加术语" -#: app/models/team.py:85 +#: app/models/team.py:86 msgid "若无此权限只能在自己创建的术语库中增加术语" msgstr "若无此权限只能在自己创建的术语库中增加术语" -#: app/models/team.py:88 +#: app/models/team.py:89 msgid "修改他人术语" msgstr "修改他人术语" -#: app/models/team.py:89 +#: app/models/team.py:90 msgid "若无此权限只能修改自己创建的术语或自己术语库中的术语" msgstr "若无此权限只能修改自己创建的术语或自己术语库中的术语" -#: app/models/team.py:94 +#: app/models/team.py:95 msgid "删除他人术语" msgstr "删除他人术语" -#: app/models/team.py:95 +#: app/models/team.py:96 msgid "若无此权限只能删除自己创建的术语或自己术语库中的术语" msgstr "若无此权限只能删除自己创建的术语或自己术语库中的术语" -#: app/models/team.py:100 +#: app/models/team.py:101 msgid "创建项目" msgstr "创建项目" -#: app/models/team.py:101 +#: app/models/team.py:102 msgid "在团队内创建项目" msgstr "在团队内创建项目" -#: app/models/team.py:104 +#: app/models/team.py:105 msgid "创建项目集" msgstr "创建项目集" -#: app/models/team.py:105 +#: app/models/team.py:106 msgid "在团队内创建项目集" msgstr "在团队内创建项目集" -#: app/models/team.py:108 +#: app/models/team.py:109 msgid "设置项目集" msgstr "设置项目集" -#: app/models/team.py:109 +#: app/models/team.py:110 msgid "修改团队内项目集的设置" msgstr "修改团队内项目集的设置" -#: app/models/team.py:112 +#: app/models/team.py:113 msgid "删除项目集" msgstr "删除项目集" -#: app/models/team.py:113 +#: app/models/team.py:114 msgid "删除团队内的项目集" msgstr "删除团队内的项目集" -#: app/models/team.py:116 +#: app/models/team.py:117 msgid "使用自动标记额度" msgstr "使用自动标记额度" -#: app/models/team.py:117 +#: app/models/team.py:118 msgid "可以使用团队的自动标记额度" msgstr "可以使用团队的自动标记额度" -#: app/models/team.py:120 +#: app/models/team.py:121 msgid "使用机器翻译额度" msgstr "使用机器翻译额度" -#: app/models/team.py:121 +#: app/models/team.py:122 msgid "可以使用团队的机器翻译额度" msgstr "可以使用团队的机器翻译额度" -#: app/models/team.py:124 +#: app/models/team.py:125 msgid "查看项目统计" msgstr "查看项目统计" -#: app/models/team.py:125 +#: app/models/team.py:126 msgid "可以查看团队项目统计" msgstr "可以查看团队项目统计" -#: app/models/team.py:198 +#: app/models/team.py:255 msgid "资深成员" -msgstr "资深成员" +msgstr "" -#: app/models/team.py:219 +#: app/models/team.py:256 msgid "成员" -msgstr "成员" +msgstr "" -#: app/models/team.py:238 +#: app/models/team.py:257 msgid "见习成员" -msgstr "见习成员" +msgstr "" #: app/models/user.py:189 msgid "令牌格式错误,应形如 Bearer x.x.x" @@ -1299,35 +1298,35 @@ msgstr "令牌格式错误,应形如 Bearer x.x.x" msgid "密码已修改,请重新登录" msgstr "密码已修改,请重新登录" -#: app/models/user.py:399 +#: app/models/user.py:405 msgid "此用户已有申请,已直接加入" msgstr "此用户已有申请,已直接加入" -#: app/models/user.py:406 +#: app/models/user.py:412 msgid "此用户是项目所在团队成员,已直接加入" msgstr "此用户是项目所在团队成员,已直接加入" -#: app/models/user.py:412 +#: app/models/user.py:418 msgid "邀请成功,请等待用户确认" msgstr "邀请成功,请等待用户确认" -#: app/models/user.py:443 +#: app/models/user.py:449 msgid "加入成功,管理员继承自团队" msgstr "加入成功,管理员继承自团队" -#: app/models/user.py:456 +#: app/models/user.py:462 msgid "管理员先前邀请了您,已直接加入" msgstr "管理员先前邀请了您,已直接加入" -#: app/models/user.py:463 +#: app/models/user.py:469 msgid "项目不允许申请加入" msgstr "项目不允许申请加入" -#: app/models/user.py:469 +#: app/models/user.py:475 msgid "加入成功" msgstr "加入成功" -#: app/models/user.py:472 +#: app/models/user.py:478 msgid "申请成功,请等待管理员审核" msgstr "申请成功,请等待管理员审核" @@ -1373,3 +1372,12 @@ msgstr "等级需要大于{min},小于{max}(您的等级)" msgid "没有有效参数" msgstr "没有有效参数" +#~ msgid "资深成员" +#~ msgstr "资深成员" + +#~ msgid "成员" +#~ msgstr "成员" + +#~ msgid "见习成员" +#~ msgstr "见习成员" + diff --git a/tests/__init__.py b/tests/__init__.py index 1a9add1..dc55da3 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -35,6 +35,7 @@ def create_test_app(): class MoeTestCase(TestCase): + maxDiff = None def setUp(self): self.app = create_test_app() self.app_context = self.app.app_context() diff --git a/tests/api/test_role_api.py b/tests/api/test_role_api.py index 3d6b73c..9a5fcbc 100644 --- a/tests/api/test_role_api.py +++ b/tests/api/test_role_api.py @@ -9,7 +9,7 @@ class RoleAPITestCase(MoeAPITestCase): - def test_get_role(self): + def disabled_test_get_role(self): """测试通过api获取role""" with self.app.test_request_context(): token = self.create_user("11", "1@1.com", "111111").generate_token() @@ -41,7 +41,7 @@ def test_get_role(self): int(data.headers.get("X-Pagination-Count")), ) - def test_create_role(self): + def disabled_test_create_role(self): """测试通过api创建role""" with self.app.test_request_context(): token = self.create_user("11", "1@1.com", "111111").generate_token() @@ -122,7 +122,7 @@ def test_create_role(self): self.assertErrorEqual(data) self.assertEqual(1, team.roles(type=RoleType.CUSTOM).count()) - def test_edit_role(self): + def disabled_test_edit_role(self): """测试通过api修改role""" with self.app.test_request_context(): token = self.create_user("11", "1@1.com", "111111").generate_token() @@ -243,7 +243,7 @@ def test_edit_role(self): sorted(role.permissions), ) - def test_delete_role(self): + def disabled_test_delete_role(self): """测试通过api修改role""" with self.app.test_request_context(): token = self.create_user("11", "1@1.com", "111111").generate_token() diff --git a/tests/api/test_team_api.py b/tests/api/test_team_api.py index f887f3d..a1633d6 100644 --- a/tests/api/test_team_api.py +++ b/tests/api/test_team_api.py @@ -115,7 +115,9 @@ def test_get_team_list2(self): # word = t,搜到 2 个 data = self.get("/v1/teams", query_string={"word": "t"}, token=token) self.assertErrorEqual(data) - self.assertEqual(2, len(data.json)) + self.assertEqual( + # default team + t1 + t2 + 3, len(data.json)) # word = 1,搜到 1 个 data = self.get("/v1/teams", query_string={"word": "1"}, token=token) self.assertErrorEqual(data)