Skip to content

Commit 52ae100

Browse files
committed
use gettext_lazy
1 parent 6027479 commit 52ae100

File tree

6 files changed

+14
-16
lines changed

6 files changed

+14
-16
lines changed

api_permission/middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def _has_permission(self, path, user, method):
6161
def _return_403_res(self, msg):
6262
res = {
6363
'code': 1,
64-
'msg': 'api_permission异常:{}'.format(msg),
64+
'msg': 'api_permission exception:{}'.format(msg),
6565
'data': None
6666
}
6767
return JsonResponse(res, status=status.HTTP_403_FORBIDDEN)

api_permission/models.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
from django.db import models
22
from django.contrib.auth.models import Group
3+
from django.utils.translation import gettext_lazy as _
34

45

56
class APIPermissionModel(models.Model):
67
POST = 'POST'
78
GET = 'GET'
89
ALL = 'ALL'
910
METHODS = (
10-
(POST, "create/edit/delete"),
11-
(GET, "readonly"),
12-
(ALL, "all"),
11+
(POST, _("create/edit/delete")),
12+
(GET, _("readonly")),
13+
(ALL, _("all")),
1314
)
1415

15-
pattern = models.CharField("API正则", max_length=128)
16-
method = models.CharField("方法类型", max_length=16, choices=METHODS)
17-
active = models.BooleanField("是否生效", default=True)
18-
group = models.ManyToManyField(Group, db_constraint=True, verbose_name="组/角色",
16+
pattern = models.CharField(_("api pattern"), max_length=128)
17+
method = models.CharField(_("method"), max_length=16, choices=METHODS)
18+
active = models.BooleanField(_("is Active"), default=True)
19+
group = models.ManyToManyField(Group, db_constraint=True, verbose_name=_("group"),
1920
related_name='api_permissions')
20-
comment = models.CharField("备注", max_length=256, blank=True, null=True)
21+
comment = models.CharField(_("comment"), max_length=256, blank=True, null=True)
2122

22-
created_at = models.DateTimeField("创建时间", auto_now_add=True, null=True)
23-
updated_at = models.DateTimeField("更新时间", auto_now=True, null=True)
23+
created_at = models.DateTimeField(_("created"), auto_now_add=True, null=True)
24+
updated_at = models.DateTimeField(_("updated"), auto_now=True, null=True)
2425

2526
class Meta:
2627
db_table = 'api_permission'
27-
verbose_name = 'API 权限'
28-
verbose_name_plural = 'API 权限列表'
28+
verbose_name = _('API Permission')
29+
verbose_name_plural = _('API Permissions')

api_permission/serializers.py

Whitespace-only changes.

api_permission/tests.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

api_permission/urls.py

Whitespace-only changes.

api_permission/views.py

Whitespace-only changes.

0 commit comments

Comments
 (0)