educommon 3.12.0__py3-none-any.whl → 3.13.2__py3-none-any.whl

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 (221) hide show
  1. educommon/__init__.py +0 -1
  2. educommon/about/ui/actions.py +16 -30
  3. educommon/about/ui/ui.py +3 -12
  4. educommon/about/utils.py +6 -5
  5. educommon/async_task/__init__.py +0 -1
  6. educommon/async_task/actions.py +18 -13
  7. educommon/async_task/apps.py +4 -0
  8. educommon/async_task/locker.py +2 -5
  9. educommon/async_task/migrations/0001_initial.py +55 -9
  10. educommon/async_task/migrations/0002_task_type_and_status_data.py +94 -89
  11. educommon/async_task/migrations/0003_alter_runningtask_options.py +0 -1
  12. educommon/async_task/models.py +9 -6
  13. educommon/async_task/tasks.py +11 -7
  14. educommon/async_task/ui.py +16 -35
  15. educommon/async_tasks/__init__.py +0 -1
  16. educommon/async_tasks/apps.py +4 -0
  17. educommon/async_tasks/locks.py +11 -21
  18. educommon/async_tasks/migrations/0001_initial.py +68 -8
  19. educommon/async_tasks/migrations/0002_load_initial_data.py +0 -1
  20. educommon/async_tasks/models.py +9 -29
  21. educommon/async_tasks/tasks.py +25 -54
  22. educommon/audit_log/__init__.py +1 -0
  23. educommon/audit_log/actions.py +27 -36
  24. educommon/audit_log/app_meta.py +7 -4
  25. educommon/audit_log/apps.py +44 -29
  26. educommon/audit_log/constants.py +7 -4
  27. educommon/audit_log/error_log/actions.py +1 -3
  28. educommon/audit_log/helpers.py +2 -4
  29. educommon/audit_log/management/commands/reinstall_audit_log.py +11 -7
  30. educommon/audit_log/migrations/0001_initial.py +91 -16
  31. educommon/audit_log/migrations/0002_install_audit_log.py +13 -13
  32. educommon/audit_log/migrations/0003_logproxy.py +1 -3
  33. educommon/audit_log/migrations/0004_reinstall_audit_log.py +1 -4
  34. educommon/audit_log/migrations/0005_postgresql_error.py +4 -2
  35. educommon/audit_log/migrations/0006_auto_20200806_1707.py +3 -4
  36. educommon/audit_log/migrations/0007_create_selective_tables_function.py +8 -5
  37. educommon/audit_log/migrations/0008_table_logged.py +0 -1
  38. educommon/audit_log/migrations/0009_reinstall_audit_log.py +0 -1
  39. educommon/audit_log/models.py +36 -42
  40. educommon/audit_log/permissions.py +11 -9
  41. educommon/audit_log/proxies.py +12 -23
  42. educommon/audit_log/ui.py +18 -15
  43. educommon/audit_log/utils/__init__.py +28 -60
  44. educommon/audit_log/utils/operations.py +16 -2
  45. educommon/auth/__init__.py +0 -3
  46. educommon/auth/rbac/__init__.py +2 -4
  47. educommon/auth/rbac/actions.py +148 -145
  48. educommon/auth/rbac/app_meta.py +9 -6
  49. educommon/auth/rbac/backends/base.py +2 -8
  50. educommon/auth/rbac/backends/caching.py +27 -37
  51. educommon/auth/rbac/backends/simple.py +1 -4
  52. educommon/auth/rbac/checker.py +1 -3
  53. educommon/auth/rbac/management/commands/rbac.py +6 -11
  54. educommon/auth/rbac/manager.py +18 -47
  55. educommon/auth/rbac/migrations/0001_initial.py +73 -12
  56. educommon/auth/rbac/migrations/0002_model_modifier_metaclass_fix.py +7 -6
  57. educommon/auth/rbac/migrations/0003_permission_hidden.py +1 -5
  58. educommon/auth/rbac/migrations/0004_auto_20171024_1245.py +26 -19
  59. educommon/auth/rbac/models.py +63 -68
  60. educommon/auth/rbac/permissions.py +6 -7
  61. educommon/auth/rbac/ui.py +83 -84
  62. educommon/auth/rbac/utils.py +10 -11
  63. educommon/auth/rbac/validators.py +4 -5
  64. educommon/auth/simple_auth/__init__.py +1 -5
  65. educommon/auth/simple_auth/actions.py +79 -92
  66. educommon/auth/simple_auth/app_meta.py +2 -9
  67. educommon/auth/simple_auth/checkers.py +3 -3
  68. educommon/auth/simple_auth/migrations/0001_initial.py +23 -4
  69. educommon/auth/simple_auth/validators.py +0 -1
  70. educommon/contingent/actions.py +7 -7
  71. educommon/contingent/app_meta.py +1 -4
  72. educommon/contingent/base.py +10 -15
  73. educommon/contingent/catalogs.py +424 -540
  74. educommon/contingent/contingent_plugin/actions.py +4 -15
  75. educommon/contingent/contingent_plugin/apps.py +10 -4
  76. educommon/contingent/contingent_plugin/migrations/0001_initial.py +5 -6
  77. educommon/contingent/contingent_plugin/migrations/0002_add_contingent_model_deleted.py +6 -11
  78. educommon/contingent/contingent_plugin/model_views.py +2 -12
  79. educommon/contingent/contingent_plugin/models.py +2 -7
  80. educommon/contingent/contingent_plugin/observer.py +14 -13
  81. educommon/contingent/contingent_plugin/plugin_meta.py +1 -3
  82. educommon/contingent/contingent_plugin/storage.py +8 -7
  83. educommon/contingent/contingent_plugin/utils.py +6 -6
  84. educommon/django/db/fields.py +72 -86
  85. educommon/django/db/migration/__init__.py +3 -7
  86. educommon/django/db/migration/operations.py +29 -51
  87. educommon/django/db/mixins/__init__.py +16 -10
  88. educommon/django/db/mixins/date_interval.py +47 -75
  89. educommon/django/db/mixins/validation.py +26 -26
  90. educommon/django/db/model_view/__init__.py +18 -22
  91. educommon/django/db/models.py +9 -8
  92. educommon/django/db/observer.py +9 -27
  93. educommon/django/db/partitioning/__init__.py +66 -92
  94. educommon/django/db/partitioning/management/commands/apply_partitioning.py +3 -13
  95. educommon/django/db/partitioning/management/commands/clear_table.py +18 -14
  96. educommon/django/db/partitioning/management/commands/split_table.py +18 -13
  97. educommon/django/db/routers.py +6 -15
  98. educommon/django/db/signals.py +149 -2
  99. educommon/django/db/utils.py +14 -19
  100. educommon/django/db/validators/__init__.py +1 -0
  101. educommon/django/db/validators/simple.py +72 -100
  102. educommon/django/storages/atcfs/api.py +39 -53
  103. educommon/django/storages/atcfs/app_meta.py +1 -1
  104. educommon/django/storages/atcfs/management/commands/atcfs_migrate.py +42 -55
  105. educommon/django/storages/atcfs/models.py +0 -3
  106. educommon/django/storages/atcfs/monkey_patching.py +18 -12
  107. educommon/django/storages/atcfs/storage.py +14 -23
  108. educommon/extjs/fields/input_params.py +15 -45
  109. educommon/importer/XLSReader.py +143 -241
  110. educommon/importer/__init__.py +86 -4
  111. educommon/importer/api.py +53 -84
  112. educommon/importer/constants.py +4 -14
  113. educommon/importer/loggers.py +16 -26
  114. educommon/importer/proxy.py +131 -176
  115. educommon/importer/proxy_import.py +11 -12
  116. educommon/importer/report.py +4 -6
  117. educommon/importer/ui.py +32 -26
  118. educommon/importer/validators.py +4 -7
  119. educommon/integration_entities/helpers.py +14 -18
  120. educommon/ioc/__init__.py +3 -6
  121. educommon/logger/loggers.py +10 -14
  122. educommon/m3/__init__.py +20 -38
  123. educommon/m3/extensions/__init__.py +1 -0
  124. educommon/m3/extensions/listeners/__init__.py +22 -38
  125. educommon/m3/extensions/listeners/delete_check/listeners.py +31 -41
  126. educommon/m3/extensions/listeners/delete_check/mixins.py +20 -25
  127. educommon/m3/extensions/listeners/delete_check/signals.py +2 -2
  128. educommon/m3/extensions/listeners/delete_check/ui.py +15 -14
  129. educommon/m3/extensions/listeners/delete_check/utils.py +9 -11
  130. educommon/m3/extensions/ui.py +15 -33
  131. educommon/m3/transaction_context.py +17 -19
  132. educommon/objectpack/actions.py +70 -88
  133. educommon/objectpack/apps.py +5 -0
  134. educommon/objectpack/filters.py +9 -15
  135. educommon/objectpack/ui.py +59 -77
  136. educommon/report/__init__.py +9 -5
  137. educommon/report/actions.py +29 -32
  138. educommon/report/constructor/__init__.py +5 -8
  139. educommon/report/constructor/app_meta.py +1 -3
  140. educommon/report/constructor/apps.py +1 -0
  141. educommon/report/constructor/base.py +33 -80
  142. educommon/report/constructor/builders/excel/_base.py +138 -286
  143. educommon/report/constructor/builders/excel/_header.py +2 -9
  144. educommon/report/constructor/builders/excel/product.py +13 -34
  145. educommon/report/constructor/builders/excel/with_merged_cells.py +18 -14
  146. educommon/report/constructor/config.py +2 -0
  147. educommon/report/constructor/editor/actions.py +101 -215
  148. educommon/report/constructor/editor/ui.py +71 -93
  149. educommon/report/constructor/exceptions.py +6 -12
  150. educommon/report/constructor/migrations/0001_initial.py +36 -44
  151. educommon/report/constructor/migrations/0002_report_filters.py +86 -72
  152. educommon/report/constructor/migrations/0003_reportfilter_exclude.py +5 -5
  153. educommon/report/constructor/migrations/0004_reportfilter_fields.py +22 -18
  154. educommon/report/constructor/migrations/0005_reportcolumn_visible.py +5 -4
  155. educommon/report/constructor/migrations/0006_reportsorting.py +21 -17
  156. educommon/report/constructor/migrations/0007_include_available_units.py +14 -14
  157. educommon/report/constructor/migrations/0008_auto_20170407_1318.py +4 -5
  158. educommon/report/constructor/migrations/0009_auto_20180405_0642.py +1 -4
  159. educommon/report/constructor/migrations/0010_add_aggregate_fields.py +7 -8
  160. educommon/report/constructor/mixins.py +14 -15
  161. educommon/report/constructor/models.py +76 -124
  162. educommon/report/constructor/utils.py +3 -8
  163. educommon/report/constructor/validators.py +1 -3
  164. educommon/report/reporter.py +25 -43
  165. educommon/report/utils.py +14 -40
  166. educommon/rest/actions.py +7 -11
  167. educommon/rest/context.py +6 -16
  168. educommon/rest/controllers.py +10 -10
  169. educommon/rest/mixins.py +29 -27
  170. educommon/secure_media/app_meta.py +9 -9
  171. educommon/utils/__init__.py +3 -2
  172. educommon/utils/caching.py +1 -3
  173. educommon/utils/conversion.py +1 -3
  174. educommon/utils/crypto.py +1 -2
  175. educommon/utils/date.py +13 -26
  176. educommon/utils/db/__init__.py +17 -26
  177. educommon/utils/db/postgresql.py +1 -4
  178. educommon/utils/fonts/__init__.py +3 -4
  179. educommon/utils/licence/__init__.py +5 -16
  180. educommon/utils/misc.py +9 -18
  181. educommon/utils/object_grid.py +55 -62
  182. educommon/utils/phone_number/modelfields.py +1 -3
  183. educommon/utils/phone_number/phone_number.py +5 -8
  184. educommon/utils/phone_number/validators.py +8 -23
  185. educommon/utils/plugins.py +15 -28
  186. educommon/utils/registry.py +2 -1
  187. educommon/utils/seqtools.py +1 -3
  188. educommon/utils/serializer.py +9 -16
  189. educommon/utils/storage.py +3 -2
  190. educommon/utils/system.py +1 -3
  191. educommon/utils/system_app/management/commands/delete_objects.py +17 -34
  192. educommon/utils/ui.py +87 -84
  193. educommon/utils/xml/__init__.py +2 -7
  194. educommon/utils/xml/resolver.py +1 -0
  195. educommon/ws_log/actions.py +31 -76
  196. educommon/ws_log/base.py +6 -20
  197. educommon/ws_log/migrations/0001_initial.py +25 -8
  198. educommon/ws_log/migrations/0002_auto_20160628_1334.py +0 -1
  199. educommon/ws_log/migrations/0003_add_fields_to_smev_logs.py +20 -4
  200. educommon/ws_log/migrations/0004_auto_20160727_1600.py +7 -6
  201. educommon/ws_log/migrations/0005_auto_20161130_1615.py +14 -4
  202. educommon/ws_log/migrations/0006_auto_20170327_1027.py +3 -2
  203. educommon/ws_log/migrations/0007_auto_20180607_1040.py +8 -9
  204. educommon/ws_log/migrations/0008_auto_20180713_1445.py +23 -10
  205. educommon/ws_log/migrations/0009_auto_20201130_1553.py +7 -2
  206. educommon/ws_log/models.py +21 -35
  207. educommon/ws_log/provider.py +2 -1
  208. educommon/ws_log/report.py +8 -13
  209. educommon/ws_log/smev/applications.py +12 -27
  210. educommon/ws_log/smev/exceptions.py +2 -3
  211. educommon/ws_log/ui.py +32 -32
  212. educommon/ws_log/utils.py +1 -3
  213. educommon-3.13.2.dist-info/METADATA +57 -0
  214. educommon-3.13.2.dist-info/RECORD +354 -0
  215. {educommon-3.12.0.dist-info → educommon-3.13.2.dist-info}/WHEEL +1 -1
  216. educommon/utils/patches.py +0 -27
  217. educommon/version.conf +0 -11
  218. educommon-3.12.0.dist-info/METADATA +0 -47
  219. educommon-3.12.0.dist-info/RECORD +0 -357
  220. educommon-3.12.0.dist-info/dependency_links.txt +0 -1
  221. {educommon-3.12.0.dist-info → educommon-3.13.2.dist-info}/top_level.txt +0 -0
