Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce archive.tira.io to prepare for usage in pyterrier-artifacts #671

Open
wants to merge 150 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 138 commits
Commits
Show all changes
150 commits
Select commit Hold shift + click to select a range
1a5fe8d
rough prototype that would be compatible with alpha pyterrier artifac…
mam10eks Aug 29, 2024
93f508f
helper method to get tasks
mam10eks Sep 3, 2024
860cf8c
use prepared docker image
mam10eks Sep 24, 2024
23d835d
Start lightweight client-side validation of formats #666
mam10eks Sep 24, 2024
445abd9
Merge pull request #667 from tira-io/development
mam10eks Sep 24, 2024
fc9d6ea
improve formatting
mam10eks Sep 24, 2024
fef5a28
prepare command for export for data.tira.io #659
mam10eks Sep 24, 2024
35ff580
use dedicated formatting error codes #666
mam10eks Sep 24, 2024
254fdb5
prepare export
mam10eks Sep 25, 2024
b4493f1
add datasets overview
mam10eks Sep 26, 2024
f9f7540
add system view
mam10eks Sep 26, 2024
2512a2a
we now use https://github.com/tira-io/tira-data/blob/main/data/create…
mam10eks Sep 26, 2024
6a463c1
add links to datasets and public softwares
mam10eks Sep 27, 2024
7e928d8
prepare App meni
mam10eks Oct 2, 2024
c2a054f
prepare UI improvements
mam10eks Oct 2, 2024
0a65543
add login method
mam10eks Oct 2, 2024
204917e
adjust breadcrumb and allow to traversal
mam10eks Oct 3, 2024
7f6522b
Allow to use well-known
mam10eks Nov 21, 2024
d59511e
Allow to use well-known
mam10eks Nov 21, 2024
025fde2
fix typescript build
mam10eks Nov 25, 2024
4ef66f1
mf
mam10eks Nov 25, 2024
e4b6d97
improve pipeline
mam10eks Nov 25, 2024
a4e28df
mf
mam10eks Nov 25, 2024
6edf44f
mf
mam10eks Nov 25, 2024
5e91144
mf
mam10eks Nov 25, 2024
f208066
mf
mam10eks Nov 25, 2024
405e040
mf
mam10eks Nov 25, 2024
9b231d4
mf
mam10eks Nov 25, 2024
aa32297
mf
mam10eks Nov 25, 2024
b7ba950
mf
mam10eks Nov 25, 2024
7a2e01e
prepare anonymous uploads
mam10eks Nov 26, 2024
c6b5164
refactor release.yml to publish.yml
mam10eks Nov 26, 2024
21701d1
refactor usage of inject method
mam10eks Nov 26, 2024
dd9499c
allow posts in dev environment
mam10eks Nov 28, 2024
0669bb9
incorproate csrf via userinfo via inject
mam10eks Nov 28, 2024
57d2b8a
incorproate csrf via userinfo via inject
mam10eks Nov 28, 2024
d32c27f
incorproate csrf via userinfo via inject
mam10eks Nov 28, 2024
a56613b
Implement first version of run-file formats
mam10eks Nov 28, 2024
2700870
add format to datasets
mam10eks Nov 28, 2024
9c24422
implement run serializers
mam10eks Nov 29, 2024
4236cf0
add ir_datasets_id and chatnoir_id to datasets
mam10eks Nov 29, 2024
e23e323
adjust DatasetInfo type
mam10eks Nov 29, 2024
a17bfab
add pypi version with format checks
mam10eks Nov 29, 2024
8b4d340
add migrations
mam10eks Nov 29, 2024
239bbf2
adjust datasets listing endpoint
mam10eks Nov 29, 2024
b52e9db
adjust datasets listing endpoint
mam10eks Nov 29, 2024
d794378
adjust datasets listing endpoint
mam10eks Nov 29, 2024
00f58ce
adjust datasets listing endpoint
mam10eks Nov 29, 2024
fec6afb
adjust systems listing endpoint
mam10eks Nov 29, 2024
baa29c5
adjust systems listing endpoint
mam10eks Nov 29, 2024
3c7e307
mf
mam10eks Nov 29, 2024
07948e0
mf
mam10eks Nov 29, 2024
474d090
mf
mam10eks Nov 29, 2024
47c8d1a
mf
mam10eks Nov 29, 2024
39dadec
mf
mam10eks Nov 29, 2024
4804fec
mf
mam10eks Nov 29, 2024
0585f2a
dataset search tests
mam10eks Nov 29, 2024
c06ec0e
mf
mam10eks Nov 29, 2024
9ffeec5
do not send credentials to archived pages
mam10eks Nov 29, 2024
66b2189
prepare form to claim submissions
mam10eks Nov 30, 2024
62e0013
refactor SERP rendering with DiffIr
mam10eks Nov 30, 2024
a77fc87
refactor SERP rendering with DiffIr
mam10eks Nov 30, 2024
eb0f3b0
refactor SERP rendering with DiffIr
mam10eks Nov 30, 2024
e516e69
add mirrors to datasets
mam10eks Dec 1, 2024
07af7e6
mf
mam10eks Dec 1, 2024
b96adac
mf
mam10eks Dec 1, 2024
df383d7
mf
mam10eks Dec 1, 2024
36b94ec
add git to prod container
mam10eks Dec 1, 2024
c55519b
mf
mam10eks Dec 1, 2024
ba6aa0d
mf
mam10eks Dec 1, 2024
3ac877e
mf
mam10eks Dec 1, 2024
4a0a1df
mf
mam10eks Dec 1, 2024
1b5b926
mf
mam10eks Dec 1, 2024
7b4c908
allow for multiple ir-datasets for a single tira dataset
mam10eks Dec 1, 2024
f5f5525
allow anonymous uploads
mam10eks Dec 2, 2024
2f0412a
allow anonymous uploads
mam10eks Dec 2, 2024
f94ae8c
allow anonymous uploads
mam10eks Dec 2, 2024
858ea2e
allow anonymous uploads
mam10eks Dec 2, 2024
1b9d246
allow anonymous uploads
mam10eks Dec 2, 2024
f341349
Fix TemporaryDirectory arguments
janheinrichmerker Dec 2, 2024
d9f334b
Merge pull request #670 from tira-io/janheinrichmerker-patch-1
mam10eks Dec 2, 2024
dc447d0
fix tempfile
mam10eks Dec 2, 2024
9ecab9e
mf
mam10eks Dec 2, 2024
80c17d8
add endpoint to upload uuids
mam10eks Dec 2, 2024
a0759e1
add endpoint to upload uuids
mam10eks Dec 2, 2024
dc6a811
add endpoint to upload uuids
mam10eks Dec 2, 2024
75221ec
add endpoint to upload uuids
mam10eks Dec 2, 2024
a0845fd
use archive.tira.io
mam10eks Dec 3, 2024
b90a230
improve TiraMenu
mam10eks Dec 3, 2024
b26b6e1
mf
mam10eks Dec 3, 2024
e1e34d1
mf
mam10eks Dec 3, 2024
b6920a2
mf
mam10eks Dec 3, 2024
f66dcaa
improve method to create vms
mam10eks Dec 3, 2024
cb4cb3e
mf
mam10eks Dec 3, 2024
8767983
mf
mam10eks Dec 3, 2024
2eec7bf
mf
mam10eks Dec 3, 2024
50641cf
mf
mam10eks Dec 3, 2024
9478035
mf
mam10eks Dec 3, 2024
7880300
mf
mam10eks Dec 3, 2024
6b4e8a7
mf
mam10eks Dec 3, 2024
8ec7eb8
mf
mam10eks Dec 4, 2024
16c54a7
mf
mam10eks Dec 4, 2024
c082f42
mf
mam10eks Dec 4, 2024
b4d7fd4
mf
mam10eks Dec 4, 2024
2afc21f
mf
mam10eks Dec 4, 2024
bcdd449
mf
mam10eks Dec 4, 2024
67acebb
fix inject in vue
mam10eks Dec 4, 2024
3a883c1
mf
mam10eks Dec 4, 2024
8515370
mf
mam10eks Dec 4, 2024
9932d04
mf
mam10eks Dec 5, 2024
8253989
deploy to pypi via Github Action
mam10eks Dec 5, 2024
f480c5a
mf
mam10eks Dec 9, 2024
4e21c03
mf
mam10eks Dec 9, 2024
0532ceb
mf
mam10eks Dec 9, 2024
0105b62
Fix code scanning alert no. 229: Reflected server-side cross-site scr…
mam10eks Dec 10, 2024
e4cbbd0
Fix code scanning alert no. 225: Reflected server-side cross-site scr…
mam10eks Dec 10, 2024
de67d58
resolve problem pointed out in review
mam10eks Dec 10, 2024
97f357e
adjust rest schema
mam10eks Dec 10, 2024
29577e2
fix security vulnerability
mam10eks Dec 10, 2024
fe66a88
fix linter
mam10eks Dec 10, 2024
1955a99
adjust rest schema
mam10eks Dec 10, 2024
43db15c
adjust rest schema
mam10eks Dec 10, 2024
0719ce5
mf
mam10eks Dec 10, 2024
71c710f
Merge pull request #672 from tira-io/main
mam10eks Dec 10, 2024
76e1433
add rest endpoint to doanload submissions
mam10eks Dec 10, 2024
eb290ac
mf
mam10eks Dec 10, 2024
0b38e76
use environment variables to overwrite rest api settings
mam10eks Dec 10, 2024
b0744b2
mf
mam10eks Dec 10, 2024
73257d6
mf
mam10eks Dec 10, 2024
b599d00
mf
mam10eks Dec 10, 2024
805e863
mf
mam10eks Dec 10, 2024
a452795
mf
mam10eks Dec 10, 2024
297175c
mf
mam10eks Dec 10, 2024
59771d4
mf
mam10eks Dec 10, 2024
f790c29
mf
mam10eks Dec 11, 2024
bff6b05
add download method
mam10eks Dec 11, 2024
7a7a3e6
mf
mam10eks Dec 11, 2024
1f8a59f
mf
mam10eks Dec 12, 2024
97df57d
add new logo for archive.tira.io
mam10eks Dec 13, 2024
9844cba
mf
mam10eks Dec 13, 2024
f2a76a3
mf
mam10eks Dec 13, 2024
a119abf
add loading screen
mam10eks Dec 13, 2024
3bcef67
mf
mam10eks Dec 13, 2024
d6dbf64
loading
mam10eks Dec 13, 2024
46739d4
start to use router-links
mam10eks Dec 13, 2024
58568b8
fix scroll behaviour
mam10eks Dec 13, 2024
33d91ff
mf
mam10eks Dec 16, 2024
f28959e
fix archive bug
mam10eks Dec 18, 2024
a8199af
fix archive bug
mam10eks Dec 18, 2024
0d43db1
fix archive bug
mam10eks Dec 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .devcontainer/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#docker build -t webis/tira:dev-container-0.0.1 -f .devcontainer/Dockerfile.dev .
FROM ubuntu:24.04

