mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 05:54:19 +01:00
Adds ondelete='CASCADE' to some models. (#979)
* Fixes `populate.py` to assign captains to teams.
* Adds `ondelete='CASCADE'` to most ForeignKeys in models
* Closes #794
* Test reset in team mode to test removing teams with captains
* Test deleting users/teams with awards to test cascading deletion
* `gen_team()` test helper now creates users for the team and assigns the first one as captain
* Added `Challenges.flags` relationship and moved the `Flags.challenge` relationship to a backref on `Challenges`
This commit is contained in:
10
populate.py
10
populate.py
@@ -304,6 +304,16 @@ if __name__ == '__main__':
|
||||
|
||||
db.session.commit()
|
||||
|
||||
if mode == 'teams':
|
||||
# Assign Team Captains
|
||||
print("GENERATING TEAM CAPTAINS")
|
||||
teams = Teams.query.all()
|
||||
for team in teams:
|
||||
captain = Users.query.filter_by(team_id=team.id).order_by(Users.id).limit(1).first()
|
||||
if captain:
|
||||
team.captain_id = captain.id
|
||||
db.session.commit()
|
||||
|
||||
# Generating Solves
|
||||
print("GENERATING SOLVES")
|
||||
if mode == 'users':
|
||||
|
||||
Reference in New Issue
Block a user