Fix after rebase

This commit is contained in:
smilerz 2021-12-30 13:55:38 -06:00
parent 79b4bc387e
commit 582e145a9f
7 changed files with 57 additions and 59 deletions

View File

@ -7,7 +7,9 @@ SQL_DEBUG=0
ALLOWED_HOSTS=* ALLOWED_HOSTS=*
# random secret key, use for example `base64 /dev/urandom | head -c50` to generate one # random secret key, use for example `base64 /dev/urandom | head -c50` to generate one
# ---------------------------- REQUIRED -------------------------
SECRET_KEY= SECRET_KEY=
# ---------------------------------------------------------------
# your default timezone See https://timezonedb.com/time-zones for a list of timezones # your default timezone See https://timezonedb.com/time-zones for a list of timezones
TIMEZONE=Europe/Berlin TIMEZONE=Europe/Berlin
@ -18,7 +20,9 @@ DB_ENGINE=django.db.backends.postgresql
POSTGRES_HOST=db_recipes POSTGRES_HOST=db_recipes
POSTGRES_PORT=5432 POSTGRES_PORT=5432
POSTGRES_USER=djangouser POSTGRES_USER=djangouser
# ---------------------------- REQUIRED -------------------------
POSTGRES_PASSWORD= POSTGRES_PASSWORD=
# ---------------------------------------------------------------
POSTGRES_DB=djangodb POSTGRES_DB=djangodb
# database connection string, when used overrides other database settings. # database connection string, when used overrides other database settings.

View File

@ -259,7 +259,7 @@ admin.site.register(ViewLog, ViewLogAdmin)
class InviteLinkAdmin(admin.ModelAdmin): class InviteLinkAdmin(admin.ModelAdmin):
list_display = ( list_display = (
'group', 'valid_until', 'group', 'valid_until', 'space',
'created_by', 'created_at', 'used_by' 'created_by', 'created_at', 'used_by'
) )

View File

@ -14,24 +14,24 @@ class CookbookConfig(AppConfig):
def ready(self): def ready(self):
import cookbook.signals # noqa import cookbook.signals # noqa
if not settings.DISABLE_TREE_FIX_STARTUP: # if not settings.DISABLE_TREE_FIX_STARTUP:
# when starting up run fix_tree to: # # when starting up run fix_tree to:
# a) make sure that nodes are sorted when switching between sort modes # # a) make sure that nodes are sorted when switching between sort modes
# b) fix problems, if any, with tree consistency # # b) fix problems, if any, with tree consistency
with scopes_disabled(): # with scopes_disabled():
try: # try:
from cookbook.models import Food, Keyword # from cookbook.models import Food, Keyword
Keyword.fix_tree(fix_paths=True) # Keyword.fix_tree(fix_paths=True)
Food.fix_tree(fix_paths=True) # Food.fix_tree(fix_paths=True)
except OperationalError: # except OperationalError:
if DEBUG: # if DEBUG:
traceback.print_exc() # traceback.print_exc()
pass # if model does not exist there is no need to fix it # pass # if model does not exist there is no need to fix it
except ProgrammingError: # except ProgrammingError:
if DEBUG: # if DEBUG:
traceback.print_exc() # traceback.print_exc()
pass # if migration has not been run database cannot be fixed yet # pass # if migration has not been run database cannot be fixed yet
except Exception: # except Exception:
if DEBUG: # if DEBUG:
traceback.print_exc() # traceback.print_exc()
pass # dont break startup just because fix could not run, need to investigate cases when this happens # pass # dont break startup just because fix could not run, need to investigate cases when this happens

View File

@ -201,7 +201,10 @@ class InviteLinkCreate(GroupRequiredMixin, CreateView):
def form_valid(self, form): def form_valid(self, form):
obj = form.save(commit=False) obj = form.save(commit=False)
obj.created_by = self.request.user obj.created_by = self.request.user
obj.space = self.request.space
# verify given space is actually owned by the user creating the link
if obj.space.created_by != self.request.user:
obj.space = self.request.space
obj.save() obj.save()
if obj.email: if obj.email:
try: try:

