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

Switching to avoid leading zeros in future memberID creations #1150

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions open_humans/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ def get_grant_project_image_upload_path(instance, filename):

def random_member_id():
"""
Return a zero-padded string from 00000000 to 99999999 that's not in use by
any Member.
Return a zero-padded string from 10000000 to 99999999 that's not in use by
any Member. Previously was 00000000, but the leading zero was dropped by many
programs and caused immense headaches, so switching to avoid the leading zero
in member numbers.
"""

def random_id():
return str("{0:08d}").format(random.randint(0, 99_999_999))
return str("{0:08d}").format(random.randint(10_000_000, 99_999_999))

member_id = random_id()

Expand Down