-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge: branch '109-add-commands-to-init-single-instance' into 'dev'
- Loading branch information
Showing
13 changed files
with
528 additions
and
337 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,32 @@ | ||
[ | ||
{ | ||
"git_repo_url": "https://github.com/rmnldwg/lydata", | ||
"revision": "main", | ||
"data_path": "2021-usz-oropharynx/data.csv" | ||
}, | ||
{ | ||
"git_repo_url": "https://github.com/rmnldwg/lydata", | ||
"revision": "main", | ||
"data_path": "2021-clb-oropharynx/data.csv" | ||
}, | ||
{ | ||
"git_repo_url": "https://github.com/rmnldwg/lydata", | ||
"revision": "main", | ||
"data_path": "2023-isb-multisite/data.csv" | ||
}, | ||
{ | ||
"git_repo_url": "https://github.com/rmnldwg/lydata", | ||
"revision": "main", | ||
"data_path": "2023-clb-multisite/data.csv" | ||
}, | ||
{ | ||
"git_repo_url": "https://github.com/rmnldwg/lydata.private", | ||
"revision": "2023-usz-hypopharynx-larynx", | ||
"data_path": "2023-usz-hypopharynx-larynx/data.csv" | ||
}, | ||
{ | ||
"git_repo_url": "https://github.com/rmnldwg/lydata.private", | ||
"revision": "2023-hvh-oropharynx", | ||
"data_path": "2023-hvh-oropharynx/data.csv" | ||
} | ||
] |
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,38 @@ | ||
[ | ||
{ | ||
"name": "University Hospital Zurich", | ||
"shortname": "USZ", | ||
"street": "Rämistrasse 100", | ||
"city": "Zürich", | ||
"country": "CH", | ||
"phone": "+41442553566", | ||
"logo": "logos/usz.png" | ||
}, | ||
{ | ||
"name": "Centre Léon Bérard", | ||
"shortname": "CLB", | ||
"street": "28 Rue Laennec", | ||
"city": "Lyon", | ||
"country": "FR", | ||
"phone": "+33478782828", | ||
"logo": "logos/clb.png" | ||
}, | ||
{ | ||
"name": "Inselspital Bern", | ||
"shortname": "ISB", | ||
"street": "Freiburgstrasse 15", | ||
"city": "Bern", | ||
"country": "CH", | ||
"phone": "+41316322111", | ||
"logo": "logos/isb.png" | ||
}, | ||
{ | ||
"name": "Vall d'Hebron Barcelona Hospital", | ||
"shortname": "HVH", | ||
"street": "Passeig de la Vall d'Hebron, 119-129", | ||
"city": "Barcelona", | ||
"country": "ES", | ||
"phone": "+34934893000", | ||
"logo": "logos/hvh.png" | ||
} | ||
] |
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,23 @@ | ||
[ | ||
{ | ||
"git_repo_owner": "rmnldwg", | ||
"git_repo_name": "lynference", | ||
"revision": "win-graph-v1", | ||
"params_path": "params.yaml", | ||
"num_samples": 100 | ||
}, | ||
{ | ||
"git_repo_owner": "rmnldwg", | ||
"git_repo_name": "lynference", | ||
"revision": "complete-part1-v1", | ||
"params_path": "params.yaml", | ||
"num_samples": 100 | ||
}, | ||
{ | ||
"git_repo_owner": "rmnldwg", | ||
"git_repo_name": "lynference", | ||
"revision": "add-I-to-II-and-IV-to-V", | ||
"params_path": "params.yaml", | ||
"num_samples": 100 | ||
} | ||
] |
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,83 @@ | ||
[ | ||
{ | ||
"email": "roman.ludwig@usz.ch", | ||
"first_name": "Roman", | ||
"last_name": "Ludwig", | ||
"institution": "USZ", | ||
"is_active": true, | ||
"is_staff": true, | ||
"is_superuser": true | ||
}, | ||
{ | ||
"email": "jan.unkelbach@usz.ch", | ||
"first_name": "Jan", | ||
"last_name": "Unkelbach", | ||
"institution": "USZ", | ||
"is_active": true, | ||
"is_staff": false, | ||
"is_superuser": false | ||
}, | ||
{ | ||
"email": "vincent.gregoire@lyon.unicancer.fr", | ||
"first_name": "Vincent", | ||
"last_name": "Grégoire", | ||
"institution": "CLB", | ||
"is_active": true, | ||
"is_staff": false, | ||
"is_superuser": false | ||
}, | ||
{ | ||
"email": "roland.giger@insel.ch", | ||
"first_name": "Roland", | ||
"last_name": "Giger", | ||
"institution": "ISB", | ||
"is_active": true, | ||
"is_staff": false, | ||
"is_superuser": false | ||
}, | ||
{ | ||
"email": "lars.widmer@usz.ch", | ||
"first_name": "Lars", | ||
"last_name": "Widmer", | ||
"institution": "USZ", | ||
"is_active": true, | ||
"is_staff": false, | ||
"is_superuser": false | ||
}, | ||
{ | ||
"email": "esmee.looman@usz.ch", | ||
"first_name": "Esmee", | ||
"last_name": "Looman", | ||
"institution": "USZ", | ||
"is_active": true, | ||
"is_staff": false, | ||
"is_superuser": false | ||
}, | ||
{ | ||
"email": "yoel.perezhaas@usz.ch", | ||
"first_name": "Yoel", | ||
"last_name": "Perez Haas", | ||
"institution": "USZ", | ||
"is_active": true, | ||
"is_staff": false, | ||
"is_superuser": false | ||
}, | ||
{ | ||
"email": "julian.broennimann@uzh.ch", | ||
"first_name": "Julian", | ||
"last_name": "Brönnimann", | ||
"institution": "USZ", | ||
"is_active": true, | ||
"is_staff": false, | ||
"is_superuser": false | ||
}, | ||
{ | ||
"email": "sergi.benavente@vallhebron.cat", | ||
"first_name": "Sergio", | ||
"last_name": "Benavente Norza", | ||
"institution": "HVH", | ||
"is_active": true, | ||
"is_staff": false, | ||
"is_superuser": false | ||
} | ||
] |
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,87 @@ | ||
""" | ||
Management command to add institutions from a file or the command line. | ||
""" | ||
import json | ||
from pathlib import Path | ||
from django.core.management import base | ||
from django.core.management.base import CommandParser | ||
from django.db.utils import IntegrityError | ||
|
||
from lyprox.accounts.models import Institution | ||
|
||
|
||
class Command(base.BaseCommand): | ||
"""Command to add institutions from a file or the command line.""" | ||
help = __doc__ | ||
|
||
def add_arguments(self, parser: CommandParser) -> None: | ||
"""Add arguments to command.""" | ||
group = parser.add_mutually_exclusive_group(required=True) | ||
group.add_argument( | ||
"--from-file", | ||
type=Path, | ||
help="Path to JSON file with list of institutions.", | ||
) | ||
group.add_argument( | ||
"--from-stdin", | ||
action="store_true", | ||
help="Use command line arguments to create a single institution.", | ||
) | ||
parser.add_argument( | ||
"--name", type=str, help="Name of institution.", | ||
) | ||
parser.add_argument( | ||
"--shortname", type=str, help="Abbreviation of institution.", | ||
) | ||
parser.add_argument( | ||
"--street", type=str, help="Street and house number of institution.", | ||
) | ||
parser.add_argument( | ||
"--city", type=str, help="City of institution.", | ||
) | ||
parser.add_argument( | ||
"--country", type=str, help="Country of institution.", | ||
) | ||
parser.add_argument( | ||
"--phone", type=str, help="Phone number of institution.", | ||
) | ||
parser.add_argument( | ||
"--logo", type=str, help="Path of insitution's logo within media.", | ||
) | ||
|
||
def handle(self, *args, **options): | ||
"""Execute command.""" | ||
if not options["from_stdin"]: | ||
with open(options["from_file"], "r", encoding="utf-8") as json_file: | ||
institution_configurations = json.load(json_file) | ||
else: | ||
institution_configurations = [{ | ||
"name": options["name"], | ||
"shortname": options["shortname"], | ||
"street": options["street"], | ||
"city": options["city"], | ||
"country": options["country"], | ||
"phone": options["phone"], | ||
"logo": options["logo"], | ||
}] | ||
|
||
for config in institution_configurations: | ||
try: | ||
Institution.objects.create(**config) | ||
self.stdout.write( | ||
self.style.SUCCESS( | ||
f"Institution '{config['name']}' created." | ||
) | ||
) | ||
except IntegrityError: | ||
self.stdout.write( | ||
self.style.WARNING( | ||
f"Institution '{config['name']}' already exists. Skipping." | ||
) | ||
) | ||
except Exception as exc: | ||
self.stdout.write( | ||
self.style.ERROR( | ||
f"Could not create institution '{config['name']}': {exc}" | ||
) | ||
) |
Oops, something went wrong.