ENV TZ=Europe/Berlin
Expand All @@ -20,7 +21,11 @@ RUN <<EOF
useradd -ms /bin/bash dev
echo 'dev:1234' | chpasswd
usermod -aG sudo dev
usermod -aG docker dev
usermod -aG docker dev
# Sometimes, the ubuntu user is used in the dev container
echo 'ubuntu:1234' | chpasswd
usermod -aG sudo ubuntu
usermod -aG docker ubuntu
EOF


Expand Down Expand Up @@ -90,3 +95,4 @@ RUN mkdir -p /usr/share/umlet \
&& unzip download.zip
USER dev
RUN pip3 install sphinx furo myst-parser sphinx-toolbox sphinx-design sphinxcontrib-plantuml sphinxcontrib-umlet

7 changes: 6 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
"args": [
"run_develop"
],
"env": {
"TIRA_API_BASE_URL": "https://127.0.0.1:8080",
"TIRA_GRPC_BASE_URL": "https://127.0.0.1:8080",
"TIRA_ARCHIVED_URL": "https://127.0.0.1:8080"
},
"django": true,
"autoStartBrowser": false,
"program": "${workspaceFolder:Backend}/src/manage.py"
Expand Down Expand Up @@ -144,7 +149,7 @@
},

// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"
"remoteUser": "ubuntu",

