-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix(Workspaces): ensure the presence of a token / server hash in memb…
…erships (#552) * Fix(Workspaces): ensure the presence of a token (and a server hash) for each membership * Fix(Workspaces): ensure the presence of a token (and a server hash) for each membership * Fix(Workspaces): ensure the presence of a token (and a server hash) for each membership
- Loading branch information
1 parent
294fc44
commit 1f1c4da
Showing
4 changed files
with
72 additions
and
7 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
46 changes: 46 additions & 0 deletions
46
hexa/workspaces/migrations/0037_alter_workspacemembership_access_token_and_more.py
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,46 @@ | ||
# Generated by Django 4.1.7 on 2023-09-25 07:54 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
def generate_tokens(apps, schema_editor): | ||
WorkspaceMembership = apps.get_model("workspaces", "WorkspaceMembership") | ||
|
||
# Filter the instances without access_token | ||
memberships_without_token = WorkspaceMembership.objects.filter( | ||
models.Q(access_token__isnull=True) | models.Q(access_token="") | ||
) | ||
|
||
for membership in memberships_without_token: | ||
membership.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("workspaces", "0036_service_account_key_migration"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(generate_tokens, reverse_code=migrations.RunPython.noop), | ||
migrations.AlterField( | ||
model_name="workspacemembership", | ||
name="access_token", | ||
field=models.TextField( | ||
blank=True, | ||
help_text="Access token that can be used to interact with the OpenHexa API (will be generated automatically, set to empty to regenerate a new token)", | ||
max_length=50, | ||
unique=True, | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="workspacemembership", | ||
name="notebooks_server_hash", | ||
field=models.TextField( | ||
blank=True, | ||
editable=False, | ||
help_text="Can be used to identify a notebook server for a given user and workspace (will be generated automatically)", | ||
unique=True, | ||
), | ||
), | ||
] |
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