Skip to content

Commit 1c3c19a

Browse files
committed
Merge branch 'main' into main-test
2 parents a3a70ec + e19080c commit 1c3c19a

8 files changed

Lines changed: 54 additions & 24 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,14 @@ jobs:
5555
sudo chown -R ubuntu:ubuntu /home/ubuntu/Moodico
5656
sudo git config --system --add safe.directory /home/ubuntu/Moodico
5757
58+
sudo chown -R ubuntu:ubuntu /home/ubuntu/Moodico
59+
sudo git config --system --add safe.directory /home/ubuntu/Moodico
60+
5861
cd /home/ubuntu/Moodico
5962
git fetch origin main
6063
git reset --hard origin/main
6164
65+
6266
source venv/bin/activate
6367
pip install --upgrade pip
6468
pip install -r requirements.txt

clustering/generate_clusters.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,11 @@ def calculate_coordinates(h, s, l):
5757

5858
return round(final_warm, 2), round(final_deep, 2)
5959

60+
from django.conf import settings
61+
import os, json
6062
# 데이터 로드
61-
with open("static/data/test_products.json", "r", encoding="utf-8") as f:
63+
file_path = os.path.join(settings.STATIC_ROOT, "data", "test_products.json")
64+
with open(file_path, "r", encoding="utf-8") as f:
6265
products = json.load(f)
6366

6467
coordinates = []
@@ -96,11 +99,25 @@ def calculate_coordinates(h, s, l):
9699
valid_products[i]["cluster"] = int(label)
97100

98101
# 클러스터링 결과를 JSON 파일로 저장
99-
with open("static/data/products_clustered.json", "w", encoding="utf-8") as f:
102+
# with open("static/data/products_clustered.json", "w", encoding="utf-8") as f:
103+
# json.dump(valid_products, f, ensure_ascii=False, indent=2)
104+
105+
# Create a data directory in MEDIA_ROOT
106+
data_dir = os.path.join(settings.MEDIA_ROOT, "data")
107+
os.makedirs(data_dir, exist_ok=True)
108+
file_path = os.path.join(data_dir, "products_clustered.json")
109+
with open(file_path, "w", encoding="utf-8") as f:
100110
json.dump(valid_products, f, ensure_ascii=False, indent=2)
101111

102112
# 클러스터 중심 좌표 저장
103-
with open("static/data/cluster_centers.json", "w", encoding="utf-8") as f:
113+
# with open("static/data/cluster_centers.json", "w", encoding="utf-8") as f:
114+
# json.dump(kmeans.cluster_centers_.tolist(), f, ensure_ascii=False, indent=2)
115+
data_dir = os.path.join(settings.MEDIA_ROOT, "data")
116+
os.makedirs(data_dir, exist_ok=True)
117+
118+
file_path = os.path.join(data_dir, "cluster_centers.json")
119+
120+
with open(file_path, "w", encoding="utf-8") as f:
104121
json.dump(kmeans.cluster_centers_.tolist(), f, ensure_ascii=False, indent=2)
105122

106123
print(" Clustering complete. Files saved.")

crawler/scraper.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@
1111
from selenium.webdriver.chrome.service import Service
1212
from selenium.webdriver.common.by import By
1313
from webdriver_manager.chrome import ChromeDriverManager
14+
import os
15+
from django.conf import settings
1416

1517
TARGETS = [
1618
{"brand": "romand", "url": "https://romand.co.kr/product/maincatedetail.html?cate_code=289"},
1719
{"brand": "3ce", "url": "https://www.3cecosmetics.com/all-products/lips"}
1820
]
1921

2022
SCROLL_COUNT = 4
21-
SAVE_PATH = 'static/data/test_products.json'
23+
# SAVE_PATH = 'static/data/test_products.json'
24+
SAVE_PATH = os.path.join(settings.MEDIA_ROOT, 'data', 'test_products.json')
25+
os.makedirs(os.path.dirname(SAVE_PATH), exist_ok=True)
2226

2327
# Selenium Chrome Driver 설정
2428
options = webdriver.ChromeOptions()

moodico/products/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def color_matrix_explore(request):
2323

2424
return render(request, 'recommendation/color_matrix.html', {'makeupProducts': products})
2525

26+
from django.templatetags.static import static
2627
def product_detail(request, product_id):
2728
"""제품 상세 페이지 뷰"""
2829
# 제품 상세 정보 (백엔드에서 받아올 예정)
@@ -31,7 +32,7 @@ def product_detail(request, product_id):
3132
'name': f'제품 {product_id}',
3233
'description': '이 제품은 아주 좋은 제품입니다.',
3334
'price': '30,000원',
34-
'image': '/static/images/test.jpg', # 임시 이미지
35+
'image': static('images/test.jpg')
3536
}
3637
return render(request, 'products/detail.html', {'product': product})
3738

