django-batch-sheet 0.20.2__tar.gz → 0.90.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (19) hide show
  1. {django_batch_sheet-0.20.2 → django_batch_sheet-0.90.0}/PKG-INFO +1 -1
  2. {django_batch_sheet-0.20.2 → django_batch_sheet-0.90.0}/batch_sheet/CombinedSheet.py +19 -10
  3. {django_batch_sheet-0.20.2 → django_batch_sheet-0.90.0}/batch_sheet/Sheet.py +7 -2
  4. {django_batch_sheet-0.20.2 → django_batch_sheet-0.90.0}/django_batch_sheet.egg-info/PKG-INFO +1 -1
  5. {django_batch_sheet-0.20.2 → django_batch_sheet-0.90.0}/setup.py +1 -1
  6. {django_batch_sheet-0.20.2 → django_batch_sheet-0.90.0}/LICENSE +0 -0
  7. {django_batch_sheet-0.20.2 → django_batch_sheet-0.90.0}/README.md +0 -0
  8. {django_batch_sheet-0.20.2 → django_batch_sheet-0.90.0}/batch_sheet/__init__.py +0 -0
  9. {django_batch_sheet-0.20.2 → django_batch_sheet-0.90.0}/batch_sheet/admin.py +0 -0
  10. {django_batch_sheet-0.20.2 → django_batch_sheet-0.90.0}/batch_sheet/apps.py +0 -0
  11. {django_batch_sheet-0.20.2 → django_batch_sheet-0.90.0}/batch_sheet/management/__init__.py +0 -0
  12. {django_batch_sheet-0.20.2 → django_batch_sheet-0.90.0}/batch_sheet/management/commands/__init__.py +0 -0
  13. {django_batch_sheet-0.20.2 → django_batch_sheet-0.90.0}/batch_sheet/management/commands/batch_load.py +0 -0
  14. {django_batch_sheet-0.20.2 → django_batch_sheet-0.90.0}/batch_sheet/management/commands/generate_sheet.py +0 -0
  15. {django_batch_sheet-0.20.2 → django_batch_sheet-0.90.0}/django_batch_sheet.egg-info/SOURCES.txt +0 -0
  16. {django_batch_sheet-0.20.2 → django_batch_sheet-0.90.0}/django_batch_sheet.egg-info/dependency_links.txt +0 -0
  17. {django_batch_sheet-0.20.2 → django_batch_sheet-0.90.0}/django_batch_sheet.egg-info/requires.txt +0 -0
  18. {django_batch_sheet-0.20.2 → django_batch_sheet-0.90.0}/django_batch_sheet.egg-info/top_level.txt +0 -0
  19. {django_batch_sheet-0.20.2 → django_batch_sheet-0.90.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: django_batch_sheet
3
- Version: 0.20.2
3
+ Version: 0.90.0
4
4
  Summary: Create Excel Sheet from Django Model and load them automatically
5
5
  Home-page: https://github.com/mkalioby/django-batch-sheet/
6
6
  Download-URL: https://github.com/mkalioby/django-batch-sheet/
@@ -4,6 +4,7 @@ import xlrd
4
4
  import xlsxwriter
5
5
  from django.conf import settings
6
6
  from django.core.exceptions import ValidationError
7
+ from django.db import transaction
7
8
  from django.db.models import Field
8
9
  from .Sheet import Sheet
9
10
 
@@ -93,15 +94,20 @@ class CombinedSheet(metaclass=DeclarativeCombinedSheetsMetaclass):
93
94
  wb = xlrd.open_workbook(file_name)
94
95
  self.xls_sheet = wb.sheets()[0]
95
96
 
96
- def is_valid(self):
97
+ def is_valid(self,show_sheet=False):
97
98
  if self._valid is None:
98
99
  for sheet_name, sheet in self.sheets.items():
99
100
  sheet.sheet =self.xls_sheet
100
101
  if not sheet.is_valid():
101
102
  for k in sheet.errors:
102
- if not k in self.errors:
103
- self.errors[k]={}
104
- self.errors[k].update(sheet.errors[k])
103
+ if show_sheet:
104
+ if not sheet.name in self.errors:
105
+ self.errors[sheet.name]={}
106
+ self.errors[sheet.name][k]=sheet.errors[k]
107
+ else:
108
+ if not k in self.errors:
109
+ self.errors[k] = {}
110
+ self.errors[k].update(sheet.errors[k])
105
111
  for i,d in enumerate(sheet.data):
106
112
  if len(self.data) == i:
107
113
  self.data.append({})
@@ -116,12 +122,15 @@ class CombinedSheet(metaclass=DeclarativeCombinedSheetsMetaclass):
116
122
 
117
123
  def process(self):
118
124
  if self._valid:
119
- for row in self.cleaned_data:
120
- row_objs = {}
121
- for sheet_name, sheet in self.sheets.items():
122
- obj_name = getattr(sheet._meta, "object_name", sheet_name)
123
- row_objs[obj_name] = sheet.row_processor(row, row_objs)
124
- self.instances.append(row_objs)
125
+ with transaction.atomic():
126
+ for row in self.cleaned_data:
127
+ row_objs = {}
128
+ for sheet_name, sheet in self.sheets.items():
129
+ obj_name = getattr(sheet._meta, "object_name", sheet_name)
130
+ row = sheet.row_preprocessor(row)
131
+ row_objs[obj_name] = sheet.row_processor(row, row_objs)
132
+ self.instances.append(row_objs)
133
+ return self.instances
125
134
 
126
135
 
127
136
  def load(self,file_name=None, file_content=None):
@@ -114,7 +114,10 @@ class Sheet(metaclass=DeclarativeColumnsMetaclass):
114
114
  errors = {}
115
115
  data = []
116
116
  cleaned_data = []
117
-
117
+ @classmethod
118
+ @property
119
+ def name(cls):
120
+ return cls.__name__
118
121
  def __init__(self, *args, **kwargs):
119
122
  super().__init__()
120
123
 
@@ -283,9 +286,11 @@ class Sheet(metaclass=DeclarativeColumnsMetaclass):
283
286
  def process(self,):
284
287
  self.convert_json(self.sheet)
285
288
  for row in self.cleaned_data:
286
- x = self.row_processor(row)
289
+ final_row = self.row_preprocessor(row)
290
+ x = self.row_processor(final_row)
287
291
  if x:
288
292
  self.instances.append(x)
293
+ return self.instances
289
294
 
290
295
  def post_process(self):
291
296
  pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: django-batch-sheet
3
- Version: 0.20.2
3
+ Version: 0.90.0
4
4
  Summary: Create Excel Sheet from Django Model and load them automatically
5
5
  Home-page: https://github.com/mkalioby/django-batch-sheet/
6
6
  Download-URL: https://github.com/mkalioby/django-batch-sheet/
@@ -4,7 +4,7 @@ from setuptools import find_packages, setup
4
4
 
5
5
  setup(
6
6
  name='django_batch_sheet',
7
- version='0.20.2',
7
+ version='0.90.0',
8
8
  description='Create Excel Sheet from Django Model and load them automatically',
9
9
  long_description=open("README.md").read(),
10
10
  long_description_content_type="text/markdown",