Show the right flag for every country on profiles and the leaderboard

Open
#116 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
72/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
django, python
Domain
web-dev

Research direction

Start with Profile.flag and the _FLAGS dict in core/models.py, then read core/signals.py around line 37 where the country is taken from the GitHub location. Add a country data file (for example core/data/countries.json) and compute regional indicator flags from ISO alpha-2 codes, keeping the globe fallback. Done when the listed examples (Nigeria, Lagos, Nigeria, France, Cameroun) return the right flag, unknown values return the globe, and pytest covers these cases.

Written by the indexing model from the issue text.

Description

enhancement good first issue

Context

Profile.flag in core/models.py uses a hand-written _FLAGS dict that only covers some African countries; everyone else gets a globe. The country comes from the free-text GitHub location (core/signals.py, line 37), so values like "Lagos, Nigeria" or "Paris" don't match either.

What to do

  • Add a small data file (e.g. core/data/countries.json) mapping country names in English and French to ISO 3166-1 alpha-2 codes.
  • Compute the flag from the code with regional indicator symbols (each letter becomes chr(0x1F1E6 + ord(letter) - ord("A"))), so every country works.
  • Match the last part of a location like "Lagos, Nigeria" too.
  • Keep the globe fallback when nothing matches.

Acceptance criteria

  • "Nigeria", "nigeria", "Lagos, Nigeria", "France" and "Cameroun" give the right flag
  • Unknown values still return the globe
  • Unit tests for these cases

Run it locally

git clone https://github.com/<your-username>/opentoall.git && cd opentoall
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
python manage.py migrate
python manage.py seed_demo   # demo data for the UI
python manage.py runserver   # http://localhost:8000
pytest                       # must pass before you open the PR

See CONTRIBUTING.md for conventions (Conventional Commits, one PR per issue, link the PR with "Closes #").


Questions are welcome. Comment here to get assigned before you start, so two people don't work on the same thing.

— Max

Dominant language
Python
Stars
5
Forks
3
Avg merge
2d 50m
Merged PRs (30d)
31

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Ymax27/opentoall

All issues in Ymax27/opentoall

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.