Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/latest
Browse files Browse the repository at this point in the history
# Conflicts:
#	requirements.txt
#	requirements_dev.txt
  • Loading branch information
jjbeekman committed Jun 24, 2024
2 parents e855e76 + 75580fc commit 61a3ab4
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 55 deletions.
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ django-datetime-utc
django-filter
django-extensions
django-debug-toolbar
django-import-export==3.3.9
django-import-export
django-leaflet
djangorestframework-xml
django-storages[azure]
Expand Down
25 changes: 6 additions & 19 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,7 @@ cryptography==42.0.8
decorator==5.1.1
# via fabric
defusedxml==0.7.1
# via
# djangorestframework-xml
# odfpy
# via djangorestframework-xml
deprecated==1.2.14
# via
# fabric
Expand Down Expand Up @@ -433,9 +431,9 @@ django-extensions==3.2.3
# via -r requirements.in
django-filter==24.2
# via -r requirements.in
django-import-export==3.3.9
django-import-export==4.0.8
# via -r requirements.in
django-leaflet==0.30.0
django-leaflet==0.30.1
# via -r requirements.in
django-storages[azure]==1.14.3
# via -r requirements.in
Expand Down Expand Up @@ -526,8 +524,6 @@ jsondiff==2.0.0
# via azure-cli
knack==0.11.0
# via azure-cli-core
markuppy==1.14
# via tablib
mozilla-django-oidc==4.0.1
# via -r requirements.in
msal[broker]==1.28.0
Expand Down Expand Up @@ -593,8 +589,6 @@ msrestazure==0.6.4.post1
# azure-mgmt-managedservices
oauthlib==3.2.2
# via requests-oauthlib
odfpy==1.4.1
# via tablib
opencensus==0.11.4
# via
# opencensus-ext-azure
Expand All @@ -615,9 +609,7 @@ opencensus-ext-postgresql==0.1.3
opencensus-ext-requests==0.8.0
# via -r requirements.in
openpyxl==3.1.4
# via
# -r requirements.in
# tablib
# via -r requirements.in
packaging==24.1
# via
# azure-cli
Expand Down Expand Up @@ -699,7 +691,6 @@ pyyaml==6.0.1
# drf-yasg
# knack
# pycomposefile
# tablib
requests[socks]==2.32.3
# via
# -r requirements.in
Expand Down Expand Up @@ -742,7 +733,7 @@ sqlparse==0.5.0
# django-debug-toolbar
sshtunnel==0.1.5
# via azure-cli
tablib[html,ods,xls,xlsx,yaml]==3.5.0
tablib==3.5.0
# via django-import-export
tabulate==0.9.0
# via
Expand All @@ -760,7 +751,7 @@ typing-extensions==4.12.2
# azure-storage-blob
uritemplate==4.1.1
# via drf-yasg
urllib3==2.2.1
urllib3==2.2.2
# via
# azure-cli
# requests
Expand All @@ -770,10 +761,6 @@ wrapt==1.16.0
# via
# deprecated
# opencensus-ext-requests
xlrd==2.0.1
# via tablib
xlwt==1.3.0
# via tablib
xmltodict==0.13.0
# via azure-cli