// Needed for parts of the python-client that build and run docker containers
"privileged": true,
Expand Down
4 changes: 3 additions & 1 deletion .devcontainer/devfiles/nginx/tira-backend.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ server {
include /config/nginx/snippets/proxy.conf;
include /config/nginx/snippets/authelia-authrequest.conf;
add_header 'Access-Control-Allow-Origin' 'https://127.0.0.1:8082';
add_header 'Access-Control-Allow-Method' 'GET, POST, OPTIONS, PUT, PATCH, DELETE';
add_header 'Access-Control-Allow-Headers' 'x-csrftoken, content-type, accept,';
add_header 'Access-Control-Allow-Credentials' 'true';
proxy_pass $upstream;
}
}
}
4 changes: 1 addition & 3 deletions .devcontainer/docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
services:
devenv:
build:
context: ./
dockerfile: Dockerfile.dev
image: webis/tira:dev-container-0.0.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am am in favor that you use the prebuilt container but would vote that this change is not checked in into the repo

restart: unless-stopped
environment:
# TIRA Frontend Environment Variables
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,20 @@ jobs:
- name: Install mypy
run: pip3 install mypy
- name: Run mypy on backend
continue-on-error: true
working-directory: ${{github.workspace}}/application
run: |
mkdir .mypy_cache
mypy . --non-interactive --cache-dir=.mypy_cache/
- name: Run mypy on python-client
continue-on-error: true
working-directory: ${{github.workspace}}/python-client
run: |
mkdir .mypy_cache
mypy .--non-interactive --cache-dir=.mypy_cache/
- name: Fail Never
run: |
echo Hello