@@ -6,32 +6,36 @@ from django.db import (
6
6
 
7
7
 
8
8
  class Migration(migrations.Migration):
9
-
10
- dependencies = [('report_constructor', '0003_reportfilter_exclude'), ]
9
+ dependencies = [
10
+ ('report_constructor', '0003_reportfilter_exclude'),
11
+ ]
11
12
 
12
13
  operations = [
13
14
  migrations.AlterField(
14
15
  model_name='reportfilter',
15
16
  name='operator',
16
17
  field=models.PositiveSmallIntegerField(
17
- choices=[(1, 'Меньше или равно'),
18
- (2, 'Меньше'),
19
- (3, 'Равно'),
20
- (4, 'Больше'),
21
- (5, 'Больше или равно'),
22
- (6, 'Пусто'),
23
- (7, 'Содержит'),
24
- (8, 'Начинается с'),
25
- (9, 'Заканчивается на'),
26
- (10, 'Между'),
27
- (11, 'Равно одному из')],
28
- verbose_name='Оператор сравнения'), ),
18
+ choices=[
19
+ (1, 'Меньше или равно'),
20
+ (2, 'Меньше'),
21
+ (3, 'Равно'),
22
+ (4, 'Больше'),
23
+ (5, 'Больше или равно'),
24
+ (6, 'Пусто'),
25
+ (7, 'Содержит'),
26
+ (8, 'Начинается с'),
27
+ (9, 'Заканчивается на'),
28
+ (10, 'Между'),
29
+ (11, 'Равно одному из'),
30
+ ],
31
+ verbose_name='Оператор сравнения',
32
+ ),
33
+ ),
29
34
  migrations.AlterField(
30
35
  model_name='reportfilter',
31
36
  name='values',
32
37
  field=django.contrib.postgres.fields.ArrayField(
33
- base_field=models.TextField(verbose_name='Значение'),
34
- blank=True,
35
- null=True,
36
- size=None), ),
38
+ base_field=models.TextField(verbose_name='Значение'), blank=True, null=True, size=None
39
+ ),
40
+ ),
37
41
  ]
