39 lines
1.5 KiB
Python
39 lines
1.5 KiB
Python
#!/srv/venv/bin/python
|
|
import sys
|
|
import os
|
|
from django.core.management.base import BaseCommand, CommandError
|
|
from django.conf import settings
|
|
|
|
import time
|
|
|
|
from rowers.models import (
|
|
Workout, User, Rower, WorkoutForm,
|
|
RowerForm, GraphImage, AdvancedWorkoutForm)
|
|
from django.core.files.base import ContentFile
|
|
|
|
from rowsandall_app.settings import BASE_DIR
|
|
|
|
from rowers.dataprep import *
|
|
|
|
# If you find a solution that does not need the two paths, please comment!
|
|
sys.path.append('$path_to_root_of_project$')
|
|
sys.path.append('$path_to_root_of_project$/$project_name$')
|
|
|
|
os.environ['DJANGO_SETTINGS_MODULE'] = '$project_name$.settings'
|
|
|
|
|
|
class Command(BaseCommand):
|
|
def handle(self, *args, **options):
|
|
# find all Workout instances with uploadedtostrava not 0 or None, workoutsource not 'strava'
|
|
workouts = Workout.objects.filter(uploadedtostrava__gt=0)
|
|
# report the number of workouts found to the console
|
|
self.stdout.write(self.style.SUCCESS('Found {} Strava workouts.'.format(workouts.count())))
|
|
# set workout.privacy to hidden and workout.workoutsource to 'strava, report percentage complete to console'
|
|
for workout in workouts:
|
|
workout.privacy = 'hidden'
|
|
workout.workoutsource = 'strava'
|
|
workout.save()
|
|
self.stdout.write(self.style.SUCCESS('Set workout {} private.'.format(workout.id)))
|
|
|
|
self.stdout.write(self.style.SUCCESS('Successfully set all Strava data private.'))
|