Skip to content

Commit

Permalink
Merge pull request #81 from ppfeufer/development
Browse files Browse the repository at this point in the history
[FIX] `django.db.utils.IntegrityError: (1048, "Column 'log_time' cannot be null")` on log merge.
  • Loading branch information
ppfeufer authored Apr 21, 2021
2 parents c5f552e + 05252ad commit 9ab40e0
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 24 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [2.0.1] - 2021-04-22

### Fixed

- `django.db.utils.IntegrityError: (1048, "Column 'log_time' cannot be null")` on
log merge.


## [2.0.0] - 2021-04-21

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion afat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

default_app_config: str = "afat.apps.AfatConfig"

__version__ = "2.0.0"
__version__ = "2.0.1"
__title__ = "Fleet Activity Tracking"
13 changes: 7 additions & 6 deletions afat/management/commands/afat_import_from_bfat.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,13 @@ def _import_from_imicusfat(self) -> None:
f'"{bfat_fatlink.fleet}" was created by {bfat_fatlink.creator}'
)

afatlog = AFatLog()
afatlog.log_time = bfat_fatlink.fattime
afatlog.log_event = AFatLogEvent.CREATE_FATLINK
afatlog.log_text = log_text
afatlog.user_id = bfat_fatlink.creator_id
afatlog.save()
if bfat_fatlink.fattime is not None:
afatlog = AFatLog()
afatlog.log_time = bfat_fatlink.fattime
afatlog.log_event = AFatLogEvent.CREATE_FATLINK
afatlog.log_text = log_text
afatlog.user_id = bfat_fatlink.creator_id
afatlog.save()

# import FATs
bfat_fats = BfatFat.objects.all()
Expand Down
13 changes: 7 additions & 6 deletions afat/management/commands/afat_import_from_imicusfat.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,13 @@ def _import_from_imicusfat(self) -> None:
fatlink_hash=fatlink.hash,
)

afatlog = AFatLog()
afatlog.log_time = imicusfat_manualfat.created_at
afatlog.log_event = AFatLogEvent.MANUAL_FAT
afatlog.log_text = log_text
afatlog.user_id = imicusfat_manualfat.creator_id
afatlog.save()
if imicusfat_manualfat.created_at is not None:
afatlog = AFatLog()
afatlog.log_time = imicusfat_manualfat.created_at
afatlog.log_event = AFatLogEvent.MANUAL_FAT
afatlog.log_text = log_text
afatlog.user_id = imicusfat_manualfat.creator_id
afatlog.save()

self.stdout.write(
self.style.SUCCESS(
Expand Down
23 changes: 12 additions & 11 deletions afat/management/commands/afat_migrate_manual_fat_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@ def _migrate_manual_fat_log(self) -> None:

if manual_fat_logs.count() > 0:
for manual_log in manual_fat_logs:
afat_log = AFatLog()

afat_log.user_id = manual_log.creator_id
afat_log.log_time = manual_log.created_at
afat_log.log_event = AFatLogEvent.MANUAL_FAT
afat_log.log_text = (
f"Pilot {manual_log.character} manually added. "
f"(Migrated from old Manual FAT log)"
)
afat_log.fatlink_hash = manual_log.afatlink.hash
afat_log.save()
if manual_log.created_at is not None:
afat_log = AFatLog()

afat_log.user_id = manual_log.creator_id
afat_log.log_time = manual_log.created_at
afat_log.log_event = AFatLogEvent.MANUAL_FAT
afat_log.log_text = (
f"Pilot {manual_log.character} manually added. "
f"(Migrated from old Manual FAT log)"
)
afat_log.fatlink_hash = manual_log.afatlink.hash
afat_log.save()

manual_log.delete()

Expand Down

0 comments on commit 9ab40e0

Please sign in to comment.