Expand Down
30 changes: 5 additions & 25 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,6 @@ defusedxml==0.7.1
# via
# -r ./requirements.txt
# djangorestframework-xml
# odfpy
deprecated==1.2.14
# via
# -r ./requirements.txt
Expand Down Expand Up @@ -652,9 +651,9 @@ django-extensions==3.2.3
# via -r ./requirements.txt
django-filter==24.2
# via -r ./requirements.txt
django-import-export==3.3.9
django-import-export==4.0.8
# via -r ./requirements.txt
django-leaflet==0.30.0
django-leaflet==0.30.1
# via -r ./requirements.txt
django-storages[azure]==1.14.3
# via -r ./requirements.txt
Expand Down Expand Up @@ -822,10 +821,6 @@ knack==0.11.0
# azure-cli-core
locust==2.29.0
# via -r requirements_dev.in
markuppy==1.14
# via
# -r ./requirements.txt
# tablib
markupsafe==2.1.5
# via
# jinja2
Expand Down Expand Up @@ -909,10 +904,6 @@ oauthlib==3.2.2
# via
# -r ./requirements.txt
# requests-oauthlib
odfpy==1.4.1
# via
# -r ./requirements.txt
# tablib
opencensus==0.11.4
# via
# -r ./requirements.txt
Expand All @@ -936,9 +927,7 @@ opencensus-ext-postgresql==0.1.3
opencensus-ext-requests==0.8.0
# via -r ./requirements.txt
openpyxl==3.1.4
# via
# -r ./requirements.txt
# tablib
# via -r ./requirements.txt
packaging==24.1
# via
# -r ./requirements.txt
Expand Down Expand Up @@ -1091,7 +1080,6 @@ pyyaml==6.0.1
# drf-yasg
# knack
# pycomposefile
# tablib
pyzmq==26.0.3
# via locust
requests[socks]==2.32.3
Expand Down Expand Up @@ -1152,7 +1140,7 @@ sshtunnel==0.1.5
# azure-cli
stack-data==0.6.3
# via ipython
tablib[html,ods,xls,xlsx,yaml]==3.5.0
tablib==3.5.0
# via
# -r ./requirements.txt
# django-import-export
Expand Down Expand Up @@ -1194,7 +1182,7 @@ uritemplate==4.1.1
# via
# -r ./requirements.txt
# drf-yasg
urllib3==2.2.1
urllib3==2.2.2
# via
# -r ./requirements.txt
# azure-cli
Expand All @@ -1218,14 +1206,6 @@ wrapt==1.16.0
# -r ./requirements.txt
# deprecated
# opencensus-ext-requests
xlrd==2.0.1
# via
# -r ./requirements.txt
# tablib
xlwt==1.3.0
# via
# -r ./requirements.txt
# tablib
xmltodict==0.13.0
# via
# -r ./requirements.txt
Expand Down
4 changes: 2 additions & 2 deletions src/metingen/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class MetingVerrijkingAdmin(ImportExportMixin, admin.ModelAdmin):
)
raw_id_fields = ("hoogtepunt",)
ordering = ("hoogtepunt",)
resource_class = MetingVerrijkingResource
resource_classes = [MetingVerrijkingResource]

def get_import_formats(self):
return [TCOFormatClass]
Expand Down Expand Up @@ -162,7 +162,7 @@ class MetingControleAdmin(
raw_id_fields = ("hoogtepunt",)
actions = ["make_graph", "save_measurements"]
tmp_storage_class = CacheStorage
resource_class = MetingControleResource
resource_classes = [MetingControleResource]
import_form_class = CustomImportForm
confirm_form_class = CustomConfirmImportForm

Expand Down
23 changes: 15 additions & 8 deletions src/metingen/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@


class SimpleError(Error):
def __init__(self, error, traceback=None, row=None):
super().__init__(error, traceback=traceback, row=row)
def __init__(self, error, traceback=None, row=None, number=None):
super().__init__(error, traceback=traceback, row=row, number=number)
self.traceback = " "


Expand All @@ -26,11 +26,14 @@ class Meta:
exclude = ("id",)
use_bulk = True

def before_import(self, dataset, using_transactions, dry_run, **kwargs):
def before_import(self, dataset, **kwargs):
# import_export Version 4 change: param dry-run passed in kwargs
# during 'confirm' step, dry_run is True
dry_run = kwargs.get("dry_run", False)
if not dry_run:
truncate(MetingControle)

def before_import_row(self, row, row_number=None, **kwargs):
def before_import_row(self, row, **kwargs):
if not (Hoogtepunt.objects.filter(nummer=row["hoogtepunt"]).exists()):
error = ObjectDoesNotExist(
f"Provided hoogtepunt {row['hoogtepunt']} does not exist."
Expand Down Expand Up @@ -63,11 +66,15 @@ class Meta:
import_id_fields = ("hoogtepunt",)
exclude = "id"

def before_import(self, dataset, using_transactions, dry_run, **kwargs):
def before_import(self, dataset, **kwargs):
# import_export Version 4 change: param dry-run passed in kwargs
print(kwargs)
# during 'confirm' step, dry_run is True
dry_run = kwargs.get("dry_run", False)
if not dry_run:
truncate(MetingVerrijking)

def before_import_row(self, row, row_number=None, **kwargs):
def before_import_row(self, row, **kwargs):
if not (Hoogtepunt.objects.filter(nummer=row["hoogtepunt"]).exists()):
error = ObjectDoesNotExist(
f"Provided hoogtepunt {row['hoogtepunt']} does not exist."
Expand Down Expand Up @@ -102,9 +109,9 @@ def truncate(model):
truncate db table and restart AutoField primary_key for import
use as follows:
def before_import(self, dataset, using_transactions, dry_run, **kwargs):
def before_import(self, dataset, **kwargs):
# truncate table before import when dry_run = False
if not dry_run:
if not kwargs['dry_run']:
truncate(modelobject)
"""

Expand Down

0 comments on commit 61a3ab4

Please sign in to comment.