flake8:
runs-on: ubuntu-latest
Expand All @@ -40,12 +45,17 @@ jobs:
- name: Install flake8
run: pip3 install flake8
- name: Run flake8 on backend
continue-on-error: true
working-directory: ${{github.workspace}}/application
run: flake8 .
- name: Run flake8 on python-client
continue-on-error: true
working-directory: ${{github.workspace}}/python-client
run: flake8 .

- name: Fail Never
run: |
echo Hello

black:
runs-on: ubuntu-latest
timeout-minutes: 15
Expand Down Expand Up @@ -80,4 +90,4 @@ jobs:
run: isort --check .
- name: Run isort on python-client
working-directory: ${{github.workspace}}/python-client
run: isort --check .
run: isort --check .
44 changes: 40 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
name: Publish Docker images
name: Publish Artifacts

on:
release:
types: [published]
on: [push]

env:
REGISTRY: ghcr.io

jobs:
release-frontend:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Install dependencies
working-directory: ${{github.workspace}}/frontend
run: yarn --frozen-lockfile
- name: compile client
working-directory: ${{github.workspace}}/frontend
run: yarn build
- name: package code
working-directory: ${{github.workspace}}/frontend/static
run: zip -r ../../frontend-build.zip .
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: frontend-build.zip

build-and-push:
name: Push Docker image to GHCR
runs-on: ubuntu-latest
Expand All @@ -23,12 +45,24 @@ jobs:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# - name: Publish PyPi Package
# id: meta-frontend
# if: startsWith(github.ref, 'refs/tags/')
# working-directory: ${{github.workspace}}/python-client
# run:
# sudo apt-get install -y openjdk-11-jdk
# pip3 install .[test,dev]
# export TWINE_NON_INTERACTIVE=True
# export TWINE_PASSWORD=${{ secrets.PYPI_API_KEY}}
# make build-pypi-package
- name: Extract metadata (tags, labels) for Docker
id: meta-frontend
if: startsWith(github.ref, 'refs/tags/')
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/tira-io/tira-frontend
- name: Publish tira-frontend image
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: ${{ github.workspace }}/frontend
Expand All @@ -39,10 +73,12 @@ jobs:

