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

Improve muscle recognition #1041

Merged

Conversation

ImTheTom
Copy link
Contributor

Proposed Changes

  • Adds a name_en column to the muscle view. This can be used as an alternative name.

Please check that the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features) (Very minimal though. Might make some more)
  • Added yourself to AUTHORS.rst

Other questions

  • Do users need to run some commmands in their local instances due to this PR
    (e.g. database migration)? Yes. Added a migration in exercises.

  • Placing it up as a draft at the moment for general feedback on what I'm missing.

Images

Muscle-alt-name

Json response

        {
            "id": 11,
            "name": "Biceps femoris",
            "is_front": false,
            "name_en": "Hamstrings",
            "image_url_main": "/static/images/muscles/main/muscle-11.svg",
            "image_url_secondary": "/static/images/muscles/secondary/muscle-11.svg"
        },
        {
            "id": 13,
            "name": "Brachialis",
            "is_front": true,
            "name_en": "",
            "image_url_main": "/static/images/muscles/main/muscle-13.svg",
            "image_url_secondary": "/static/images/muscles/secondary/muscle-13.svg"
        }

@rolandgeider rolandgeider linked an issue May 11, 2022 that may be closed by this pull request
@rolandgeider
Copy link
Member

Looks great!

What still needs to be done is mark those new names as translatable so they can be imported into weblate. That's the extract-i18n.py file I was talking about in the issue. Basically just adding a [i.name_en for i in Muscle.objects.all() if i.name_en] to the list of items should be enough. Then we can also do {% translate muscle.name_en %} in the template

I'm also thinking about directly updating the names in the migration file, then there's no need to run an additional step to load the fixture. Something like along these lines:

muscle_names = [
    (1, 'Biceps'),
    (2, 'Shoulders'),
    (4, 'Chest'),
    (5, 'Triceps'),
    ...
]


def set_names(apps, schema_editor):
    Muscle = apps.get_model('exercises', 'Muscle')
    for mapping in muscle_names:
        m = Muscle.objects.get(pk=mapping[0])
        m.name_en = mapping[1]
        m.save()

 operations = [
        ....
        migrations.RunPython(set_names),
    ]

@ImTheTom
Copy link
Contributor Author

Yeah sweet. Thanks for the feedback. I'll look into it tonight 👍

@rolandgeider
Copy link
Member

🚀

@rolandgeider rolandgeider merged commit 84cae7a into wger-project:master May 12, 2022
@ImTheTom ImTheTom deleted the improve-muscle-recognition-1009 branch May 19, 2022 10:08
@ImTheTom ImTheTom changed the title Draft: Improve muscle recognition Improve muscle recognition May 22, 2022
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.

Improve muscle recognition
2 participants