View File

@ -51,7 +51,7 @@ That said **beta** should usually be working if you like frequent updates and ne
The main, and also recommended, installation option is to install this application using Docker Compose. The main, and also recommended, installation option is to install this application using Docker Compose.
1. Choose your `docker-compose.yml` from the examples below. 1. Choose your `docker-compose.yml` from the examples below.
2. Download the `.env` configuration file with `wget`, then **edit it accordingly**. 2. Download the `.env` configuration file with `wget`, then **edit it accordingly** (you NEED to set `SECRET_KEY` and `POSTGRES_PASSWORD`).
```shell ```shell
wget https://raw.githubusercontent.com/vabene1111/recipes/develop/.env.template -O .env wget https://raw.githubusercontent.com/vabene1111/recipes/develop/.env.template -O .env
``` ```
@ -136,23 +136,23 @@ In both cases, also make sure to mount `/media/` in your swag container to point
Please refer to the [appropriate documentation](https://github.com/linuxserver/docker-swag#usage) for the container setup. Please refer to the [appropriate documentation](https://github.com/linuxserver/docker-swag#usage) for the container setup.
#### Nginx Swag by LinuxServer #### Nginx Swag by LinuxServer
[This container](https://github.com/linuxserver/docker-swag) is an all in one solution created by LinuxServer.io [This container](https://github.com/linuxserver/docker-swag) is an all in one solution created by LinuxServer.io
It also contains templates for popular apps, including Tandoor Recipes, so you don't have to manually configure nginx and discard the template provided in Tandoor repo. Tandoor config is called `recipes.subdomain.conf.sample` which you can adapt for your instance It also contains templates for popular apps, including Tandoor Recipes, so you don't have to manually configure nginx and discard the template provided in Tandoor repo. Tandoor config is called `recipes.subdomain.conf.sample` which you can adapt for your instance
If you're running Swag on the default port, you'll just need to change the container name to yours. If you're running Swag on the default port, you'll just need to change the container name to yours.
If your running Swag on a custom port, some headers must be changed. To do this, If your running Swag on a custom port, some headers must be changed. To do this,
- Create a copy of `proxy.conf` - Create a copy of `proxy.conf`
- Replace `proxy_set_header X-Forwarded-Host $host;` and `proxy_set_header Host $host;` to - Replace `proxy_set_header X-Forwarded-Host $host;` and `proxy_set_header Host $host;` to
- `proxy_set_header X-Forwarded-Host $http_host;` and `proxy_set_header Host $http_host;` - `proxy_set_header X-Forwarded-Host $http_host;` and `proxy_set_header Host $http_host;`
- Update `recipes.subdomain.conf` to use the new file - Update `recipes.subdomain.conf` to use the new file
- Restart the linuxserver/swag container and Recipes will work - Restart the linuxserver/swag container and Recipes will work
More information [here](https://github.com/TandoorRecipes/recipes/issues/959#issuecomment-962648627). More information [here](https://github.com/TandoorRecipes/recipes/issues/959#issuecomment-962648627).
In both cases, also make sure to mount `/media/` in your swag container to point to your Tandoor Recipes Media directory. In both cases, also make sure to mount `/media/` in your swag container to point to your Tandoor Recipes Media directory.
Please refer to the [appropriate documentation](https://github.com/linuxserver/docker-swag#usage) for the container setup. Please refer to the [appropriate documentation](https://github.com/linuxserver/docker-swag#usage) for the container setup.

View File

@ -49,13 +49,13 @@
<div class="col-md-6 mt-1"> <div class="col-md-6 mt-1">
<label for="id_name"> {{ $t('Preparation') }} {{ $t('Time') }} ({{ $t('min') }})</label> <label for="id_name"> {{ $t('Preparation') }} {{ $t('Time') }} ({{ $t('min') }})</label>
<input class="form-control" id="id_prep_time" v-model="recipe.working_time"> <input class="form-control" id="id_prep_time" v-model="recipe.working_time" type="number">
<br/> <br/>
<label for="id_name"> {{ $t('Waiting') }} {{ $t('Time') }} ({{ $t('min') }})</label> <label for="id_name"> {{ $t('Waiting') }} {{ $t('Time') }} ({{ $t('min') }})</label>
<input class="form-control" id="id_wait_time" v-model="recipe.waiting_time"> <input class="form-control" id="id_wait_time" v-model="recipe.waiting_time" type="number">
<br/> <br/>
<label for="id_name"> {{ $t('Servings') }}</label> <label for="id_name"> {{ $t('Servings') }}</label>
<input class="form-control" id="id_servings" v-model="recipe.servings"> <input class="form-control" id="id_servings" v-model="recipe.servings" type="number">
<br/> <br/>
<label for="id_name"> {{ $t('Servings') }} {{ $t('Text') }}</label> <label for="id_name"> {{ $t('Servings') }} {{ $t('Text') }}</label>
<input class="form-control" id="id_servings_text" v-model="recipe.servings_text" maxlength="32"> <input class="form-control" id="id_servings_text" v-model="recipe.servings_text" maxlength="32">
@ -343,7 +343,7 @@
</div> </div>
<div class="small-padding" <div class="small-padding"
v-bind:class="{ 'col-lg-4 col-md-6': !ingredient.is_header, 'col-lg-12 col-md-12': ingredient.is_header }"> v-bind:class="{ 'col-lg-4 col-md-6': !ingredient.is_header, 'col-lg-12 col-md-12': ingredient.is_header }">
<input class="form-control" <input class="form-control" maxlength="256"
v-model="ingredient.note" v-model="ingredient.note"
v-bind:placeholder="$t('Note')" v-bind:placeholder="$t('Note')"
v-on:keydown.tab="event => {if(step.ingredients.indexOf(ingredient) === (step.ingredients.length -1)){event.preventDefault();addIngredient(step)}}"> v-on:keydown.tab="event => {if(step.ingredients.indexOf(ingredient) === (step.ingredients.length -1)){event.preventDefault();addIngredient(step)}}">
@ -623,9 +623,10 @@ export default {
this.sortIngredients(s) this.sortIngredients(s)
} }
if (this.recipe.waiting_time === ''){ this.recipe.waiting_time = 0} if (this.recipe.waiting_time === '' || isNaN(this.recipe.waiting_time)){ this.recipe.waiting_time = 0}
if (this.recipe.working_time === ''){ this.recipe.working_time = 0} if (this.recipe.working_time === ''|| isNaN(this.recipe.working_time)){ this.recipe.working_time = 0}
if (this.recipe.servings === ''){ this.recipe.servings = 0} if (this.recipe.servings === ''|| isNaN(this.recipe.servings)){ this.recipe.servings = 0}
apiFactory.updateRecipe(this.recipe_id, this.recipe, apiFactory.updateRecipe(this.recipe_id, this.recipe,
{}).then((response) => { {}).then((response) => {

View File

@ -11,11 +11,7 @@
<small style="margin-left: 4px" class="text-muted" v-if="step.time !== 0"><i class="fas fa-user-clock"></i> {{ step.time }} {{ $t("min") }} </small> <small style="margin-left: 4px" class="text-muted" v-if="step.time !== 0"><i class="fas fa-user-clock"></i> {{ step.time }} {{ $t("min") }} </small>
<small v-if="start_time !== ''" class="d-print-none"> <small v-if="start_time !== ''" class="d-print-none">
<b-link :id="`id_reactive_popover_${step.id}`" @click="openPopover" href="#"> <b-link :id="`id_reactive_popover_${step.id}`" @click="openPopover" href="#">
{{ {{ moment(start_time).add(step.time_offset, "minutes").format("HH:mm") }}
moment(start_time)
.add(step.time_offset, "minutes")
.format("HH:mm")
}}
</b-link> </b-link>
</small> </small>
</h5> </h5>
@ -57,11 +53,7 @@
</h4> </h4>
<span style="margin-left: 4px" class="text-muted" v-if="step.time !== 0"><i class="fa fa-stopwatch"></i> {{ step.time }} {{ $t("min") }}</span> <span style="margin-left: 4px" class="text-muted" v-if="step.time !== 0"><i class="fa fa-stopwatch"></i> {{ step.time }} {{ $t("min") }}</span>
<b-link class="d-print-none" :id="`id_reactive_popover_${step.id}`" @click="openPopover" href="#" v-if="start_time !== ''"> <b-link class="d-print-none" :id="`id_reactive_popover_${step.id}`" @click="openPopover" href="#" v-if="start_time !== ''">
{{ {{ moment(start_time).add(step.time_offset, "minutes").format("HH:mm") }}
moment(start_time)
.add(step.time_offset, "minutes")
.format("HH:mm")
}}
</b-link> </b-link>
</div> </div>
@ -106,14 +98,14 @@
<a :href="resolveDjangoUrl('view_recipe', step.step_recipe_data.id)">{{ step.step_recipe_data.name }}</a> <a :href="resolveDjangoUrl('view_recipe', step.step_recipe_data.id)">{{ step.step_recipe_data.name }}</a>
</h2> </h2>
<div v-for="(sub_step, index) in step.step_recipe_data.steps" v-bind:key="`substep_${sub_step.id}`"> <div v-for="(sub_step, index) in step.step_recipe_data.steps" v-bind:key="`substep_${sub_step.id}`">
<Step <step-component
:recipe="step.step_recipe_data" :recipe="step.step_recipe_data"
:step="sub_step" :step="sub_step"
:ingredient_factor="ingredient_factor" :ingredient_factor="ingredient_factor"
:index="index" :index="index"
:start_time="start_time" :start_time="start_time"
:force_ingredients="true" :force_ingredients="true"
></Step> ></step-component>
</div> </div>
</div> </div>
</b-collapse> </b-collapse>
@ -128,7 +120,7 @@
</div> </div>
<div class="row" style="margin-top: 1vh"> <div class="row" style="margin-top: 1vh">
<div class="col-12" style="text-align: right"> <div class="col-12" style="text-align: right">
<b-button @click="closePopover" size="sm" variant="secondary" style="margin-right:8px">Cancel</b-button> <b-button @click="closePopover" size="sm" variant="secondary" style="margin-right: 8px">Cancel</b-button>
<b-button @click="updateTime" size="sm" variant="primary">Ok</b-button> <b-button @click="updateTime" size="sm" variant="primary">Ok</b-button>
</div> </div>
</div> </div>
@ -172,16 +164,14 @@ export default {
} }
}, },
mounted() { mounted() {
this.set_time_input = moment(this.start_time) this.set_time_input = moment(this.start_time).add(this.step.time_offset, "minutes").format("yyyy-MM-DDTHH:mm")
.add(this.step.time_offset, "minutes")
.format("yyyy-MM-DDTHH:mm")
}, },
methods: { methods: {
calculateAmount: function(x) { calculateAmount: function (x) {
// used by the jinja2 template // used by the jinja2 template
return calculateAmount(x, this.ingredient_factor) return calculateAmount(x, this.ingredient_factor)
}, },
updateTime: function() { updateTime: function () {
let new_start_time = moment(this.set_time_input) let new_start_time = moment(this.set_time_input)
.add(this.step.time_offset * -1, "minutes") .add(this.step.time_offset * -1, "minutes")
.format("yyyy-MM-DDTHH:mm") .format("yyyy-MM-DDTHH:mm")
@ -189,10 +179,10 @@ export default {
this.$emit("update-start-time", new_start_time) this.$emit("update-start-time", new_start_time)
this.closePopover() this.closePopover()
}, },
closePopover: function() { closePopover: function () {
this.$refs[`id_reactive_popover_${this.step.id}`].$emit("close") this.$refs[`id_reactive_popover_${this.step.id}`].$emit("close")
}, },
openPopover: function() { openPopover: function () {
this.$refs[`id_reactive_popover_${this.step.id}`].$emit("open") this.$refs[`id_reactive_popover_${this.step.id}`].$emit("open")
}, },
}, },