@@ -5,13 +5,14 @@ from django.db import (
5
5
 
6
6
 
7
7
  class Migration(migrations.Migration):
8
-
9
- dependencies = [('report_constructor', '0004_reportfilter_fields'), ]
8
+ dependencies = [
9
+ ('report_constructor', '0004_reportfilter_fields'),
10
+ ]
10
11
 
11
12
  operations = [
12
13
  migrations.AddField(
13
14
  model_name='reportcolumn',
14
15
  name='visible',
15
- field=models.BooleanField(
16
- default=True, verbose_name='Видимость колонки в отчете'), ),
16
+ field=models.BooleanField(default=True, verbose_name='Видимость колонки в отчете'),
17
+ ),
17
18
  ]
@@ -6,30 +6,34 @@ from django.db import (
6
6
 
7
7
 
8
8
  class Migration(migrations.Migration):
9
-
10
- dependencies = [('report_constructor', '0005_reportcolumn_visible'), ]
9
+ dependencies = [
10
+ ('report_constructor', '0005_reportcolumn_visible'),
11
+ ]
11
12
 
12
13
  operations = [
13
14
  migrations.CreateModel(
14
15
  name='ReportSorting',
15
16
  fields=[
16
- ('id', models.AutoField(
17
- auto_created=True,
18
- primary_key=True,
19
- serialize=False,
20
- verbose_name='ID')),
21
- ('direction', models.PositiveSmallIntegerField(
22
- choices=[(1, 'По возрастанию'), (2, 'По убыванию')],
23
- verbose_name='Направление сортировки')),
24
- ('index', models.PositiveSmallIntegerField(
25
- verbose_name='Порядковый номер')),
26
- ('column', models.OneToOneField(
27
- on_delete=django.db.models.deletion.CASCADE,
28
- to='report_constructor.ReportColumn',
29
- verbose_name='Колонка')),
17
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18
+ (
19
+ 'direction',
20
+ models.PositiveSmallIntegerField(
21
+ choices=[(1, 'По возрастанию'), (2, 'По убыванию')], verbose_name='Направление сортировки'
22
+ ),
23
+ ),
24
+ ('index', models.PositiveSmallIntegerField(verbose_name='Порядковый номер')),
25
+ (
26
+ 'column',
27
+ models.OneToOneField(
28
+ on_delete=django.db.models.deletion.CASCADE,
29
+ to='report_constructor.ReportColumn',
30
+ verbose_name='Колонка',
31
+ ),
32
+ ),
30
33
  ],
31
34
  options={
32
35
  'verbose_name': 'Сортировка',
33
36
  'verbose_name_plural': 'Сортировка',
34
- }, ),
37
+ },
38
+ ),
35
39
  ]
