forked from City-of-Helsinki/smbackend
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #319 from City-of-Turku/develop
Production update
- Loading branch information
Showing
51 changed files
with
4,236 additions
and
563 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
eco_counter/management/commands/delete_all_counter_data.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import logging | ||
|
||
from django import db | ||
from django.core.management.base import BaseCommand | ||
|
||
from eco_counter.constants import COUNTER_CHOICES_STR | ||
from eco_counter.management.commands.utils import check_counters_argument | ||
from eco_counter.models import ImportState, Station | ||
|
||
logger = logging.getLogger("eco_counter") | ||
|
||
|
||
class Command(BaseCommand): | ||
def add_arguments(self, parser): | ||
parser.add_argument( | ||
"--counters", | ||
type=str, | ||
nargs="+", | ||
default=False, | ||
help=f"Delete given counter data, choices are: {COUNTER_CHOICES_STR}.", | ||
) | ||
|
||
@db.transaction.atomic | ||
def handle(self, *args, **options): | ||
counters = options.get("counters", None) | ||
check_counters_argument(counters) | ||
if counters: | ||
for counter in counters: | ||
logger.info(f"Deleting counter data for {counter}") | ||
logger.info( | ||
f"{Station.objects.filter(csv_data_source=counter).delete()}" | ||
) | ||
logger.info( | ||
f"{ImportState.objects.filter(csv_data_source=counter).delete()}" | ||
) | ||
logger.info("Deleted counter data.") |
Oops, something went wrong.