Add Team/TeamRole/TeamMembership/TeamPicture models and fix two test bugs
- Fix Member.create(): post_save signal creates Member immediately on User creation,
so new users always hit the hasattr branch; check `created` flag to set initial
password and notes for genuinely new users
- Fix Season.for_date(): replace get() with filter().order_by("-start_date").first()
to handle overlapping seasons gracefully and raise DoesNotExist when none match
- Add TeamRole, Team, TeamMembership, TeamPicture models with rules permissions
- Add migration 0002 for new models
- Add test suites for members and teams covering all new model behaviour
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -83,7 +83,13 @@ class Member(RulesModel):
|
||||
|
||||
if hasattr(user, "member"):
|
||||
member = user.member
|
||||
if password is not None and password != "":
|
||||
if created:
|
||||
if password is None or password == "":
|
||||
initial_password = "".join(secrets.choice(string.ascii_letters + string.digits) for _ in range(20))
|
||||
password = initial_password
|
||||
member.notes = f"Initial password: {initial_password}"
|
||||
user.set_password(password)
|
||||
elif password is not None and password != "":
|
||||
user.set_password(password)
|
||||
else:
|
||||
member = cls()
|
||||
|
||||
Reference in New Issue
Block a user