@@ -7,32 +7,30 @@ from django.db import (
7
7
 
8
8
 
9
9
  class Migration(migrations.Migration):
10
-
11
- dependencies = [('report_constructor', '0006_reportsorting'), ]
10
+ dependencies = [
11
+ ('report_constructor', '0006_reportsorting'),
12
+ ]
12
13
 
13
14
  operations = [
14
15
  migrations.AlterModelOptions(
15
16
  name='reportsorting',
16
- options={
17
- 'ordering': ('index', ),
18
- 'verbose_name': 'Сортировка',
19
- 'verbose_name_plural': 'Сортировка'
20
- }, ),
17
+ options={'ordering': ('index',), 'verbose_name': 'Сортировка', 'verbose_name_plural': 'Сортировка'},
18
+ ),
21
19
  migrations.AddField(
22
20
  model_name='reporttemplate',
23
21
  name='include_available_units',
24
- field=models.BooleanField(
25
- default=False,
26
- verbose_name='Отображать данные по дочерним учреждениям'), ),
22
+ field=models.BooleanField(default=False, verbose_name='Отображать данные по дочерним учреждениям'),
23
+ ),
27
24
  migrations.AlterField(
28
25
  model_name='reportfilter',
29
26
  name='values',
30
27
  field=django.contrib.postgres.fields.ArrayField(
31
- base_field=models.TextField(
32
- blank=True, null=True, verbose_name='Значение'),
28
+ base_field=models.TextField(blank=True, null=True, verbose_name='Значение'),
33
29
  blank=True,
34
30
  null=True,
35
- size=None), ),
31
+ size=None,
32
+ ),
33
+ ),
36
34
  migrations.AlterField(
37
35
  model_name='reportsorting',
38
36
  name='column',
@@ -40,5 +38,7 @@ class Migration(migrations.Migration):
40
38
  on_delete=django.db.models.deletion.CASCADE,
41
39
  related_name='sorting',
42
40
  to='report_constructor.ReportColumn',
43
- verbose_name='Колонка'), ),
41
+ verbose_name='Колонка',
42
+ ),
43
+ ),
44
44
  ]