- name: Extract metadata (tags, labels) for Docker
id: meta-backend
if: startsWith(github.ref, 'refs/tags/')
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/tira-io/tira-backend
- name: Publish tira-backend image
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: ${{ github.workspace }}/
Expand Down
2 changes: 1 addition & 1 deletion application/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ src/tira_vm_states.sqlite3
src/venv
src/__init__.py
src/config
src/tira_app/migrations/*.py
test/test-database
src/tira_app/migrations/__pycache__

src/tira_app/static/tira/dist/*
package-lock.json
Expand Down
5 changes: 2 additions & 3 deletions application/Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ cd test
pytest
EOF



########################################################################################################################
# Production Container #
########################################################################################################################
Expand All @@ -88,7 +86,7 @@ apt-get -qq update && apt-get -qq install -y locales
echo "en_US.UTF-8 UTF-8" | tee -a /etc/locale.gen && locale-gen

# Tools
apt-get -qq install -y python3 python3-dev
apt-get -qq install -y python3 python3-dev git
# For MariaDB
apt-get -qq install -y mariadb-client
#
Expand All @@ -114,6 +112,7 @@ EOF
# Final Configuration Stuff #
########################################################################################################################
USER tira
ENV LC_ALL=en_US.UTF-8
ENV PATH=/home/tira/.local/bin:$PATH
# CONFIGURE THE FOLLOWING ENVIRONMENT VARIABLES IN YOUR DOCKER-COMPOSE FILE
ENV HF_HOME=/home/tira/data/publicly-shared-datasets/huggingface/
Expand Down
9 changes: 9 additions & 0 deletions application/config/tira-application-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,12 @@ django_secret: !ENV ${DJANGO_SECRET:change-me!}
grpc_host: local
host_grpc_port: 50051
application_grpc_port: 50052

tira_rest_api:
base_url: !ENV ${TIRA_API_BASE_URL:https://www.tira.io}
grpc_url: !ENV ${TIRA_GRPC_BASE_URL:https://www.tira.io}
archived_url: !ENV ${TIRA_ARCHIVED_URL:https://archive.tira.io}
login_url: !ENV ${TIRA_LOGIN_URL:https://www.tira.io}
logout_url: !ENV ${TIRA_LOGOUT_URL:https://www.tira.io}
disraptor_url: !ENV ${TIRA_DISRAPTOR_URL:https://www.tira.io}
notifications_url: !ENV ${TIRA_NOTIFICATIONS_URL:https://www.tira.io}
6 changes: 5 additions & 1 deletion application/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ install_requires =
requests
randomname
tqdm
werkzeug
mysqlclient
python-gitlab==4.10.0
GitPython
Expand All @@ -26,7 +27,7 @@ install_requires =
markdown
PyGithub==1.59.1
django-extensions
discourse-client-in-disraptor==0.0.8
discourse-client-in-disraptor==0.0.10
# tira>=0.0.97
huggingface-hub
djangorestframework==3.15.1
Expand Down Expand Up @@ -62,6 +63,9 @@ include =

[options.package_data]
tira_app.res = *.yml
tira_app.templates.tira = *
tira_app.templates.tira.git_repo_template = *
tira_app.endpoints = aha

[flake8]
max-line-length = 120
Expand Down
11 changes: 11 additions & 0 deletions application/src/django_admin/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,4 +398,15 @@ def logger_config(log_dir: Path):
),
}

WELL_KNOWN = {
"api": custom_settings["tira_rest_api"]["base_url"],
"grpc": custom_settings["tira_rest_api"]["grpc_url"],
"archived": custom_settings["tira_rest_api"]["archived_url"],
"login": custom_settings["tira_rest_api"]["login_url"],
"logout": custom_settings["tira_rest_api"]["logout_url"],
"notifications": custom_settings["tira_rest_api"]["notifications_url"],
"disraptorURL": custom_settings["tira_rest_api"]["disraptor_url"],
}

CODE_SUBMISSION_REPOSITORY_NAMESPACE = "tira-io"
CSRF_TRUSTED_ORIGINS = ["https://127.0.0.1:8082", "https://127.0.0.1:8080", "https://127.0.0.1:8081"]
2 changes: 1 addition & 1 deletion application/src/manage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""Django's command-line utility for administrative tasks."""
import os
import sys
Expand Down
38 changes: 17 additions & 21 deletions application/src/tira_app/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,25 +276,15 @@ 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, vm):
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.
:param vm: a vm dict as returned by tira_model.get_vm
{"vm_id", "user_password", "roles", "host", "admin_name", "admin_pw", "ip", "ssh", "rdp", "archived"}
have all permissions.

"""
group_bio = f"""Members of this group have access to the virtual machine {vm['vm_id']}:<br><br>
<ul>
<li>Host: {vm['host']}</li>
<li>User: {vm['vm_id']}</li>
<li>Passwort: {vm['user_password']}</li>
<li>SSH Port: {vm['ssh']}</li>
<li>RDP Port: {vm['rdp']}</li>
<li>SSH Example: <code>sshpass -p {vm['user_password']} ssh {vm['vm_id']}@{vm['host']} -p {vm['ssh']} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no</code></li>
</ul><br><br>
Please contact us when you have questions.
"""
return self.discourse_client.create_group(f"tira_vm_{vm['vm_id']}", group_bio, 2)
group_bio = f"""Members of this team participate in shared tasks as {team_name}. <br><br>

Please do not hesitate to design your team's page accorging to your needs."""
return self.discourse_client.create_group(f"tira_vm_{team_name}", group_bio, 2)

def notify_organizers_of_new_participants(self, data, task_id):
task = model.get_task(task_id)
Expand Down Expand Up @@ -322,18 +312,18 @@ def notify_organizers_of_new_participants(self, data, task_id):
"tira_org_" + slugify(task["organizer"].lower()),
)

def create_group(self, vm):
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: a vm dict as returned by tira_model.get_vm
:param team_name: the name of the team.
"""
vm_group = self._create_discourse_vm_group(vm)
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['vm_id']} here: https://www.tira.io/g/tira_vm_{vm['vm_id']}"""
dedicated virtual machine {team_name} here: https://www.tira.io/g/tira_vm_{team_name}"""

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

def create_organizer_group(self, organizer_name, user_name):
group_bio = f"""Members of this team organize shared tasks in TIRA as in shared tasks as {organizer_name}.
Expand All @@ -352,6 +342,12 @@ def create_docker_group(self, team_name, user_name):
group_id = self.discourse_client.create_group(f"tira_vm_{slugify(team_name)}", group_bio, 0)
model.get_vm(team_name, create_if_none=True)
self.discourse_client.add_user_as_owner_to_group(group_id, user_name)
invite_link = self.discourse_client.create_invite_link(group_id)
return {
"group_id": group_id,
"invite_link": invite_link,
"group_link": f"https://www.tira.io/g/tira_vm_{slugify(team_name)}",
}

def user_is_organizer_for_endpoint(
self,
Expand Down
5 changes: 4 additions & 1 deletion application/src/tira_app/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from functools import wraps

from django.conf import settings
from django.http import Http404, HttpRequest, HttpResponseNotAllowed, HttpResponseRedirect, JsonResponse
from django.http import Http404, HttpRequest, HttpResponse, HttpResponseNotAllowed, HttpResponseRedirect, JsonResponse
from django.shortcuts import redirect
from django.urls import resolve

Expand Down Expand Up @@ -34,6 +34,9 @@ def check_permissions(func):

@wraps(func)
def func_wrapper(request: HttpRequest, *args, **kwargs):
if request.method == "OPTIONS":
return HttpResponse("allowed")

vm_id = kwargs.get("vm_id", None)
user_id = kwargs.get("user_id", None)
if vm_id is None and user_id is not None: # some endpoints say user_id instead of vm_id
Expand Down
Loading
Loading