django-batch-sheet 0.20.0__tar.gz → 0.20.2__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.0 → django_batch_sheet-0.20.2}/PKG-INFO +5 -5
  2. {django-batch-sheet-0.20.0 → django_batch_sheet-0.20.2}/README.md +3 -3
  3. {django-batch-sheet-0.20.0 → django_batch_sheet-0.20.2}/batch_sheet/CombinedSheet.py +2 -2
  4. {django-batch-sheet-0.20.0 → django_batch_sheet-0.20.2}/batch_sheet/Sheet.py +1 -1
  5. django_batch_sheet-0.20.2/batch_sheet/management/__init__.py +0 -0
  6. django_batch_sheet-0.20.2/batch_sheet/management/commands/__init__.py +0 -0
  7. django_batch_sheet-0.20.2/batch_sheet/management/commands/batch_load.py +28 -0
  8. django_batch_sheet-0.20.2/batch_sheet/management/commands/generate_sheet.py +23 -0
  9. {django-batch-sheet-0.20.0 → django_batch_sheet-0.20.2}/django_batch_sheet.egg-info/PKG-INFO +4 -4
  10. {django-batch-sheet-0.20.0 → django_batch_sheet-0.20.2}/django_batch_sheet.egg-info/SOURCES.txt +4 -0
  11. {django-batch-sheet-0.20.0 → django_batch_sheet-0.20.2}/setup.py +3 -3
  12. {django-batch-sheet-0.20.0 → django_batch_sheet-0.20.2}/LICENSE +0 -0
  13. {django-batch-sheet-0.20.0 → django_batch_sheet-0.20.2}/batch_sheet/__init__.py +0 -0
  14. {django-batch-sheet-0.20.0 → django_batch_sheet-0.20.2}/batch_sheet/admin.py +0 -0
  15. {django-batch-sheet-0.20.0 → django_batch_sheet-0.20.2}/batch_sheet/apps.py +0 -0
  16. {django-batch-sheet-0.20.0 → django_batch_sheet-0.20.2}/django_batch_sheet.egg-info/dependency_links.txt +0 -0
  17. {django-batch-sheet-0.20.0 → django_batch_sheet-0.20.2}/django_batch_sheet.egg-info/requires.txt +0 -0
  18. {django-batch-sheet-0.20.0 → django_batch_sheet-0.20.2}/django_batch_sheet.egg-info/top_level.txt +0 -0
  19. {django-batch-sheet-0.20.0 → django_batch_sheet-0.20.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
- Name: django-batch-sheet
3
- Version: 0.20.0
2
+ Name: django_batch_sheet
3
+ Version: 0.20.2
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/
@@ -40,9 +40,9 @@ License-File: LICENSE
40
40
 
41
41
  ## django-batch-sheet
42
42
 
43
- Most of the projects we worked on needs a feature to upload data in batch, we always ended up write another code to handle
44
- the Excel sheet and where each column shall go in the model, in the latest project we decided to handle it differently
45
- and why write a django app that handles this like ModelForm handles models and surprisingly, it worked.
43
+ Most of the projects we worked on needs a feature to upload data in batch, we always ended up writing another code to handle
44
+ the Excel sheet and where each column shall go in the model(s), in the latest project we decided to handle it differently
45
+ and that is why we wrote a django app that handles this like ModelForm handles models and surprisingly, it worked.
46
46
 
47
47
  ## Features
48
48
  * Generate a Sheet from a Django model or a combination of models (through Combined Sheet),
@@ -1,8 +1,8 @@
1
1
  ## django-batch-sheet
2
2
 
3
- Most of the projects we worked on needs a feature to upload data in batch, we always ended up write another code to handle
4
- the Excel sheet and where each column shall go in the model, in the latest project we decided to handle it differently
5
- and why write a django app that handles this like ModelForm handles models and surprisingly, it worked.
3
+ Most of the projects we worked on needs a feature to upload data in batch, we always ended up writing another code to handle
4
+ the Excel sheet and where each column shall go in the model(s), in the latest project we decided to handle it differently
5
+ and that is why we wrote a django app that handles this like ModelForm handles models and surprisingly, it worked.
6
6
 
7
7
  ## Features
8
8
  * Generate a Sheet from a Django model or a combination of models (through Combined Sheet),
@@ -61,7 +61,7 @@ class CombinedSheet(metaclass=DeclarativeCombinedSheetsMetaclass):
61
61
  self._valid = None
62
62
  self.data_sheet_name = 'BatchSheetDetails'
63
63
 
64
- def generate_xls(self,file_path=settings.BASE_DIR + '/data_validate.xls'):
64
+ def generate_xls(self,file_path=str(settings.BASE_DIR) + '/data_validate.xls'):
65
65
  workbook = xlsxwriter.Workbook(file_path)
66
66
  worksheet = workbook.add_worksheet()
67
67
  data_worksheet = workbook.add_worksheet(name=self.data_sheet_name)
@@ -130,4 +130,4 @@ class CombinedSheet(metaclass=DeclarativeCombinedSheetsMetaclass):
130
130
  self.process()
131
131
  else:
132
132
  raise ValidationError("Sheet is not valid")
133
- #sh.close()
133
+ #sh.close()
@@ -211,7 +211,7 @@ class Sheet(metaclass=DeclarativeColumnsMetaclass):
211
211
 
212
212
  return options
213
213
 
214
- def generate_xls(self,file_path=settings.BASE_DIR + '/batch_sheet.xls', worksheet=None,data_worksheet=None,close=True,col_offset=0,**kwargs):
214
+ def generate_xls(self,file_path=str(settings.BASE_DIR) + '/batch_sheet.xls', worksheet=None,data_worksheet=None,close=True,col_offset=0,**kwargs):
215
215
 
216
216
  if not worksheet:
217
217
  workbook = xlsxwriter.Workbook(file_path)
@@ -0,0 +1,28 @@
1
+ import importlib
2
+
3
+ from django.core.management import BaseCommand
4
+
5
+
6
+ class Command(BaseCommand):
7
+ help = "Generate XLS sheet for a Sheet Class"
8
+
9
+ def add_arguments(self, parser):
10
+ parser.add_argument('--xls', nargs='?', type=str,default=None)
11
+ parser.add_argument('--sheet', nargs='?', type=str,default=None)
12
+
13
+ def handle(self, *args, **options):
14
+ if options["xls"] is None:
15
+ print("--xls path of input file is required")
16
+ if options["sheet"] is None:
17
+ print("Class to import is required --sheet")
18
+
19
+ module = importlib.import_module(".".join(options["sheet"].split(".")[:-1]))
20
+ sheet = getattr(module, options["sheet"].split(".")[-1])
21
+ s = sheet()
22
+ s.open(file_name = options["xls"])
23
+ if s.is_valid():
24
+ s.process()
25
+ else:
26
+ print("File isn't valid")
27
+ print(s.errors)
28
+ exit(-1)
@@ -0,0 +1,23 @@
1
+ import importlib
2
+
3
+ from django.core.management import BaseCommand
4
+
5
+
6
+ class Command(BaseCommand):
7
+ help = "Generate XLS sheet for a Sheet Class"
8
+
9
+ def add_arguments(self, parser):
10
+ parser.add_argument('--xls', nargs='?', type=str,default=None)
11
+ parser.add_argument('--sheet', nargs='?', type=str,default=None)
12
+
13
+ def handle(self, *args, **options):
14
+ if options["xls"] is None:
15
+ print("--xls path of output file is required")
16
+ exit(-2)
17
+ if options["sheet"] is None:
18
+ print("Class to export is required --sheet")
19
+ exit(-2)
20
+ module = importlib.import_module(".".join(options["sheet"].split(".")[:-1]))
21
+ s = getattr(module,options["sheet"].split(".")[-1])()
22
+ s.generate_xls(file_path = options["xls"])
23
+ print("Wrote Excel to '%s'"%options["xls"])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: django-batch-sheet
3
- Version: 0.20.0
3
+ Version: 0.20.2
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/
@@ -40,9 +40,9 @@ License-File: LICENSE
40
40
 
41
41
  ## django-batch-sheet
42
42
 
43
- Most of the projects we worked on needs a feature to upload data in batch, we always ended up write another code to handle
44
- the Excel sheet and where each column shall go in the model, in the latest project we decided to handle it differently
45
- and why write a django app that handles this like ModelForm handles models and surprisingly, it worked.
43
+ Most of the projects we worked on needs a feature to upload data in batch, we always ended up writing another code to handle
44
+ the Excel sheet and where each column shall go in the model(s), in the latest project we decided to handle it differently
45
+ and that is why we wrote a django app that handles this like ModelForm handles models and surprisingly, it worked.
46
46
 
47
47
  ## Features
48
48
  * Generate a Sheet from a Django model or a combination of models (through Combined Sheet),
@@ -6,6 +6,10 @@ batch_sheet/Sheet.py
6
6
  batch_sheet/__init__.py
7
7
  batch_sheet/admin.py
8
8
  batch_sheet/apps.py
9
+ batch_sheet/management/__init__.py
10
+ batch_sheet/management/commands/__init__.py
11
+ batch_sheet/management/commands/batch_load.py
12
+ batch_sheet/management/commands/generate_sheet.py
9
13
  django_batch_sheet.egg-info/PKG-INFO
10
14
  django_batch_sheet.egg-info/SOURCES.txt
11
15
  django_batch_sheet.egg-info/dependency_links.txt
@@ -3,8 +3,8 @@
3
3
  from setuptools import find_packages, setup
4
4
 
5
5
  setup(
6
- name='django-batch-sheet',
7
- version='0.20.0',
6
+ name='django_batch_sheet',
7
+ version='0.20.2',
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",
@@ -14,7 +14,7 @@ setup(
14
14
  url = 'https://github.com/mkalioby/django-batch-sheet/',
15
15
  download_url='https://github.com/mkalioby/django-batch-sheet/',
16
16
  license='MIT',
17
- packages=['batch_sheet'],
17
+ packages=['batch_sheet','batch_sheet.management','batch_sheet.management.commands'],
18
18
  install_requires=[
19
19
  'django >= 2.2',
20
20
  'xlsxwriter',