Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Topページレイアウト変更 #95

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion main_app/store_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,10 @@ def get_store_detail(self,place_id):
store_info["address"] = detail_response["formatted_address"]
store_info["tel_number"] = detail_response["formatted_phone_number"]

store_info["photos"] = [self.get_store_photo_url(detail_response["photos"][0]["photo_reference"])]
try:
store_info["photos"] = [self.get_store_photo_url(detail_response["photos"][0]["photo_reference"])]
except Exception as e:
store_info["photos"] = []
try:
store_info["photos"].append(self.get_store_photo_url(detail_response["photos"][1]["photo_reference"]))
except Exception as e:
Expand Down
7 changes: 6 additions & 1 deletion main_app/views/shop.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ def get_context_data(self, **kwargs):
detail["type"] = store_types

detail["open"] = store_info["open"]
detail["img"] = store_info["photos"]

if store_info["photos"]:
detail["img"] = store_info["photos"]
else:
detail["img"] = None

detail["rating"] = float(store_info["rating"])
detail["price_level"] = store_info["price_level"]
detail["detail_url"] = f"{reverse('main_app:shop_detail')}?{urlencode({'place_id': store_info['place_id']})}"
Expand Down
7 changes: 4 additions & 3 deletions main_app/views/top.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ def get_context_data(self, **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")
if reservation_parent:
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 = []
Expand Down
22 changes: 16 additions & 6 deletions templates/main_app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,11 @@ <h5 class="card-title"><i class="bi bi-shop"></i> おすすめのお店 <span>|
{% for store in stores_inner %}
<div class="col-5">
<div class="card">
<img src="{{ store.photo }}" class="card-img-top d-block w-100" alt="Shop Image" style="height: 30vh; width: auto;">
{% if store.photo %}
<img src="{{ store.photo }}" class="card-img-top d-block w-100 shop-img" alt="Shop Image" style="height: 30vh; width: auto;" onerror="this.src='{% static "img/logo.png" %}'; this.removeAttribute('onerror'); this.removeAttribute('onload');" onload="this.removeAttribute('onerror'); this.removeAttribute('onload');">
{% else %}
<img src="{% static 'img/logo.png' %}" class="card-img-top d-block w-100 shop-img" alt="Shop Image" style="height: 30vh; width: auto;">
{% endif %}
<div class="card-body">
<h5 class="card-title"><a href="{{ store.detail_url }}" class="card-link">{{ store.name }}</a></h5>

Expand Down Expand Up @@ -303,9 +307,12 @@ <h6 class="card-subtitle mb-2 text-muted">
<div class="card-body">
<h5 class="card-title">
最新の予約状況<br>
<span><a href="{% url 'main_app:reservation_detail' reservation_id %}">{{ reservation_title }}</a></span>
{% if reservation_title %}
<span><a href="{% url 'main_app:reservation_detail' reservation_id %}">{{ reservation_title }}</a></span>
{% else %}
{% endif %}
</h5>

{% if reservation_title %}
<div class="activity">
{% for state in reservation_detail_items %}
<div class="activity-item d-flex">
Expand Down Expand Up @@ -341,14 +348,17 @@ <h6>{{ state.title }}</h6>
</div><!-- End activity item-->
{% endfor %}
</div>
{% else %}
<p class="p-5 text-center">予約情報がありません</p>
{% endif %}

</div>
</div><!-- End Recent Activity -->

</div><!-- End Right side columns -->

<!-- Recent Sales -->
<div class="col-12">
{% comment %} <div class="col-12">
<div class="card recent-sales overflow-auto">

<div class="card-body">
Expand Down Expand Up @@ -406,8 +416,8 @@ <h5 class="card-title">過去に予約したお店</h5>
</div>

</div>
</div><!-- End Recent Sales -->
</div><!-- End Recent Sales --> {% endcomment %}

</div>
</section>
{% endblock %}
{% endblock %}
8 changes: 7 additions & 1 deletion templates/main_app/shop/shop_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,21 @@ <h5 class="card-title"></h5>
<!-- Slides with controls -->
<div id="carouselExampleControls" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-inner">
{% if shop.img_list%}
{% for img in shop.img_list %}
{% if forloop.first %}
<div class="carousel-item active">
{% else %}
<div class="carousel-item">
{% endif %}
<img src={{ img }} class="d-block w-100" style="height: 30vh; width: auto;">
<img src="{{ img }}" class="d-block w-100" style="height: 30vh; width: auto;">
</div>
{% endfor %}
{% else %}
<div class="carousel-item active">
<img src="{% static 'img/logo.png' %}" class="d-block w-100" style="height: 30vh; width: auto;">
</div>
{% endif %}
</div>

<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleControls" data-bs-slide="prev">
Expand Down
6 changes: 5 additions & 1 deletion templates/main_app/shop/shop_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ <h1>お店を選んで予約</h1>
<div class="masonry-container">
{% for shop in shop_list %}
<div class="card mb-3">
<img src="{{ shop.img }}" class="card-img-top" alt="Shop Image">
{% if shop.img %}
<img src="{{ shop.img }}" class="card-img-top" alt="Shop Image">
{% else %}
<img src="{% static 'img/logo.png' %}" class="card-img-top" alt="Shop Image">
{% endif %}
<div class="card-body">
<h5 class="card-title"><a href="{{ shop.detail_url }}" class="card-link">{{shop.name}}</a></h5>
<h6 class="card-subtitle mb-2 text-muted">
Expand Down