Skip to content

Commit

Permalink
Revert "Merge branch 'development' into phillips/custom_parameters"
Browse files Browse the repository at this point in the history
This reverts commit c72d328, reversing
changes made to cfc0604.
  • Loading branch information
Juan Puerto committed Jan 29, 2025
1 parent c72d328 commit bc7cc0c
Show file tree
Hide file tree
Showing 15 changed files with 2 additions and 597 deletions.
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Django==5.1.3
django-cors-headers==3.13.0
django-picklefield==3.1
django-q2==1.7.3
djangorestframework==3.15.2
djangorestframework==3.14.0
Flask==2.2.2
globus-sdk==3.12.0
h11==0.14.0
Expand Down
10 changes: 1 addition & 9 deletions src/user_workspaces_server/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,4 @@
from user_workspaces_server import models

# Register your models here.
admin.site.register(
[
models.ExternalUserMapping,
models.UserQuota,
models.Workspace,
models.Job,
models.SharedWorkspaceMapping,
]
)
admin.site.register([models.ExternalUserMapping, models.UserQuota, models.Workspace, models.Job])

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

28 changes: 0 additions & 28 deletions src/user_workspaces_server/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,31 +107,3 @@ def __str__(self):
f"{self.id}: {self.user_id.username if self.user_id else 'User Missing'} -"
f" {self.user_authentication_name}"
)


class SharedWorkspaceMapping(models.Model):
original_workspace_id = models.ForeignKey(
Workspace,
on_delete=models.SET_NULL,
null=True,
related_name="original_workspace_set",
)
shared_workspace_id = models.ForeignKey(
Workspace, on_delete=models.CASCADE, related_name="shared_workspace_set"
)
last_resource_options = models.JSONField(blank=True, null=True)
last_job_type = models.CharField(max_length=64, null=True)
is_accepted = models.BooleanField(default=False)
datetime_share_created = models.DateTimeField(null=True)

@staticmethod
def get_query_param_fields():
return ["is_accepted"]

@staticmethod
def get_dict_fields():
return [
"is_accepted",
"last_resource_options",
"last_job_type",
]
36 changes: 0 additions & 36 deletions src/user_workspaces_server/serializers.py

This file was deleted.

55 changes: 0 additions & 55 deletions src/user_workspaces_server/tasks.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import datetime
import logging
import os
import shutil

from asgiref.sync import async_to_sync
from channels.layers import get_channel_layer
from django.apps import apps
from django.conf import settings
from django.db.models import Sum
from django.template.loader import render_to_string
from django_q.brokers import get_broker
from django_q.tasks import async_task

Expand Down Expand Up @@ -287,56 +285,3 @@ def update_user_quota_core_hours(user_quota_id):
workspace_id__user_id=user_quota.user_id
).aggregate(Sum("core_hours"))["core_hours__sum"]
user_quota.save()


def initialize_shared_workspace(shared_workspace_mapping_id: int):
shared_workspace_mapping = models.SharedWorkspaceMapping.objects.get(
pk=shared_workspace_mapping_id
)
original_workspace = shared_workspace_mapping.original_workspace_id
shared_workspace = shared_workspace_mapping.shared_workspace_id

main_storage = apps.get_app_config("user_workspaces_server").main_storage
external_user_mapping = main_storage.storage_user_authentication.has_permission(
shared_workspace.user_id
)

# Set the shared_workspace file path
shared_workspace.file_path = os.path.join(
external_user_mapping.external_username, str(shared_workspace.pk)
)

try:
# Copy non . directories
shutil.copytree(
os.path.join(main_storage.root_dir, original_workspace.file_path),
os.path.join(main_storage.root_dir, shared_workspace.file_path),
ignore=shutil.ignore_patterns(".*"),
symlinks=True,
)
main_storage.set_ownership(
shared_workspace.file_path, external_user_mapping, recursive=True
)
except Exception as e:
logger.exception(f"Copying files for {shared_workspace_mapping} failed: {e}")

async_update_workspace(shared_workspace.pk)

message = render_to_string(
"email_templates/share_email.txt",
context={
"sharer": original_workspace.user_id,
"receiver": shared_workspace.user_id,
"mapping_details": shared_workspace_mapping,
"original_workspace": original_workspace,
},
)
async_task(
"django.core.mail.send_mail",
"Invitation to Share a Workspace",
message,
None,
[shared_workspace.user_id.email],
)

shared_workspace.save()

This file was deleted.

30 changes: 0 additions & 30 deletions src/user_workspaces_server/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
job_type_view,
job_view,
passthrough_view,
shared_workspace_view,
status_view,
user_view,
user_workspaces_server_token_view,
workspace_view,
)
Expand Down Expand Up @@ -79,41 +77,13 @@
),
]

user_view_patterns = [
path(
"",
user_view.UserView.as_view(),
name="users",
)
]

shared_workspace_view_patterns = [
path(
"",
shared_workspace_view.SharedWorkspaceView.as_view(),
name="shared_workspaces",
),
path(
"<int:shared_workspace_id>/",
shared_workspace_view.SharedWorkspaceView.as_view(),
name="shared_workspaces_with_id",
),
path(
"<int:shared_workspace_id>/<str:put_type>/",
shared_workspace_view.SharedWorkspaceView.as_view(),
name="shared_workspaces_put_type",
),
]

urlpatterns = [
path("tokens/", include(token_view_patterns)),
path("workspaces/", include(workspace_view_patterns)),
path("jobs/", include(job_view_patterns)),
path("job_types/", include(job_type_view_patterns)),
path("passthrough/", include(passthrough_view_patterns)),
path("parameters/", include(parameter_view_patterns)),
path("users/", include(user_view_patterns)),
path("shared_workspaces/", include(shared_workspace_view_patterns)),
path("status/", status_view.StatusView.as_view(), name="status"),
]

Expand Down
Loading

0 comments on commit bc7cc0c

Please sign in to comment.