Skip to content

Commit

Permalink
Update migrations of connector-lead , lead, entry
Browse files Browse the repository at this point in the history
  • Loading branch information
sudan45 committed Jun 26, 2024
1 parent e3d6f09 commit a9daaf2
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 115 deletions.
1 change: 1 addition & 0 deletions apps/deepl_integration/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ def save_lead_data_using_connector_lead(
connector_lead_attachment.file_preview.name,
connector_lead_attachment.file_preview
)
lead_attachment.save()
lead.update_extraction_status(Lead.ExtractionStatus.SUCCESS)
return True

Expand Down
2 changes: 1 addition & 1 deletion apps/deepl_integration/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def create(self, data: List[Dict]):
lead,
data['text_path'],
data.get('images_path', [])[:10], # TODO: Support for more images, too much image will error.
data.get('tables_path', []),
data.get('tables_path', [])[:10],
data.get('total_words_count'),
data.get('total_pages'),
data.get('text_extraction_id'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.2.25 on 2024-06-11 08:10
# Generated by Django 3.2.25 on 2024-06-21 11:49

from django.db import migrations, models
import django.db.models.deletion
Expand All @@ -7,8 +7,8 @@
class Migration(migrations.Migration):

dependencies = [
('lead', '0053_alter_leadpreviewattachment_type'),
('entry', '0040_alter_entryattachment_entry_file_type'),
('lead', '0051_auto_20240625_0509')
]

operations = [
Expand Down
3 changes: 3 additions & 0 deletions apps/entry/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.db import models

from deep.middleware import get_current_user
from unified_connector.models import ConnectorLeadPreviewAttachment
from utils.common import parse_number
from project.mixins import ProjectEntityMixin
from project.permissions import PROJECT_PERMISSIONS
Expand All @@ -31,6 +32,8 @@ class EntryFileType(models.IntegerChoices):
LEAD_TO_ENTRY_TYPE = {
LeadPreviewAttachment.AttachmentFileType.XLSX: EntryFileType.XLSX,
LeadPreviewAttachment.AttachmentFileType.IMAGE: EntryFileType.IMAGE,
ConnectorLeadPreviewAttachment.ConnectorAttachmentFileType.XLSX: EntryFileType.XLSX,
ConnectorLeadPreviewAttachment.ConnectorAttachmentFileType.IMAGE: EntryFileType.IMAGE
}
assert len(list(LeadPreviewAttachment.AttachmentFileType)) == len(LEAD_TO_ENTRY_TYPE.keys()), \
'Make sure to sync LEAD_TO_ENTRY_TYPE with LeadPreviewAttachment.AttachmentFileType'
Expand Down
29 changes: 0 additions & 29 deletions apps/lead/migrations/0050_auto_20240606_0608.py

This file was deleted.

17 changes: 17 additions & 0 deletions apps/lead/migrations/0050_auto_20240621_1149.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.25 on 2024-06-21 11:49

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('lead', '0049_auto_20231121_0926_squashed_0054_auto_20231218_0552'),
]

operations = [
migrations.RenameModel(
old_name='LeadPreviewImage',
new_name='LeadPreviewAttachment'
),
]
18 changes: 0 additions & 18 deletions apps/lead/migrations/0051_alter_leadpreviewattachment_type.py

This file was deleted.

45 changes: 45 additions & 0 deletions apps/lead/migrations/0051_auto_20240625_0509.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Generated by Django 3.2.25 on 2024-06-25 05:09

from django.db import migrations, models


def set_file_preview(apps, schema_editor):
LeadPreviewAttachment = apps.get_model('lead', 'LeadPreviewAttachment')
lead_attachments = LeadPreviewAttachment.objects.all()
for lead_attachment in lead_attachments:
lead_attachment.file_preview = lead_attachment.file
lead_attachment.type = 2 # default type is image


class Migration(migrations.Migration):

dependencies = [
('lead', '0050_auto_20240621_1149'),
]

operations = [
migrations.AddField(
model_name='leadpreviewattachment',
name='order',
field=models.IntegerField(default=0)
),
migrations.AddField(
model_name='leadpreviewattachment',
name='page_number',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='leadpreviewattachment',
name='file_preview',
field=models.FileField(upload_to='lead-preview/attachments-preview/')
),
migrations.AddField(
model_name='leadpreviewattachment',
name='type',
field=models.PositiveSmallIntegerField(choices=[(1, 'XLSX'), (2, 'Image')],max_length=20)
),
migrations.RunPython(
set_file_preview,
reverse_code=migrations.RunPython.noop,
)
]
18 changes: 0 additions & 18 deletions apps/lead/migrations/0052_alter_leadpreviewattachment_type.py

This file was deleted.

18 changes: 0 additions & 18 deletions apps/lead/migrations/0053_alter_leadpreviewattachment_type.py

This file was deleted.

29 changes: 0 additions & 29 deletions apps/unified_connector/migrations/0009_auto_20240618_0924.py

This file was deleted.

27 changes: 27 additions & 0 deletions apps/unified_connector/migrations/0009_auto_20240621_1149.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 3.2.25 on 2024-06-21 11:49

from django.db import migrations,models


class Migration(migrations.Migration):

dependencies = [
('unified_connector', '0008_connectorlead_text_extraction_id'),
]

operations = [
migrations.RenameField(
model_name='connectorleadpreviewimage',
old_name='image',
new_name='file',
),
migrations.AlterField(
model_name='connectorleadpreviewimage',
name='file',
field=models.FileField(upload_to='connector-lead/attachments/')
),
migrations.RenameModel(
old_name='ConnectorLeadPreviewImage',
new_name='ConnectorLeadPreviewAttachment'
),
]
44 changes: 44 additions & 0 deletions apps/unified_connector/migrations/0010_auto_20240625_0806.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Generated by Django 3.2.25 on 2024-06-25 08:06

from django.db import migrations, models

def set_file_preview(apps, schema_editor):
ConnectorLeadPreviewAttachment = apps.get_model('unified_connector', 'ConnectorLeadPreviewAttachment')
connector_lead_attachments = ConnectorLeadPreviewAttachment.objects.all()
for connector_lead_attachment in connector_lead_attachments:
connector_lead_attachment.file_preview = connector_lead_attachment.file
connector_lead_attachment.type = 2 # default type is image


class Migration(migrations.Migration):

dependencies = [
('unified_connector', '0009_auto_20240621_1149'),
]

operations = [
migrations.AddField(
model_name='connectorleadpreviewattachment',
name='order',
field=models.IntegerField(default=0)
),
migrations.AddField(
model_name='connectorleadpreviewattachment',
name='page_number',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='connectorleadpreviewattachment',
name='file_preview',
field=models.FileField(upload_to='connector-lead/attachments-preview/')
),
migrations.AddField(
model_name='connectorleadpreviewattachment',
name='type',
field=models.PositiveSmallIntegerField(choices=[(1, 'XLSX'), (2, 'Image')])
),
migrations.RunPython(
set_file_preview,
reverse_code=migrations.RunPython.noop,
)
]
Empty file added server.diff
Empty file.

0 comments on commit a9daaf2

Please sign in to comment.