-
Notifications
You must be signed in to change notification settings - Fork 7
Upload feature #80
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
Merged
Merged
Upload feature #80
Changes from 17 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
ccb2f87
copy upload files into branch
lmdulz ffd15d1
deleted a comment
lmdulz 09b86eb
delete package-lock.json and package.json files
lmdulz e27f800
parse seed env variable for Anonymizer to Javascript
lmdulz c257f0c
cleanup for CI
lmdulz ef10a09
Merge remote-tracking branch 'origin/main' into upload_dev
lmdulz d884d2a
Use model pk instead of id and adapt to upgraded packages
lmdulz 34b4174
adapt tests to package updates
lmdulz eddce09
adjust upload tests for CI
lmdulz 3dc574a
integrate UploadPermissionSupport into existing UploadSettings
lmdulz 49eb7fc
update adit_radis_shared
lmdulz 9d25903
update dicom-wab-anonymizer
lmdulz 7d2eeb5
package-lock.json
lmdulz 70791be
add type assertions, adaption to updated Anonymizer, adapt series dic…
lmdulz cb3326b
upgrade adit-radis-shared
lmdulz 2ecaadd
Merge branch 'main' into upload_dev
lmdulz 0249f23
create initial migration fopr upload app
lmdulz f119d70
delete update task bc of renovate usage
lmdulz f77f744
Merge branch 'main' into upload_dev
medihack 38d9471
Exclude async views from test
medihack 2dfe48e
Improve integration upload tests
medihack ed071a3
Merge branch 'main' into upload_dev
medihack a1c062b
Move fixtures to helpers
medihack 0e63308
Use correct type hint
medihack c50a9e8
Use valid db url
medihack 0f9979f
Improve development setup
medihack a8de703
Fix dev setup
medihack 656d202
Merge branch 'main' into upload_dev (& resolved merge conflicts)
4876e98
Updated upload views to use correct functions
9ee3988
fixed linting and tests
3de6720
fixed unused variables & spelling
c04a2f8
Fixed uninitialized variables in views.py & removed unused variables …
0161070
fixed Bug with repeated uploads with invalid Pseudonym
266c2ad
fixed retained files after upload
20c8215
Renamed integration tests to acceptance tests
9983e8f
Fixed ANONYMIZATION_SEED variable in compose setup
497f333
moved the copy-statics command to cli.py; updated version of dicom-we…
0d2a84d
deleted abundant packages
Lucius1274 9c79436
added __init__.py to fix import file mismatch from pytest
Lucius1274 a44434f
fixed tests that failed because of upgrade to asgiref 3.10.0
Lucius1274 9072585
Merge branch 'main' into upload_dev
medihack 19fcfed
fixed linting errors in upload.js
Lucius1274 60b13dc
small stylistic fixes & better error handling
Lucius1274 4d41e68
fixed stuttering progress bar, parametrized tests & updated readme
Lucius1274 aab6ba6
Merge branch 'main' into upload_dev
medihack a463bf3
combined seed with csrftoken & improved error handling
Lucius1274 bfc6f90
Improved memory use of upload
Lucius1274 884add4
added seed security & small fixes
Lucius1274 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
Empty file.
This file contains hidden or 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,6 @@ | ||
| from django.contrib import admin | ||
|
|
||
| # Register your models here. | ||
| from .models import UploadSettings | ||
|
|
||
| admin.site.register(UploadSettings, admin.ModelAdmin) |
This file contains hidden or 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,29 @@ | ||
| from django.apps import AppConfig | ||
|
|
||
| SECTION_NAME = "DICOM Upload" | ||
|
|
||
|
|
||
| class UploadConfig(AppConfig): | ||
| default_auto_field = "django.db.models.BigAutoField" | ||
| name = "adit.upload" | ||
|
|
||
| def ready(self): | ||
| register_app() | ||
|
|
||
|
|
||
| def register_app(): | ||
| from adit_radis_shared.common.site import MainMenuItem, register_main_menu_item | ||
|
|
||
| register_main_menu_item( | ||
| MainMenuItem( | ||
| url_name="upload_create", | ||
| label=SECTION_NAME, | ||
| ) | ||
| ) | ||
|
|
||
|
|
||
| def create_app_settings(): | ||
| from .models import UploadSettings | ||
|
|
||
| if not UploadSettings.objects.exists(): | ||
| UploadSettings.objects.create() |
This file contains hidden or 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,90 @@ | ||
| from crispy_forms.helper import FormHelper | ||
| from crispy_forms.layout import Column, Div, Field, Layout, Row | ||
| from django import forms | ||
|
|
||
| from adit.core.fields import DicomNodeChoiceField | ||
| from adit.core.validators import no_backslash_char_validator, no_control_chars_validator | ||
|
|
||
|
|
||
| class MultipleFileInput(forms.widgets.FileInput): | ||
| def __init__(self, attrs=None): | ||
| attrs = attrs or {} | ||
| attrs["onchange"] = "chooseFolder(event)" | ||
| attrs["webkitdirectory"] = True | ||
| attrs["directory"] = True | ||
| attrs["multiple"] = True | ||
| super().__init__(attrs) | ||
|
|
||
|
|
||
| class UploadForm(forms.Form): | ||
| pseudonym = forms.CharField( | ||
| required=True, | ||
| max_length=64, | ||
| validators=[no_backslash_char_validator, no_control_chars_validator], | ||
| label="Patient Pseudonym", | ||
| ) | ||
|
|
||
| def __init__(self, *args, **kwargs): | ||
| self.user = kwargs.pop("user") | ||
| self.action = kwargs.pop("action") | ||
|
|
||
| super().__init__(*args, **kwargs) | ||
|
|
||
| self.fields["destination"] = DicomNodeChoiceField("destination", self.user) | ||
| self.fields["pseudonym"].required = True | ||
| self.fields["destination"].required = True | ||
| self.helper = FormHelper(self) | ||
| form_fields_layout = self.build_query_form_layout() | ||
|
|
||
| # We swap the form using the htmx alpine-morph extension to retain the focus on the input | ||
| self.helper.layout = Layout( | ||
| Div( | ||
| form_fields_layout, | ||
| css_id="form_fields", | ||
| ), | ||
| ) | ||
| self.helper.form_action = "" | ||
| self.helper.attrs = { | ||
| "x-init": "initUploadForm($el)", | ||
| "id": "myForm", | ||
| "hx-ext": "alpine-morph", | ||
| "hx-post": "", | ||
| "method": "post", | ||
| "hx-trigger": "submit", | ||
| "hx-swap-oob": "true", | ||
| "action": "", | ||
| "novalidate": "", | ||
| "enctype": "multipart/form-data", | ||
| } | ||
|
|
||
| def build_query_form_layout(self): | ||
| query_form_layout = Layout( | ||
| Div( | ||
| Row( | ||
| Column( | ||
| self.build_option_field( | ||
| "pseudonym", | ||
| ) | ||
| ), | ||
| Column( | ||
| Field( | ||
| "destination", | ||
| **{ | ||
| "x-init": "initDestination($el)", | ||
| "@change": "onDestinationChange($event)", | ||
| }, | ||
| ) | ||
| ), | ||
| ), | ||
| css_id="form_partial", | ||
| ) | ||
| ) | ||
|
|
||
| return query_form_layout | ||
|
|
||
| def build_option_field(self, field_name, additional_attrs=None): | ||
| attrs = {"@keydown.enter.prevent": ""} | ||
| if additional_attrs: | ||
| attrs = {**additional_attrs, **attrs} | ||
|
|
||
| return Column(Field(field_name, **attrs)) |
This file contains hidden or 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,27 @@ | ||
| # Generated by Django 5.1 on 2024-10-19 16:55 | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| initial = True | ||
|
|
||
| dependencies = [ | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name='UploadSettings', | ||
| fields=[ | ||
| ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
| ('locked', models.BooleanField(default=False)), | ||
| ('suspended', models.BooleanField(default=False)), | ||
| ], | ||
| options={ | ||
| 'verbose_name_plural': 'Upload settings', | ||
| 'permissions': [('can_upload_data', 'Can upload data')], | ||
| 'default_permissions': (), | ||
| }, | ||
| ), | ||
| ] |
Empty file.
This file contains hidden or 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,12 @@ | ||
| from adit.core.models import DicomAppSettings | ||
|
|
||
|
|
||
| class UploadSettings(DicomAppSettings): | ||
| class Meta: | ||
| verbose_name_plural = "Upload settings" | ||
| default_permissions = () | ||
| permissions = [ | ||
| ("can_upload_data", "Can upload data"), | ||
| ] | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.