-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
498 additions
and
94 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from .export_admin_form import ExportJobAdminForm | ||
from .import_admin_form import ImportJobAdminForm | ||
from .export_job_admin_form import ExportJobAdminForm | ||
from .import_admin_form import ForceImportForm | ||
from .import_job_admin_form import ImportJobAdminForm |
File renamed without changes.
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 |
---|---|---|
@@ -1,57 +1,11 @@ | ||
from django import forms | ||
from django.urls import reverse | ||
|
||
from ... import models | ||
from ..widgets import ProgressBarWidget | ||
from import_export import forms as base_forms | ||
|
||
|
||
class ImportJobAdminForm(forms.ModelForm): | ||
"""Admin form for ``ImportJob`` model. | ||
Adds custom `import_progressbar` field that displays current import | ||
progress using AJAX requests to specified endpoint. Fields widget is | ||
defined in `__init__` method. | ||
""" | ||
|
||
import_progressbar = forms.Field( | ||
class ForceImportForm(base_forms.ImportForm): | ||
"""Import form with `force_import` option.""" | ||
force_import = forms.BooleanField( | ||
required=False, | ||
initial=False, | ||
) | ||
|
||
def __init__( | ||
self, | ||
instance: models.ImportJob, | ||
*args, | ||
**kwargs, | ||
): | ||
"""Provide `import_progressbar` widget the ``ImportJob`` instance.""" | ||
super().__init__(*args, instance=instance, **kwargs) | ||
url_name = "admin:import_job_progress" | ||
self.fields["import_progressbar"].label = ( | ||
"Import progress" if | ||
instance.import_status == models.ImportJob.ImportStatus.IMPORTING | ||
else "Parsing progress" | ||
) | ||
self.fields["import_progressbar"].widget = ProgressBarWidget( | ||
job=instance, | ||
url=reverse(url_name, args=(instance.id,)), | ||
) | ||
|
||
class Meta: | ||
fields = ( | ||
"import_status", | ||
"resource_path", | ||
"data_file", | ||
"resource_kwargs", | ||
"traceback", | ||
"error_message", | ||
"result", | ||
"parse_task_id", | ||
"import_task_id", | ||
"parse_finished", | ||
"import_started", | ||
"import_finished", | ||
"created_by", | ||
"created", | ||
"modified", | ||
) |
57 changes: 57 additions & 0 deletions
57
import_export_extensions/admin/forms/import_job_admin_form.py
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,57 @@ | ||
from django import forms | ||
from django.urls import reverse | ||
|
||
from ... import models | ||
from ..widgets import ProgressBarWidget | ||
|
||
|
||
class ImportJobAdminForm(forms.ModelForm): | ||
"""Admin form for ``ImportJob`` model. | ||
Adds custom `import_progressbar` field that displays current import | ||
progress using AJAX requests to specified endpoint. Fields widget is | ||
defined in `__init__` method. | ||
""" | ||
|
||
import_progressbar = forms.Field( | ||
required=False, | ||
) | ||
|
||
def __init__( | ||
self, | ||
instance: models.ImportJob, | ||
*args, | ||
**kwargs, | ||
): | ||
"""Provide `import_progressbar` widget the ``ImportJob`` instance.""" | ||
super().__init__(*args, instance=instance, **kwargs) | ||
url_name = "admin:import_job_progress" | ||
self.fields["import_progressbar"].label = ( | ||
"Import progress" if | ||
instance.import_status == models.ImportJob.ImportStatus.IMPORTING | ||
else "Parsing progress" | ||
) | ||
self.fields["import_progressbar"].widget = ProgressBarWidget( | ||
job=instance, | ||
url=reverse(url_name, args=(instance.id,)), | ||
) | ||
|
||
class Meta: | ||
fields = ( | ||
"import_status", | ||
"resource_path", | ||
"data_file", | ||
"resource_kwargs", | ||
"traceback", | ||
"error_message", | ||
"result", | ||
"parse_task_id", | ||
"import_task_id", | ||
"parse_finished", | ||
"import_started", | ||
"import_finished", | ||
"created_by", | ||
"created", | ||
"modified", | ||
) |
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
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
22 changes: 22 additions & 0 deletions
22
import_export_extensions/migrations/0005_importjob_force_import.py
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,22 @@ | ||
# Generated by Django 4.2.7 on 2023-11-16 10:49 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("import_export_extensions", "0004_alter_exportjob_created_by_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="importjob", | ||
name="force_import", | ||
field=models.BooleanField( | ||
default=False, | ||
help_text="Import data with skip invalid rows.", | ||
verbose_name="Force import", | ||
), | ||
), | ||
] |
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
Oops, something went wrong.