Skip to content

Commit

Permalink
mf
Browse files Browse the repository at this point in the history
  • Loading branch information
mam10eks committed Dec 10, 2024
1 parent 76e1433 commit eb290ac
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 13 deletions.
3 changes: 0 additions & 3 deletions application/Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ cd test
pytest
EOF

RUN cp -R /tira/src/tira_app/templates/tira/* /home/tira/.local/lib/python3.11/site-packages/tira_app/templates/tira/


########################################################################################################################
# Production Container #
########################################################################################################################
Expand Down
1 change: 1 addition & 0 deletions application/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ include =

[options.package_data]
tira_app.res = *.yml
tira_app.templates = *

[flake8]
max-line-length = 120
Expand Down
10 changes: 5 additions & 5 deletions application/src/tira_app/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def get_vm_ids(self, request: HttpRequest, user_id=None):

return vms if len(vms) >= 1 else [Authentication.get_default_vm_id(user_id)]

def _create_discourse_vm_group(self, team_name):
def _create_discourse_vm_group(self, team_name: str):
"""Create the vm group in the distaptor. Members of this group will be owners of the vm and
have all permissions.
Expand Down Expand Up @@ -312,16 +312,16 @@ def notify_organizers_of_new_participants(self, data, task_id):
"tira_org_" + slugify(task["organizer"].lower()),
)

def create_group(self, vm_id):
def create_group(self, team_name: str) -> dict[str, str]:
"""Create the vm group in the distaptor. Members of this group will be owners of the vm and
have all permissions.
:param vm_id: the name of the team.
:param team_name: the name of the team.
"""
vm_group = self._create_discourse_vm_group(vm_id)
vm_group = self._create_discourse_vm_group(team_name)
invite_link = self.discourse_client.create_invite_link(vm_group)
message = f"""Invite Mail: Please use this link to create your login for TIRA: {invite_link}.
After login to TIRA, you can find the credentials and usage examples for your
dedicated virtual machine {vm_id} here: https://www.tira.io/g/tira_vm_{vm_id}"""
dedicated virtual machine {team_name} here: https://www.tira.io/g/tira_vm_{team_name}"""

return {"message": message, "invite_link": invite_link}

Expand Down
2 changes: 1 addition & 1 deletion application/src/tira_app/endpoints/admin_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def admin_edit_organizer(request, organizer_id):
def admin_create_group(request, vm_id):
"""this is a rest endpoint to grant a user permissions on a vm"""
if auth.get_role(request=request) != "admin":
return HttpResponseNotAllowed("Access forbidden.")
return HttpResponseNotAllowed("Access forbidden.", status_code=403)

try:
vm_id = slugify(vm_id)
Expand Down
4 changes: 2 additions & 2 deletions application/src/tira_app/endpoints/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

try:
SOFTWARE_COUNT = len(json.loads(public_submissions(None).content.decode("UTF-8")))
DATASET_COUNT = len(modeldb.Dataset.objects.all())
TASK_COUNT = len(modeldb.Task.objects.all())
DATASET_COUNT = modeldb.Dataset.objects.count()
TASK_COUNT = modeldb.Task.objects.count()
except:
SOFTWARE_COUNT = 0
DATASET_COUNT = 0
Expand Down
4 changes: 2 additions & 2 deletions application/src/tira_app/endpoints/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
endpoints = [
path("anonymous/", include(anonymous_endpoints)),
path("datasets/", include(dataset_endpoints)),
path("systems/", include(system_endpoints)),
path("tirex/", include(tirex_endpoints)),
path("evaluations/", include(evaluation_endpoints)),
path("organizers/", include(organizer_endpoints)),
path("runs/", include(run_endpoints)),
path("systems/", include(system_endpoints)),
path("tirex/", include(tirex_endpoints)),
path("tasks/", include(task_endpoints)),
path("user/", include(user_endpoints)),
]

0 comments on commit eb290ac

Please sign in to comment.