moodico/recommendation/views.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,17 @@ def recommend_by_color(request):
3434

3535
coord = np.array([warm, deep, lab_l, lab_a, lab_b])
3636
logger.info(f"Received coordinates: warmCool={warm}, lightDeep={deep}, lab_l={lab_l}, lab_a={lab_a}, lab_b={lab_b}")
37-
38-
with open("static/data/cluster_centers.json", "r") as f:
37+
import os
38+
from django.conf import settings
39+
# with open("static/data/cluster_centers.json", "r") as f:
40+
# centers = json.load(f)
41+
path = os.path.join(settings.MEDIA_ROOT, 'data', 'cluster_centers.json')
42+
with open(path, "r", encoding="utf-8") as f:
3943
centers = json.load(f)
40-
with open("static/data/products_clustered.json", "r", encoding="utf-8") as f:
44+
# with open("static/data/products_clustered.json", "r", encoding="utf-8") as f:
45+
# products = json.load(f)
46+
path = os.path.join(settings.MEDIA_ROOT, 'data', 'products_clustered.json')
47+
with open(path, "r", encoding="utf-8") as f:
4148
products = json.load(f)
4249

4350
# Step 1: Find closest cluster

moodico_project/settings.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
if config('DATABASE_URL', default=''):
9595
import dj_database_url
9696
DATABASES = {
97-
'default': dj_database_url.parse(config('DATABASE_URL'), conn_max_age=600, ssl_require=True)
97+
'default': dj_database_url.parse(config('DATABASE_URL'), conn_max_age=600)
9898
}
9999
else:
100100
DATABASES = {
@@ -206,15 +206,4 @@
206206

207207
# 로그인 로그아웃 후 리다이렉트 URL 설정
208208
LOGIN_REDIRECT_URL = "/"
209-
LOGOUT_REDIRECT_URL = "/login/"
210-
211-
# security toggles for production
212-
if not DEBUG:
213-
SECURE_SSL_REDIRECT = config('SECURE_SSL_REDIRECT', cast=bool, default=True)
214-
SESSION_COOKIE_SECURE = True
215-
CSRF_COOKIE_SECURE = True
216-
SECURE_HSTS_SECONDS = config('SECURE_HSTS_SECONDS', cast=int, default=31536000)
217-
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
218-
SECURE_HSTS_PRELOAD = True
219-
SECURE_REFERRER_POLICY = "strict-origin-when-cross-origin"
220-
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
209+
LOGOUT_REDIRECT_URL = "/login/"

templates/products/liked_products.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ <h1>💖 찜한 아이템</h1>
1818
data-product-id="{{ liked_product.product_id }}"
1919
>
2020
<button class="like-button liked" title="좋아요 취소"></button>
21-
<img
21+
{% comment %} <img
2222
src="{{ liked_product.product_image|default:'/static/images/test.jpg' }}"
2323
alt="{{ liked_product.product_name }}"
2424
onerror="this.src='/static/images/test.jpg'"
25+
/> {% endcomment %}
26+
<img
27+
src="{{ liked_product.product_image.url|default:static('images/test.jpg') }}"
28+
alt="{{ liked_product.product_name }}"
29+
onerror="this.src='{% static 'images/test.jpg' %}'"
2530
/>
2631
<div class="product-info">
2732
<div class="like-date">

templates/users/profile.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,11 @@ <h2><span style="color: mediumpurple;">{{ user_name }}</span>님의 프로필</h
101101
{% for liked_product in liked_products %}
102102
<div class="liked-product-card" data-product-id="{{ liked_product.product_id }}">
103103
<button class="like-button liked" title="좋아요 취소"></button>
104-
<img src="{{ liked_product.product_image|default:'/static/images/test.jpg' }}"
105-
alt="{{ liked_product.product_name }}" onerror="this.src='/static/images/test.jpg'" />
104+
{% comment %} <img src="{{ liked_product.product_image|default:'/static/images/test.jpg' }}"
105+
alt="{{ liked_product.product_name }}" onerror="this.src='/static/images/test.jpg'" /> {% endcomment %}
106+
<img src="{{ liked_product.product_image|default:static('images/test.jpg') }}"
107+
alt="{{ liked_product.product_name }}"
108+
onerror="this.src='{% static 'images/test.jpg' %}'" />
106109
<div class="product-info">
107110
<div class="like-date">
108111
찜한 날짜: {{ liked_product.created_at|date:"Y년 m월 d일" }}

0 commit comments

Comments
 (0)