@@ -6,13 +6,12 @@ from django.db import (
6
6
  def delete_reports(apps, schema_editor):
7
7
  """Удаляет отчеты с несуществующими источниками данных."""
8
8
  ReportTemplate = apps.get_model('report_constructor', 'ReportTemplate')
9
- ReportTemplate.objects.filter(
10
- data_source_name__in=('unit.Unit', 'person.Person')
11
- ).delete()
9
+ ReportTemplate.objects.filter(data_source_name__in=('unit.Unit', 'person.Person')).delete()
12
10
 
13
11
 
14
12
  class Migration(migrations.Migration):
15
-
16
- dependencies = [('report_constructor', '0007_include_available_units'), ]
13
+ dependencies = [
14
+ ('report_constructor', '0007_include_available_units'),
15
+ ]
17
16
 
18
17
  operations = [migrations.RunPython(delete_reports)]
@@ -5,7 +5,6 @@ from django.db import (
5
5
 
6
6
 
7
7
  class Migration(migrations.Migration):
8
-
9
8
  dependencies = [
10
9
  ('report_constructor', '0008_auto_20170407_1318'),
11
10
  ]
@@ -14,8 +13,6 @@ class Migration(migrations.Migration):
14
13
  migrations.AlterField(
15
14
  model_name='reporttemplate',
16
15
  name='include_available_units',
17
- field=models.BooleanField(
18
- default=False,
19
- verbose_name='Отображать данные по дочерним организациям'),
16
+ field=models.BooleanField(default=False, verbose_name='Отображать данные по дочерним организациям'),
20
17
  ),
21
18
  ]
@@ -5,7 +5,6 @@ from django.db import (
5
5
 
6
6
 
7
7
  class Migration(migrations.Migration):
8
-
9
8
  dependencies = [
10
9
  ('report_constructor', '0009_auto_20180405_0642'),
11
10
  ]
@@ -15,17 +14,17 @@ class Migration(migrations.Migration):
15
14
  model_name='reportcolumn',
16
15
  name='by_value',
17
16
  field=models.PositiveSmallIntegerField(
18
- blank=True,
19
- choices=[(1, 'Количество'), (2, 'Сумма')],
20
- null=True,
21
- verbose_name='Промежуточный итог'), ),
17
+ blank=True, choices=[(1, 'Количество'), (2, 'Сумма')], null=True, verbose_name='Промежуточный итог'
18
+ ),
19
+ ),
22
20
  migrations.AddField(
23
21
  model_name='reportcolumn',
24
22
  name='total',
25
23
  field=models.PositiveSmallIntegerField(
26
24
  blank=True,
27
- choices=[(1, 'Количество'), (2, 'Сумма'), (
28
- 3, 'Количество уникальных')],
25
+ choices=[(1, 'Количество'), (2, 'Сумма'), (3, 'Количество уникальных')],
29
26
  null=True,
30
- verbose_name='Итог'), ),
27
+ verbose_name='Итог',
28
+ ),
29
+ ),
31
30
  ]
