-
Notifications
You must be signed in to change notification settings - Fork 0
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 #38 from Pure-Plate/develop
Release: fix account, review, restaurant list, favorite features
- Loading branch information
Showing
47 changed files
with
124 additions
and
50 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+949 Bytes
pure_plate/account/migrations/__pycache__/0001_initial.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+496 Bytes
(120%)
pure_plate/pure_plate/__pycache__/settings.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
57 changes: 57 additions & 0 deletions
57
...estaurant/migrations/0003_remove_restaurant_categories_restaurant_gluten_free_and_more.py
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,57 @@ | ||
# Generated by Django 4.2.13 on 2024-05-26 11:50 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("restaurant", "0002_rename_categoryid_category_category_id_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name="restaurant", | ||
name="categories", | ||
), | ||
migrations.AddField( | ||
model_name="restaurant", | ||
name="gluten_free", | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.AddField( | ||
model_name="restaurant", | ||
name="halal", | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.AddField( | ||
model_name="restaurant", | ||
name="lacto_free", | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.AddField( | ||
model_name="restaurant", | ||
name="phone", | ||
field=models.CharField(db_index=True, default=0, max_length=255), | ||
preserve_default=False, | ||
), | ||
migrations.AddField( | ||
model_name="restaurant", | ||
name="photo", | ||
field=models.CharField(db_index=True, default="nonphoto", max_length=255), | ||
preserve_default=False, | ||
), | ||
migrations.AddField( | ||
model_name="restaurant", | ||
name="time", | ||
field=models.CharField(db_index=True, default=0, max_length=255), | ||
preserve_default=False, | ||
), | ||
migrations.AddField( | ||
model_name="restaurant", | ||
name="vegan", | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.DeleteModel( | ||
name="Category", | ||
), | ||
] |
Binary file added
BIN
+1.2 KB
pure_plate/restaurant/migrations/__pycache__/0001_initial.cpython-39.pyc
Binary file not shown.
Binary file added
BIN
+652 Bytes
...igrations/__pycache__/0002_rename_categoryid_category_category_id_and_more.cpython-39.pyc
Binary file not shown.
Binary file added
BIN
+1.12 KB
...ycache__/0003_remove_restaurant_categories_restaurant_gluten_free_and_more.cpython-39.pyc
Binary file not shown.
Binary file added
BIN
+172 Bytes
pure_plate/restaurant/migrations/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,40 @@ | ||
from django.test import TestCase | ||
from django.test import TestCase, Client | ||
from django.urls import reverse | ||
from .models import Restaurant | ||
|
||
# Create your tests here. | ||
class RestaurantSearchTests(TestCase): | ||
def setUp(self): | ||
self.client = Client() | ||
# 테스트를 위한 레스토랑 데이터를 생성합니다. | ||
Restaurant.objects.create( | ||
name='Vegan Bliss', address='123 Green Way', vegan=True, halal=False, | ||
gluten_free=True, lacto_free=False, latitude=10.0, longitude=20.0, | ||
time='09:00-21:00', photo='vegan_bliss.jpg', phone='111-222-3333', | ||
review_count=100, avg_rating=4.8 | ||
) | ||
Restaurant.objects.create( | ||
name='Halal Heaven', address='456 Crescent Moon', vegan=False, halal=True, | ||
gluten_free=False, lacto_free=True, latitude=30.0, longitude=40.0, | ||
time='10:00-22:00', photo='halal_heaven.jpg', phone='444-555-6666', | ||
review_count=80, avg_rating=4.6 | ||
) | ||
|
||
def test_search_for_vegan_restaurants(self): | ||
# 비건 옵션을 선택했을 때 해당하는 레스토랑이 반환되는지 테스트합니다. | ||
response = self.client.get(reverse('restaurants-in-categories'), {'categories': 'vegan'}) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertIn('Vegan Bliss', response.content.decode()) | ||
|
||
def test_search_for_halal_restaurants(self): | ||
# 할랄 옵션을 선택했을 때 해당하는 레스토랑이 반환되는지 테스트합니다. | ||
response = self.client.get(reverse('restaurants-in-categories'), {'categories': 'halal'}) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertIn('Halal Heaven', response.content.decode()) | ||
|
||
def test_search_for_gluten_free_and_lacto_free_restaurants(self): | ||
# 글루텐 프리와 락토 프리 옵션을 모두 선택했을 때 해당하는 레스토랑이 없다는 것을 테스트합니다. | ||
response = self.client.get(reverse('restaurants-in-categories'), {'categories': 'glutenfree,lactofree'}) | ||
self.assertEqual(response.status_code, 200) | ||
content = response.content.decode() | ||
# 이 부분은 실제 반환되는 내용에 따라 수정이 필요할 수 있습니다. | ||
self.assertTrue('No restaurants found' in content or '[]' in content) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,40 @@ | ||
from django.http import JsonResponse | ||
from django.db.models import Count | ||
from .models import Restaurant, Category | ||
from .models import Restaurant | ||
|
||
#/api/restaurants_in_categories?categories=Italian,Chinese,Mexican | ||
|
||
def restaurants_in_categories_view(request): | ||
def restaurants_list(request): | ||
|
||
try: | ||
category_names = request.GET.get('categories', '') | ||
if not category_names: | ||
return JsonResponse({ | ||
'status': 200, | ||
'message': 'Category is not selected.', | ||
'data': [] | ||
}) | ||
|
||
category_names_list = category_names.split(',') | ||
|
||
# find all restaurants in selected categories | ||
categories = Category.objects.filter(CategoryName__in=category_names_list) | ||
restaurants = Restaurant.objects.filter(categories__in=categories).distinct() | ||
|
||
# filtered restaurants list category by category | ||
data = {} | ||
for category_name in category_names_list: | ||
category_restaurants = restaurants.filter(categories__CategoryName=category_name) | ||
category_list = [{ | ||
'restaurantId': restaurant.id, | ||
'restaurantName': restaurant.name, | ||
'restaurantAddress': restaurant.address, | ||
'restaurantLatitude': float(restaurant.latitude), | ||
'restaurantLongitude': float(restaurant.longitude), | ||
# 'restaurantTime': restaurant.time, | ||
# 'restaurantPhoto': restaurant.photo, | ||
# 'restaurantPhone': restaurant.phone, | ||
'restaurantReviewCount': restaurant.review_count, | ||
'restaurantRating': str(restaurant.avg_rating), | ||
} for restaurant in category_restaurants] | ||
data[f"{category_name}List"] = category_list | ||
restaurants = Restaurant.objects.all() | ||
|
||
data = [{ | ||
'Id': restaurant.id, | ||
'Name': restaurant.name, | ||
'Address': restaurant.address, | ||
'Latitude': str(restaurant.latitude), | ||
'Longitude': str(restaurant.longitude), | ||
'Time': restaurant.time, | ||
'Photo': restaurant.photo, | ||
'Phone': restaurant.phone, | ||
'ReviewCount': restaurant.review_count, | ||
'Rating': str(restaurant.avg_rating), | ||
'Vegan': restaurant.vegan, | ||
'Halal': restaurant.halal, | ||
'GlutenFree': restaurant.gluten_free, | ||
'LactoFree': restaurant.lacto_free | ||
} for restaurant in restaurants] | ||
|
||
|
||
response = { | ||
'status': 200, | ||
'message': 'Successfully retrieved the restaurant list.', | ||
'data': data | ||
} | ||
|
||
return JsonResponse(response) | ||
return JsonResponse(response, status=200) | ||
|
||
except Exception as e: | ||
return JsonResponse({'status': 400, 'message': str(e), 'data': []}) | ||
return JsonResponse({'status': 400, 'message': str(e), 'data': []}, status=400) | ||
|
||
|
||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.