mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-03 03:37:28 +01:00
Fix UserRank not being translatable
This commit is contained in:
parent
7cf1f40ff6
commit
e335797629
@ -113,7 +113,7 @@ def apply_all_updates(username):
|
|||||||
PackageRelease.commit_hash == package.update_config.last_commit)).count() > 0:
|
PackageRelease.commit_hash == package.update_config.last_commit)).count() > 0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
title = package.update_config.get_title()
|
title = package.update_config.title
|
||||||
ref = package.update_config.get_ref()
|
ref = package.update_config.get_ref()
|
||||||
|
|
||||||
rel = PackageRelease()
|
rel = PackageRelease()
|
||||||
|
@ -374,7 +374,7 @@ def modtools(username):
|
|||||||
if current_user.rank.at_least(new_rank):
|
if current_user.rank.at_least(new_rank):
|
||||||
if new_rank != user.rank:
|
if new_rank != user.rank:
|
||||||
user.rank = form["rank"].data
|
user.rank = form["rank"].data
|
||||||
msg = "Set rank of {} to {}".format(user.display_name, user.rank.get_title())
|
msg = "Set rank of {} to {}".format(user.display_name, user.rank.title)
|
||||||
add_audit_log(AuditSeverity.MODERATION, current_user, msg,
|
add_audit_log(AuditSeverity.MODERATION, current_user, msg,
|
||||||
url_for("users.profile", username=username))
|
url_for("users.profile", username=username))
|
||||||
else:
|
else:
|
||||||
|
@ -71,12 +71,13 @@ class AuditSeverity(enum.Enum):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def get_title(self):
|
@property
|
||||||
|
def title(self):
|
||||||
return self.name.replace("_", " ").title()
|
return self.name.replace("_", " ").title()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def choices(cls):
|
def choices(cls):
|
||||||
return [(choice, choice.get_title()) for choice in cls]
|
return [(choice, choice.title) for choice in cls]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def coerce(cls, item):
|
def coerce(cls, item):
|
||||||
|
@ -1358,14 +1358,15 @@ class PackageUpdateConfig(db.Model):
|
|||||||
else:
|
else:
|
||||||
return lazy_gettext("New tag %(tag_name)s found on the Git repo.", tag_name=self.last_tag)
|
return lazy_gettext("New tag %(tag_name)s found on the Git repo.", tag_name=self.last_tag)
|
||||||
|
|
||||||
def get_title(self):
|
@property
|
||||||
|
def title(self):
|
||||||
return self.last_tag or self.outdated_at.strftime("%Y-%m-%d")
|
return self.last_tag or self.outdated_at.strftime("%Y-%m-%d")
|
||||||
|
|
||||||
def get_ref(self):
|
def get_ref(self):
|
||||||
return self.last_tag or self.last_commit
|
return self.last_tag or self.last_commit
|
||||||
|
|
||||||
def get_create_release_url(self):
|
def get_create_release_url(self):
|
||||||
return self.package.get_url("packages.create_release", title=self.get_title(), ref=self.get_ref())
|
return self.package.get_url("packages.create_release", title=self.title, ref=self.get_ref())
|
||||||
|
|
||||||
|
|
||||||
class PackageAlias(db.Model):
|
class PackageAlias(db.Model):
|
||||||
|
@ -39,8 +39,28 @@ class UserRank(enum.Enum):
|
|||||||
def at_least(self, min):
|
def at_least(self, min):
|
||||||
return self.value >= min.value
|
return self.value >= min.value
|
||||||
|
|
||||||
def get_title(self):
|
@property
|
||||||
return self.name.replace("_", " ").title()
|
def title(self):
|
||||||
|
if self == UserRank.BANNED:
|
||||||
|
return lazy_gettext("Banned")
|
||||||
|
elif self == UserRank.NOT_JOINED:
|
||||||
|
return lazy_gettext("Not Joined")
|
||||||
|
elif self == UserRank.NEW_MEMBER:
|
||||||
|
return lazy_gettext("New Member")
|
||||||
|
elif self == UserRank.MEMBER:
|
||||||
|
return lazy_gettext("Member")
|
||||||
|
elif self == UserRank.TRUSTED_MEMBER:
|
||||||
|
return lazy_gettext("Trusted Member")
|
||||||
|
elif self == UserRank.APPROVER:
|
||||||
|
return lazy_gettext("Approver")
|
||||||
|
elif self == UserRank.EDITOR:
|
||||||
|
return lazy_gettext("Editor")
|
||||||
|
elif self == UserRank.BOT:
|
||||||
|
return lazy_gettext("Bot")
|
||||||
|
elif self == UserRank.MODERATOR:
|
||||||
|
return lazy_gettext("Moderator")
|
||||||
|
elif self == UserRank.ADMIN:
|
||||||
|
return lazy_gettext("Admin")
|
||||||
|
|
||||||
def to_name(self):
|
def to_name(self):
|
||||||
return self.name.lower()
|
return self.name.lower()
|
||||||
@ -50,7 +70,7 @@ class UserRank(enum.Enum):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def choices(cls):
|
def choices(cls):
|
||||||
return [(choice, choice.get_title()) for choice in cls]
|
return [(choice, choice.title) for choice in cls]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def coerce(cls, item):
|
def coerce(cls, item):
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
<div class="row {% if entry.severity == entry.severity.NORMAL %}text-muted{% endif %}">
|
<div class="row {% if entry.severity == entry.severity.NORMAL %}text-muted{% endif %}">
|
||||||
<div class="col-sm-auto text-center" style="width: 50px;"
|
<div class="col-sm-auto text-center" style="width: 50px;"
|
||||||
title="{{ _('Severity: %(sev)s.', sev=entry.severity.get_title()) }}">
|
title="{{ _('Severity: %(sev)s.', sev=entry.severity.title) }}">
|
||||||
{% if entry.severity == entry.severity.MODERATION %}
|
{% if entry.severity == entry.severity.MODERATION %}
|
||||||
<i class="fas fa-exclamation-triangle" style="color: yellow;"></i>
|
<i class="fas fa-exclamation-triangle" style="color: yellow;"></i>
|
||||||
{% elif entry.severity == entry.severity.EDITOR %}
|
{% elif entry.severity == entry.severity.EDITOR %}
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% if r.author.rank == r.author.rank.BOT %}
|
{% if r.author.rank == r.author.rank.BOT %}
|
||||||
<span class="badge bg-dark">
|
<span class="badge bg-dark">
|
||||||
{{ r.author.rank.get_title() }}
|
{{ r.author.rank.title }}
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
<i class="fas fa-user me-2"></i>
|
<i class="fas fa-user me-2"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{{ user.rank.get_title() }}
|
{{ user.rank.title }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span class="col-sm {{ user.rank }}">
|
<span class="col-sm {{ user.rank }}">
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
<span class="btn">
|
<span class="btn">
|
||||||
<i class="fas fa-user"></i>
|
<i class="fas fa-user"></i>
|
||||||
<span class="count">
|
<span class="count">
|
||||||
{{ user.rank.get_title() }}
|
{{ user.rank.title }}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user