@@ -22,15 +22,19 @@ _BUILDERS_PACKAGE = 'educommon.report.constructor.builders'
22
22
 
23
23
 
24
24
  class BuildReportTaskMixin:
25
+ """Миксин для генерации отчётов по шаблонам.
26
+
27
+ Обеспечивает выбор нужного класса-сборщика отчёта в зависимости от формата
28
+ и шаблона, а также создание файла с отчётом и генерацию ссылки на скачивание.
29
+ """
25
30
 
26
31
  _builders = {
27
- ReportTemplate.EXCEL_SIMPLE:
28
- _BUILDERS_PACKAGE + '.excel.product.ReportBuilder',
29
- ReportTemplate.EXCEL_MERGED:
30
- _BUILDERS_PACKAGE + '.excel.with_merged_cells.ReportBuilder',
32
+ ReportTemplate.EXCEL_SIMPLE: f'{_BUILDERS_PACKAGE}.excel.product.ReportBuilder',
33
+ ReportTemplate.EXCEL_MERGED: f'{_BUILDERS_PACKAGE}.excel.with_merged_cells.ReportBuilder',
31
34
  }
32
35
 
33
36
  def _get_builder(self, report_template, fmt):
37
+ """Определяет и загружает класс-сборщик отчёта по формату шаблона."""
34
38
  if report_template.format == ReportTemplate.USER_DEFINED:
