Skip to content

Commit

Permalink
bugfix/DT-1770-fix-file-uploader (#3008)
Browse files Browse the repository at this point in the history
* add test to check AV not called

* linting

* use the same choice logic on both upload forms

* linting
  • Loading branch information
chopkinsmade authored Feb 9, 2024
1 parent fcac79e commit f20420c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 4 additions & 0 deletions dataworkspace/dataworkspace/apps/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1672,3 +1672,7 @@ def clear_table_permissions_cache_for_user(user):
db_role,
)
cache.delete(table_permissions_cache_key(db_role))


def get_postgres_datatype_choices():
return ((name, name.capitalize()) for name, _ in SCHEMA_POSTGRES_DATA_TYPE_MAP.items())
7 changes: 2 additions & 5 deletions dataworkspace/dataworkspace/apps/datasets/manager/forms.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from django.core.validators import FileExtensionValidator
from django import forms

from dataworkspace.apps.core.constants import SCHEMA_POSTGRES_DATA_TYPE_MAP
from dataworkspace.apps.core.storage import malware_file_validator
from dataworkspace.apps.core.utils import get_postgres_datatype_choices
from dataworkspace.forms import (
GOVUKDesignSystemChoiceField,
GOVUKDesignSystemFileField,
Expand Down Expand Up @@ -49,10 +49,7 @@ def __init__(self, *args, **kwargs):
self.fields[col_def["column_name"]] = GOVUKDesignSystemChoiceField(
label=col_def["column_name"],
initial=col_def["data_type"],
choices=(
(value, name.capitalize())
for name, value in SCHEMA_POSTGRES_DATA_TYPE_MAP.items()
),
choices=get_postgres_datatype_choices(),
widget=GOVUKDesignSystemSelectWidget(
label_is_heading=False,
extra_label_classes="govuk-visually-hidden",
Expand Down
11 changes: 6 additions & 5 deletions dataworkspace/dataworkspace/apps/your_files/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
from django.core.validators import RegexValidator, MaxLengthValidator

from dataworkspace.apps.core.boto3_client import get_s3_client
from dataworkspace.apps.core.constants import SCHEMA_POSTGRES_DATA_TYPE_MAP
from dataworkspace.apps.core.utils import get_all_schemas, get_user_s3_prefixes
from dataworkspace.apps.core.utils import (
get_all_schemas,
get_postgres_datatype_choices,
get_user_s3_prefixes,
)
from dataworkspace.forms import (
GOVUKDesignSystemCharField,
GOVUKDesignSystemForm,
Expand Down Expand Up @@ -122,9 +125,7 @@ def __init__(self, *args, **kwargs):
self.fields[col_def["column_name"]] = GOVUKDesignSystemChoiceField(
label=col_def["column_name"],
initial=col_def["data_type"],
choices=(
(name, name.capitalize()) for name, _ in SCHEMA_POSTGRES_DATA_TYPE_MAP.items()
),
choices=get_postgres_datatype_choices(),
widget=GOVUKDesignSystemSelectWidget(
label_is_heading=False,
extra_label_classes="govuk-visually-hidden",
Expand Down

0 comments on commit f20420c

Please sign in to comment.