This repository has been archived by the owner on Jan 19, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix bug 784854] Display form errors on top of form.
- Loading branch information
1 parent
93fbb01
commit af216ed
Showing
8 changed files
with
49 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +0,0 @@ | ||
import hashlib | ||
import re | ||
|
||
USERNAME_MAX_LENGTH = 30 | ||
|
||
|
||
def get_username(email): | ||
"""Calculate username from email address.""" | ||
from django.contrib.auth.models import User | ||
|
||
email = email.split('@')[0] | ||
username = re.sub(r'[^\w.@+-]', '-', email) | ||
username = username[:USERNAME_MAX_LENGTH] | ||
|
||
while User.objects.filter(username=username).exists(): | ||
username += '_' | ||
|
||
if username > USERNAME_MAX_LENGTH: | ||
# We failed to calculate a name for you, default to a | ||
# email digest. | ||
username = hashlib.sha1(email).hexdigest() | ||
|
||
return username | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters