feat: show plant card button on detail page when card photos exist
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
52acd9e1f1
commit
dff1c88748
3 changed files with 16 additions and 1 deletions
|
|
@ -77,6 +77,10 @@
|
||||||
{% include "plants/partials/photo_gallery.html" %}
|
{% include "plants/partials/photo_gallery.html" %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if plant.card_photos.exists %}
|
||||||
|
<a href="{% url 'plant_card' plant.pk %}" class="btn btn-sm btn-outline-secondary mb-2">🪧 View plant card</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<a href="{% url 'plant_delete' plant.pk %}" class="btn btn-outline-danger btn-sm mt-2">Delete plant</a>
|
<a href="{% url 'plant_delete' plant.pk %}" class="btn btn-outline-danger btn-sm mt-2">Delete plant</a>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,17 @@ class TestPlantDetail:
|
||||||
assert resp.context['plant'] == plant
|
assert resp.context['plant'] == plant
|
||||||
assert resp.context['pruning_status'] == 'no_schedule'
|
assert resp.context['pruning_status'] == 'no_schedule'
|
||||||
|
|
||||||
|
def test_card_button_shown_when_card_photos_exist(self, client):
|
||||||
|
plant = Plant.objects.create(name='Fern')
|
||||||
|
PlantCardPhoto.objects.create(plant=plant, image='plants/cards/card.jpg')
|
||||||
|
resp = client.get(reverse('plant_detail', args=[plant.pk]))
|
||||||
|
assert 'View plant card' in resp.content.decode()
|
||||||
|
|
||||||
|
def test_card_button_hidden_when_no_card_photos(self, client):
|
||||||
|
plant = Plant.objects.create(name='Fern')
|
||||||
|
resp = client.get(reverse('plant_detail', args=[plant.pk]))
|
||||||
|
assert 'View plant card' not in resp.content.decode()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
class TestLogPruning:
|
class TestLogPruning:
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ def plant_list(request):
|
||||||
|
|
||||||
def plant_detail(request, pk):
|
def plant_detail(request, pk):
|
||||||
plant = get_object_or_404(
|
plant = get_object_or_404(
|
||||||
Plant.objects.select_related('species', 'location').prefetch_related('pruning_logs', 'photos'),
|
Plant.objects.select_related('species', 'location').prefetch_related('pruning_logs', 'photos', 'card_photos'),
|
||||||
pk=pk,
|
pk=pk,
|
||||||
)
|
)
|
||||||
today = date.today()
|
today = date.today()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue