-
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 #93 from crab85193/dev_crab
バグ修正
- Loading branch information
Showing
10 changed files
with
389 additions
and
548 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import uuid | ||
from django.db import models | ||
from django.utils import timezone | ||
|
||
class Store(models.Model): | ||
id = models.UUIDField(primary_key=True, editable=False, blank=False, null=False, default=uuid.uuid4) | ||
place_id = models.CharField(max_length=1000, blank=False, null=False) | ||
name = models.CharField(max_length=1000, blank=False, null=False) | ||
type = models.CharField(max_length=1000, blank=False, null=False) | ||
open = models.CharField(max_length=1000, blank=False, null=False) | ||
photo_reference = models.CharField(max_length=1000, blank=False, null=False) | ||
rating = models.CharField(max_length=10, blank=True, null=True) | ||
price_level = models.CharField(max_length=10, blank=True, null=True) | ||
record_datetime = models.DateTimeField(blank=False, null=False, default=timezone.now) | ||
archive = models.BooleanField(blank=False, null=False, default=False) | ||
recommend = models.BooleanField(blank=False, null=False, default=True) | ||
number_of_reservation = models.PositiveIntegerField(blank=False, null=False, default=0) |
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
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,6 +1,78 @@ | ||
from django.urls import reverse | ||
from django.views.generic import TemplateView | ||
from django.contrib.auth.mixins import LoginRequiredMixin | ||
from urllib.parse import urlencode | ||
from ..models.notice import Notice | ||
from ..models.reservation import ReservationParent,ReservationChild | ||
from ..models.store import Store | ||
from ..store_manager import StoreManager | ||
|
||
class TopView(LoginRequiredMixin, TemplateView): | ||
template_name = 'main_app/index.html' | ||
|
||
|
||
def get_context_data(self, **kwargs): | ||
store_manager = StoreManager() | ||
context = super().get_context_data(**kwargs) | ||
|
||
context["notices"] = Notice.objects.order_by('-datetime').all()[:3] | ||
reservation_parent = ReservationParent.objects.filter(user=self.request.user).order_by("-start_datetime").first() | ||
context["reservation_title"] = reservation_parent.shop_name | ||
context["reservation_id"] = reservation_parent.id | ||
context["reservation_detail_items"] = ReservationChild.objects.filter(parent=reservation_parent).order_by("datetime") | ||
|
||
stores_info = [] | ||
store_info_inner = [] | ||
|
||
for store in Store.objects.filter(archive=False): | ||
store_info = {} | ||
store_info["place_id"] = store.place_id | ||
store_info["name"] = store.name | ||
|
||
store_types = "" | ||
for type in store.type.split(" "): | ||
match type: | ||
case "bakery": | ||
store_types += "パン屋" + ", " | ||
case "bar": | ||
store_types += "バー" + ", " | ||
case "cafe": | ||
store_types += "カフェ" + ", " | ||
case "convenience_store": | ||
store_types += "コンビニ" + ", " | ||
case "food": | ||
store_types += "飲食店" + ", " | ||
case "restaurant": | ||
store_types += "レストラン" + ", " | ||
case _: | ||
pass | ||
|
||
store_info["type"] = store_types | ||
store_info["open"] = store.open | ||
store_info["photo"] = store_manager.get_store_photo_url(store.photo_reference) | ||
store_info["rating"] = store.rating | ||
store_info["price_level"] = store.price_level | ||
store_info["record_datetime"] = store.record_datetime | ||
store_info["add_url"] = f"{reverse('main_app:reservation_add')}?{urlencode({'place_id': store_info['place_id']})}" | ||
store_info["detail_url"] = f"{reverse('main_app:shop_detail')}?{urlencode({'place_id': store_info['place_id']})}" | ||
store_info_inner.append(store_info) | ||
print(store_info_inner) | ||
|
||
if len(store_info_inner) == 2: | ||
stores_info.append(store_info_inner) | ||
store_info_inner = [] | ||
|
||
if len(store_info_inner) >= 1: | ||
stores_info.append(store_info_inner) | ||
|
||
context["stores_info"] = stores_info | ||
|
||
# histories_info = [] | ||
# history_info_inner = [] | ||
|
||
# for history in ReservationParent.objects.all().filter(user=self.request.user).order_by("-start_datetime"): | ||
# history_info = {} | ||
|
||
|
||
# context["histories"] | ||
|
||
return context |
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
Oops, something went wrong.