several shopping list improvements

This commit is contained in:
vabene1111 2021-03-17 23:28:28 +01:00
parent 76eeed1a77
commit 2149f4034b
2 changed files with 9 additions and 7 deletions

View File

@ -510,14 +510,14 @@ class ShoppingListRecipe(models.Model, PermissionModelMixin):
recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE, null=True, blank=True)
servings = models.DecimalField(default=1, max_digits=8, decimal_places=4)
objects = ScopedManager(space='shoppinglist__space')
objects = ScopedManager(space='recipe__space')
@staticmethod
def get_space_key():
return 'shoppinglist', 'space'
return 'recipe', 'space'
def get_space(self):
return self.shoppinglist_set.first().space
return self.recipe.space
def __str__(self):
return f'Shopping list recipe {self.id} - {self.recipe}'

View File

@ -122,8 +122,8 @@
</tr>
</thead>
<tbody is="draggable" :list="c.entries" tag="tbody" group="people" @sort="sortEntries"
@change="dragChanged(c, $event)">
<tr v-for="(element, index) in c.entries" :key="element.id">
@change="dragChanged(c, $event)" handle=".handle">
<tr v-for="(element, index) in c.entries" :key="element.id" v-bind:class="{ 'text-muted': element.checked }">
<td class="handle"><i class="fas fa-sort"></i></td>
<td>[[element.amount]]</td>
<td>[[element.unit.name]]</td>
@ -154,7 +154,7 @@
<div class="input-group">
<input id="id_simple_entry" class="form-control" v-model="simple_entry">
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="button"><i class="fa fa-plus"></i>
<button class="btn btn-outline-secondary" type="button" @click="addSimpleEntry()"><i class="fa fa-plus"></i>
</button>
</div>
</div>
@ -349,6 +349,8 @@
</div>
</div>
<br/>
<br/>
<b-modal id="id_modal_export" title="{% trans 'Copy/Export' %}">
<div class="row">
@ -448,7 +450,7 @@
name: gettext('Uncategorized'),
id: -1,
entries: [],
order: 99999999
order: -1
}
}