-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from matorral-project/more-fixes-towards-mvp-2
More fixes towards mvp 2
- Loading branch information
Showing
8 changed files
with
115 additions
and
15 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Generated by Django 4.2.10 on 2024-03-02 00:27 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("sprints", "0008_alter_historicalsprint_options_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name="sprint", | ||
options={ | ||
"get_latest_by": "created_at", | ||
"ordering": ["starts_at", "-updated_at"], | ||
"verbose_name": "sprint", | ||
"verbose_name_plural": "sprints", | ||
}, | ||
), | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Generated by Django 4.2.10 on 2024-03-02 13:01 | ||
|
||
from django.db import migrations | ||
|
||
|
||
def create_default_workspace(apps, schema_editor): | ||
""" | ||
Creates the default workspace and add all the users to it | ||
""" | ||
|
||
User = apps.get_model("users", "User") | ||
|
||
if User.objects.count() == 0: | ||
# No users, nothing to do: the workspace will be created when the first user is created | ||
return | ||
|
||
# Get the first superuser or admin user | ||
admin_user = User.objects.filter(is_superuser=True).first() | ||
|
||
if admin_user is None: | ||
admin_user = User.objects.filter(is_staff=True).first() | ||
|
||
if admin_user is None: | ||
admin_user = User.objects.first() | ||
|
||
Workspace = apps.get_model("workspaces", "Workspace") | ||
default_workspace = Workspace.objects.create( | ||
name="Default Workspace", slug="default-workspace", owner=admin_user | ||
) | ||
|
||
# Now add all the users to the default workspace | ||
for user in User.objects.all(): | ||
default_workspace.members.add(user) | ||
|
||
|
||
def delete_default_workspace(apps, schema_editor): | ||
Workspace = apps.get_model("workspaces", "Workspace") | ||
Workspace.objects.filter(slug="default-workspace").delete() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("workspaces", "0004_auto_20200815_1608"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(create_default_workspace, reverse_code=delete_default_workspace), | ||
] |
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