mirror of https://github.com/snachodog/mybuddy.git
Configure support for imports
This commit is contained in:
parent
e81d3c100c
commit
8c64dd8cae
|
@ -221,6 +221,7 @@ REST_FRAMEWORK = {
|
|||
|
||||
IMPORT_EXPORT_IMPORT_PERMISSION_CODE = 'add'
|
||||
IMPORT_EXPORT_EXPORT_PERMISSION_CODE = 'change'
|
||||
IMPORT_EXPORT_USE_TRANSACTIONS = True
|
||||
|
||||
# Baby Buddy configuration
|
||||
# See README.md#configuration for details about these settings.
|
||||
|
|
|
@ -9,12 +9,16 @@ from core import models
|
|||
|
||||
|
||||
class ImportExportResourceBase(resources.ModelResource):
|
||||
id = fields.Field(attribute='id', column_name='entry_id')
|
||||
child = fields.Field(attribute='child__id', column_name='child_id')
|
||||
id = fields.Field(attribute='id')
|
||||
child = fields.Field(attribute='child_id', column_name='child_id')
|
||||
child_first_name = fields.Field(
|
||||
attribute='child__first_name', readonly=True)
|
||||
child_last_name = fields.Field(attribute='child__last_name', readonly=True)
|
||||
|
||||
class Meta:
|
||||
clean_model_instances = True
|
||||
exclude = ('duration',)
|
||||
|
||||
|
||||
class ChildImportExportResource(resources.ModelResource):
|
||||
class Meta:
|
||||
|
@ -50,7 +54,6 @@ class DiaperChangeAdmin(ImportExportMixin, ExportActionMixin,
|
|||
class FeedingImportExportResource(ImportExportResourceBase):
|
||||
class Meta:
|
||||
model = models.Feeding
|
||||
exclude = ('duration',)
|
||||
|
||||
|
||||
@admin.register(models.Feeding)
|
||||
|
@ -79,7 +82,6 @@ class NoteAdmin(ImportExportMixin, ExportActionMixin, admin.ModelAdmin):
|
|||
class SleepImportExportResource(ImportExportResourceBase):
|
||||
class Meta:
|
||||
model = models.Sleep
|
||||
exclude = ('duration',)
|
||||
|
||||
|
||||
@admin.register(models.Sleep)
|
||||
|
@ -114,7 +116,6 @@ class TimerAdmin(admin.ModelAdmin):
|
|||
class TummyTimeImportExportResource(ImportExportResourceBase):
|
||||
class Meta:
|
||||
model = models.TummyTime
|
||||
exclude = ('duration',)
|
||||
|
||||
|
||||
@admin.register(models.TummyTime)
|
||||
|
|
Loading…
Reference in New Issue