Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Update ExportEvents enum and type

IKarbowiakba5b7eabe080
diff --git a/saleor/csv/events.py b/saleor/csv/events.py
index f883fa87a0..d4b8ab2156 100644
--- a/saleor/csv/events.py
+++ b/saleor/csv/events.py
@@ -8,7 +8,7 @@ if TYPE_CHECKING:
from .models import ExportFile
-def export_event(*, export_file: "ExportFile", user: User):
+def export_started_event(*, export_file: "ExportFile", user: User):
ExportEvent.objects.create(
export_file=export_file, user=user, type=ExportEvents.EXPORT_PENDING
)
diff --git a/saleor/csv/migrations/0002_exportevent.py b/saleor/csv/migrations/0002_exportevent.py
index 1dbdca2f6f..9a35244f88 100644
--- a/saleor/csv/migrations/0002_exportevent.py
+++ b/saleor/csv/migrations/0002_exportevent.py
@@ -1,4 +1,4 @@
-# Generated by Django 3.0.5 on 2020-05-07 07:06
+# Generated by Django 3.0.5 on 2020-05-11 11:29
import django.contrib.postgres.fields.jsonb
import django.db.models.deletion
@@ -39,11 +39,18 @@ class Migration(migrations.Migration):
"type",
models.CharField(
choices=[
- ("DATA_EXPORT_PENDING", "data_export_pending"),
- ("DATA_EXPORT_SUCCESS", "data_export_success"),
- ("DATA_EXPORT_FAILED", "data_export_failed"),
- ("DATA_EXPORT_DELETED", "data_export_deleted"),
- ("EXPORTED_FILE_SENT", "exported_file_sent"),
+ ("export_pending", "Data export was started."),
+ (
+ "export_success",
+ "Data export was completed successfully.",
+ ),
+ ("export_failed", "Data export failed."),
+ ("export_deleted", "Export file was started."),
+ (
+ "exported_file_sent",
+ "Email with link to download csv file was sent "
+ "to the customer.",
+ ),
],
max_length=255,
),
diff --git a/saleor/csv/models.py b/saleor/csv/models.py
index 34d5c75541..ebe0573fd4 100644
--- a/saleor/csv/models.py
+++ b/saleor/csv/models.py
@@ -17,12 +17,7 @@ class ExportEvent(models.Model):
"""Model used to store events that happened during the export file lifecycle."""
date = models.DateTimeField(default=timezone.now, editable=False)
- type = models.CharField(
- max_length=255,
- choices=[
- (type_name.upper(), type_name) for type_name, _ in ExportEvents.CHOICES
- ],
- )
+ type = models.CharField(max_length=255, choices=ExportEvents.CHOICES)
parameters = JSONField(blank=True, default=dict, encoder=CustomJsonEncoder)
export_file = models.ForeignKey(
ExportFile, related_name="events", on_delete=models.CASCADE
diff --git a/saleor/graphql/csv/mutations.py b/saleor/graphql/csv/mutations.py
index 3a3332f8eb..88c7e984f5 100644
--- a/saleor/graphql/csv/mutations.py
+++ b/saleor/graphql/csv/mutations.py
@@ -5,7 +5,7 @@ from django.core.exceptions import ValidationError
from ...core.permissions import ProductPermissions
from ...csv import models as csv_models
-from ...csv.events import export_event
+from ...csv.events import export_started_event
from ...csv.utils.export import export_products
from ..core.enums import CsvErrorCode
from ..core.mutations import BaseMutation
@@ -55,7 +55,7 @@ class ExportProducts(BaseMutation):
user = info.context.user
scope = cls.get_products_scope(info, data["input"])
export_file = csv_models.ExportFile.objects.create(created_by=user)
- export_event(export_file=export_file, user=user)
+ export_started_event(export_file=export_file, user=user)
export_products.delay(export_file.pk, scope)
export_file.refresh_from_db()
return cls(export_file=export_file)