Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix i18n issues in models #1910

Merged
merged 1 commit into from
Mar 30, 2022
Merged

Fix i18n issues in models #1910

merged 1 commit into from
Mar 30, 2022

Conversation

int-y1
Copy link
Contributor

@int-y1 int-y1 commented Mar 29, 2022

How these i18n issues were detected:

from django.core.management.base import BaseCommand
from django.utils.translation import gettext_lazy as _

from django.apps import apps


class Command(BaseCommand):
    help = 'get all fields missing verbose_name'

    def handle(self, *args, **options):
        goodtype = type(_('yes'))
        for model in apps.get_models():
            if not model._meta.db_table.startswith('judge_'):
                continue
            msg = []
            # meta verbose_name
            if type(model._meta.verbose_name) != goodtype:
                msg.append('class verbose_name')
            if type(model._meta.verbose_name_plural) != goodtype:
                msg.append('class verbose_name_plural')
            # field verbose_name
            for field in model._meta.get_fields():
                if not hasattr(field, 'verbose_name'):
                    continue
                if field.name == 'id':
                    continue
                if type(field._verbose_name) != goodtype:
                    msg.append(f'{type(field._verbose_name)} {field.name}')
            # done
            if msg:
                print(model)
                for s in msg:
                    print(s)
                print()

This still outputs some i18n issues, but I couldn't find them in the frontend.

@codecov-commenter
Copy link

Codecov Report

Merging #1910 (9699f2d) into master (0191c77) will increase coverage by 0.05%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1910      +/-   ##
==========================================
+ Coverage   46.35%   46.40%   +0.05%     
==========================================
  Files         234      234              
  Lines       13089    13103      +14     
==========================================
+ Hits         6067     6081      +14     
  Misses       7022     7022              
Impacted Files Coverage Δ
judge/admin/problem.py 56.49% <100.00%> (ø)
judge/models/comment.py 39.61% <100.00%> (+0.79%) ⬆️
judge/models/contest.py 96.20% <100.00%> (ø)
judge/models/problem.py 89.26% <100.00%> (+0.09%) ⬆️
judge/models/profile.py 81.97% <100.00%> (ø)
judge/models/runtime.py 70.79% <100.00%> (ø)
judge/models/submission.py 90.50% <100.00%> (+0.18%) ⬆️
judge/models/ticket.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0191c77...9699f2d. Read the comment docs.

@quantum5 quantum5 merged commit dd7936d into DMOJ:master Mar 30, 2022
@int-y1 int-y1 deleted the i18n-model branch March 31, 2022 00:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants