minor mealplan cleanups

This commit is contained in:
vabene1111 2020-05-02 14:58:23 +02:00
parent c398fda15c
commit 37f7326f4c
2 changed files with 12 additions and 8 deletions

View File

@ -227,7 +227,7 @@ class MealPlan(models.Model):
note = models.TextField(blank=True) note = models.TextField(blank=True)
date = models.DateField() date = models.DateField()
def __str__(self): def get_label(self):
if self.title: if self.title:
return self.title return self.title
return str(self.recipe) return str(self.recipe)

View File

@ -9,19 +9,19 @@
{% block content %} {% block content %}
<style> <style>
.mealplan-cell .mealplan-add-button{ .mealplan-cell .mealplan-add-button {
text-align: center; text-align: center;
display: block; display: block;
} }
@media (hover: hover) { @media (hover: hover) {
.mealplan-cell .mealplan-add-button{ .mealplan-cell .mealplan-add-button {
visibility: hidden; visibility: hidden;
float: right; float: right;
display: inline; display: inline;
} }
.mealplan-cell:hover .mealplan-add-button{ .mealplan-cell:hover .mealplan-add-button {
visibility: initial; visibility: initial;
} }
} }
@ -73,13 +73,17 @@
<tr> <tr>
{% for day_key, days_value in plan_value.days.items %} {% for day_key, days_value in plan_value.days.items %}
<td class="mealplan-cell"> <td class="mealplan-cell">
<a class="mealplan-add-button" href="{% url 'new_meal_plan' %}?date={{ day_key|date:'Y-m-d' }}&meal={{ plan_key }}"><i class="fas fa-plus"></i></a> <a class="mealplan-add-button"
href="{% url 'new_meal_plan' %}?date={{ day_key|date:'Y-m-d' }}&meal={{ plan_key }}"><i
class="fas fa-plus"></i></a>
{% for mp in days_value %} {% for mp in days_value %}
<a href="{% url 'edit_meal_plan' mp.pk %}"><i class="fas fa-edit"></i></a>
{% if mp.recipe %} {% if mp.recipe %}
<a href="{% url 'view_recipe' mp.recipe.id %}">{{ mp }}</a><br/> <a href="{% url 'edit_meal_plan' mp.pk %}"><i class="fas fa-edit"></i></a>
<a href="{% url 'view_recipe' mp.recipe.pk %}">{{ mp.recipe }}</a><br/>
{% else %}
<a href="{% url 'edit_meal_plan' mp.pk %}">{{ mp.title }}</a><br/>
{% endif %} {% endif %}
<span>{{ mp.note_head }}</span>
{% endfor %} {% endfor %}
</td> </td>
{% endfor %} {% endfor %}