35
39
  report_format = fmt
36
40
  else:
@@ -39,6 +43,7 @@ class BuildReportTaskMixin:
39
43
  builder_name = self._builders[report_format]
40
44
  module_name, _, class_name = builder_name.rpartition('.')
41
45
  module = import_module(module_name)
46
+
42
47
  return getattr(module, class_name)
43
48
 
44
49
  def make_report(self, *args, **kwargs):
@@ -55,20 +60,14 @@ class BuildReportTaskMixin:
55
60
  if not os.path.exists(report_dir):
56
61
  os.mkdir(report_dir)
57
62
  break
58
- file_name = (
59
- slugify(report_template.title, allow_unicode=True) + '.xlsx'
60
- )
63
+ file_name = slugify(report_template.title, allow_unicode=True) + '.xlsx'
61
64
  file_path = os.path.join(report_dir, file_name)
62
65
  builder_class = self._get_builder(report_template, kwargs['format'])
63
- user = kwargs['content_type'].get_object_for_this_type(
64
- id=kwargs['object_id']
65
- )
66
+ user = kwargs['content_type'].get_object_for_this_type(id=kwargs['object_id'])
66
67
  builder = builder_class(report_template, file_path, user)
67
68
  builder.build()
68
- link = os.path.join(
69
- settings.MEDIA_URL, 'report_constructor', report_id, file_name
70
- )
71
- download_link = '<a href="{}" target="_blank" download>{}</a>'.format(
72
- link, file_name)
69
+ link = os.path.join(settings.MEDIA_URL, 'report_constructor', report_id, file_name)
70
+ download_link = '<a href="{}" target="_blank" download>{}</a>'.format(link, file_name)
73
71
  result['download_link'] = download_link
72
+
74
73
  return result