mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2026-01-02 01:47:04 -05:00
feat: Implement initial schema and add various API, service, and management command enhancements across the application.
This commit is contained in:
@@ -52,9 +52,7 @@ class Command(BaseCommand):
|
||||
park.name}: {
|
||||
photo.image.name}"
|
||||
)
|
||||
self.stdout.write(
|
||||
f"Database record created with ID: {photo.id}"
|
||||
)
|
||||
self.stdout.write(f"Database record created with ID: {photo.id}")
|
||||
else:
|
||||
self.stdout.write(
|
||||
f"Error downloading image. Status code: {
|
||||
@@ -112,9 +110,7 @@ class Command(BaseCommand):
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
self.stdout.write(
|
||||
f"Error downloading ride photo: {str(e)}"
|
||||
)
|
||||
self.stdout.write(f"Error downloading ride photo: {str(e)}")
|
||||
|
||||
except Ride.DoesNotExist:
|
||||
self.stdout.write(
|
||||
|
||||
@@ -49,9 +49,7 @@ class Command(BaseCommand):
|
||||
if files:
|
||||
# Get the first file and update the database
|
||||
# record
|
||||
file_path = os.path.join(
|
||||
content_type, identifier, files[0]
|
||||
)
|
||||
file_path = os.path.join(content_type, identifier, files[0])
|
||||
if os.path.exists(os.path.join("media", file_path)):
|
||||
photo.image.name = file_path
|
||||
photo.save()
|
||||
@@ -111,9 +109,7 @@ class Command(BaseCommand):
|
||||
if files:
|
||||
# Get the first file and update the database
|
||||
# record
|
||||
file_path = os.path.join(
|
||||
content_type, identifier, files[0]
|
||||
)
|
||||
file_path = os.path.join(content_type, identifier, files[0])
|
||||
if os.path.exists(os.path.join("media", file_path)):
|
||||
photo.image.name = file_path
|
||||
photo.save()
|
||||
|
||||
@@ -37,9 +37,7 @@ class Command(BaseCommand):
|
||||
identifier = photo.park.slug
|
||||
|
||||
# Look for any files in that directory
|
||||
old_dir = os.path.join(
|
||||
settings.MEDIA_ROOT, content_type, identifier
|
||||
)
|
||||
old_dir = os.path.join(settings.MEDIA_ROOT, content_type, identifier)
|
||||
if os.path.exists(old_dir):
|
||||
files = [
|
||||
f
|
||||
@@ -83,9 +81,7 @@ class Command(BaseCommand):
|
||||
|
||||
# Move the file
|
||||
if current_path != new_full_path:
|
||||
shutil.copy2(
|
||||
current_path, new_full_path
|
||||
) # Use copy2 to preserve metadata
|
||||
shutil.copy2(current_path, new_full_path) # Use copy2 to preserve metadata
|
||||
processed_files.add(current_path)
|
||||
else:
|
||||
processed_files.add(current_path)
|
||||
@@ -116,9 +112,7 @@ class Command(BaseCommand):
|
||||
identifier = parts[1] # e.g., 'alton-towers'
|
||||
|
||||
# Look for any files in that directory
|
||||
old_dir = os.path.join(
|
||||
settings.MEDIA_ROOT, content_type, identifier
|
||||
)
|
||||
old_dir = os.path.join(settings.MEDIA_ROOT, content_type, identifier)
|
||||
if os.path.exists(old_dir):
|
||||
files = [
|
||||
f
|
||||
@@ -162,9 +156,7 @@ class Command(BaseCommand):
|
||||
|
||||
# Move the file
|
||||
if current_path != new_full_path:
|
||||
shutil.copy2(
|
||||
current_path, new_full_path
|
||||
) # Use copy2 to preserve metadata
|
||||
shutil.copy2(current_path, new_full_path) # Use copy2 to preserve metadata
|
||||
processed_files.add(current_path)
|
||||
else:
|
||||
processed_files.add(current_path)
|
||||
@@ -192,8 +184,6 @@ class Command(BaseCommand):
|
||||
os.remove(file_path)
|
||||
self.stdout.write(f"Removed old file: {file_path}")
|
||||
except Exception as e:
|
||||
self.stdout.write(
|
||||
f"Error removing {file_path}: {str(e)}"
|
||||
)
|
||||
self.stdout.write(f"Error removing {file_path}: {str(e)}")
|
||||
|
||||
self.stdout.write("Finished moving photo files and cleaning up")
|
||||
|
||||
Reference in New Issue
Block a user