From 903922662778e0672b908d1231eeb6faac096df0 Mon Sep 17 00:00:00 2001 From: Sketch <75850871+SketchMaster2001@users.noreply.github.com> Date: Thu, 4 Jul 2024 20:23:31 -0400 Subject: [PATCH 1/2] fix: Generate room and concierge categories in S3 --- asset_data.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/asset_data.py b/asset_data.py index d366b455..23b3bc3e 100644 --- a/asset_data.py +++ b/asset_data.py @@ -133,6 +133,20 @@ def upload_to_s3(self, im: bytes): ExtraArgs={"ContentType": "text/xml"}, ) + s3.upload_fileobj( + io.BytesIO(list_category_n("02")), + config.r2_bucket_name, + "list/category/02.xml", + ExtraArgs={"ContentType": "text/xml"}, + ) + + s3.upload_fileobj( + io.BytesIO(list_category_n("03")), + config.r2_bucket_name, + "list/category/03.xml", + ExtraArgs={"ContentType": "text/xml"}, + ) + class PayCategoryAsset(Asset): """Used for categories within the Theater.""" From 6d3565d06425cd779d8260e4f96de942f21701e4 Mon Sep 17 00:00:00 2001 From: Sketch <75850871+SketchMaster2001@users.noreply.github.com> Date: Thu, 4 Jul 2024 20:25:45 -0400 Subject: [PATCH 2/2] fix: Properly delete category asset --- asset_data.py | 25 +++++++++++++++++++++++++ theunderground/categories.py | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/asset_data.py b/asset_data.py index 23b3bc3e..31c23518 100644 --- a/asset_data.py +++ b/asset_data.py @@ -147,6 +147,31 @@ def upload_to_s3(self, im: bytes): ExtraArgs={"ContentType": "text/xml"}, ) + def remove_from_s3(self): + s3.delete_object(Bucket=config.r2_bucket_name, Key=self.s3_path()) + + # Regenerate the categories + s3.upload_fileobj( + io.BytesIO(list_category_n("01")), + config.r2_bucket_name, + "list/category/01.xml", + ExtraArgs={"ContentType": "text/xml"}, + ) + + s3.upload_fileobj( + io.BytesIO(list_category_n("02")), + config.r2_bucket_name, + "list/category/02.xml", + ExtraArgs={"ContentType": "text/xml"}, + ) + + s3.upload_fileobj( + io.BytesIO(list_category_n("03")), + config.r2_bucket_name, + "list/category/03.xml", + ExtraArgs={"ContentType": "text/xml"}, + ) + class PayCategoryAsset(Asset): """Used for categories within the Theater.""" diff --git a/theunderground/categories.py b/theunderground/categories.py index 3650ece6..3631e4cc 100644 --- a/theunderground/categories.py +++ b/theunderground/categories.py @@ -95,7 +95,7 @@ def remove_category(category): def drop_category(): db.session.delete(current_category) db.session.commit() - os.unlink(NormalCategoryAsset(category).asset_path()) + NormalCategoryAsset(category).delete() return redirect(url_for("list_categories"))