Compare commits
14 commits
09ce26af14
...
b123a010a3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b123a010a3 | ||
|
|
4925e1caab | ||
|
|
2085008504 | ||
|
|
564f538708 | ||
|
|
ba196d046c | ||
|
|
846c5cf1f6 | ||
|
|
7b1c9b0f45 | ||
|
|
35da38858f | ||
|
|
f13cf3d6c7 | ||
|
|
a860cf9406 | ||
|
|
208c4581d6 | ||
|
|
94a49a494e | ||
|
|
900e01da1b | ||
|
|
fb4bd446d4 |
|
|
@ -1,58 +0,0 @@
|
|||
{#
|
||||
Barn Web App - A collection of web-apps for my family's personal use,
|
||||
including a recipe database.
|
||||
Copyright © 2023 Benjamin Stadlbauer
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or (at
|
||||
your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
|
||||
General Public License for more details.
|
||||
|
||||
This program comes with a copy of the GNU Affero General Public License
|
||||
file at the root of this project.
|
||||
#}
|
||||
{% extends "base_main.html" %}
|
||||
{% block title %}{{ recipe.title }}{% endblock %}
|
||||
{% block main %}
|
||||
<form action="" method="post" id="add-version-form">
|
||||
{%csrf_token %}
|
||||
<table>
|
||||
{{ version_form.as_table }}
|
||||
</table>
|
||||
{{ ingredients_formset.management_form }}
|
||||
{% for ingredient_form in ingredients_formset %}
|
||||
{{ ingredient_form.as_div }}
|
||||
{% endfor %}
|
||||
<button id="add-ingredient" type="button">Add Ingredient</button>
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
||||
|
||||
<script>
|
||||
let firstIngredientDiv = document.querySelector("input[id^=id_ingredient][id$=text]").parentElement;
|
||||
let addIngredientButton = document.querySelector("#add-ingredient");
|
||||
let form = document.querySelector("#add-version-form");
|
||||
let totalIngredientFormsInput = document.querySelector("#id_ingredient-TOTAL_FORMS");
|
||||
|
||||
addIngredientButton.addEventListener('click', addIngredient);
|
||||
|
||||
function addIngredient(e) {
|
||||
let nextIngredientIndex = document.querySelectorAll("input[id^=id_ingredient][id$=text]").length
|
||||
e.preventDefault();
|
||||
|
||||
let newIngredientDiv = firstIngredientDiv.cloneNode(true);
|
||||
let formRegex = new RegExp('ingredient-(\\d){1}-', 'g');
|
||||
|
||||
newIngredientDiv.innerHTML = newIngredientDiv.innerHTML.replace(formRegex, `ingredient-${nextIngredientIndex}-`);
|
||||
|
||||
form.insertBefore(newIngredientDiv, addIngredientButton);
|
||||
totalIngredientFormsInput.setAttribute('value', `${nextIngredientIndex + 1}`);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
{#
|
||||
{% extends "base_main.html" %}
|
||||
{% comment %}
|
||||
Barn Web App - A collection of web-apps for my family's personal use,
|
||||
including a recipe database.
|
||||
Copyright © 2023 Benjamin Stadlbauer
|
||||
|
|
@ -15,8 +16,7 @@
|
|||
|
||||
This program comes with a copy of the GNU Affero General Public License
|
||||
file at the root of this project.
|
||||
#}
|
||||
{% extends "base_main.html" %}
|
||||
{% endcomment %}
|
||||
{% block title %}{{ recipe.title }}{% endblock %}
|
||||
{% block main %}
|
||||
<form action="" method="post">
|
||||
|
|
|
|||
|
|
@ -1,58 +0,0 @@
|
|||
{#
|
||||
Barn Web App - A collection of web-apps for my family's personal use,
|
||||
including a recipe database.
|
||||
Copyright © 2023 Benjamin Stadlbauer
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or (at
|
||||
your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
|
||||
General Public License for more details.
|
||||
|
||||
This program comes with a copy of the GNU Affero General Public License
|
||||
file at the root of this project.
|
||||
#}
|
||||
{% extends "base_main.html" %}
|
||||
{% block title %}{{ recipe.title }}{% endblock %}
|
||||
{% block main %}
|
||||
<form action="" method="post" id="edit-version-form"> {# TODO refactor with add-version.html#}
|
||||
{%csrf_token %}
|
||||
<table>
|
||||
{{ version_form.as_table }}
|
||||
</table>
|
||||
{{ ingredients_formset.management_form }}
|
||||
{% for ingredient_form in ingredients_formset %}
|
||||
{{ ingredient_form.as_div }}
|
||||
{% endfor %}
|
||||
<button id="add-ingredient" type="button">Add Ingredient</button>
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
||||
|
||||
<script>
|
||||
let firstIngredientDiv = document.querySelector("input[id^=id_ingredient][id$=text]").parentElement;
|
||||
let addIngredientButton = document.querySelector("#add-ingredient");
|
||||
let form = document.querySelector("#edit-version-form");
|
||||
let totalIngredientFormsInput = document.querySelector("#id_ingredient-TOTAL_FORMS");
|
||||
|
||||
addIngredientButton.addEventListener('click', addIngredient);
|
||||
|
||||
function addIngredient(e) {
|
||||
let nextIngredientIndex = document.querySelectorAll("input[id^=id_ingredient][id$=text]").length
|
||||
e.preventDefault();
|
||||
|
||||
let newIngredientDiv = firstIngredientDiv.cloneNode(true);
|
||||
let formRegex = new RegExp('ingredient-(\\d){1}-', 'g');
|
||||
|
||||
newIngredientDiv.innerHTML = newIngredientDiv.innerHTML.replace(formRegex, `ingredient-${nextIngredientIndex}-`);
|
||||
|
||||
form.insertBefore(newIngredientDiv, addIngredientButton);
|
||||
totalIngredientFormsInput.setAttribute('value', `${nextIngredientIndex + 1}`);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
{#
|
||||
{% extends "base_main.html" %}
|
||||
{% comment %}
|
||||
Barn Web App - A collection of web-apps for my family's personal use,
|
||||
including a recipe database.
|
||||
Copyright © 2023 Benjamin Stadlbauer
|
||||
|
|
@ -15,16 +16,15 @@
|
|||
|
||||
This program comes with a copy of the GNU Affero General Public License
|
||||
file at the root of this project.
|
||||
#}
|
||||
{% extends "base_main.html" %}
|
||||
{% endcomment %}
|
||||
{% block title %}{{ recipe.title }}{% endblock %}
|
||||
{% block main %}
|
||||
<form action="" method="post" id="add-version-form">
|
||||
<form action="" method="post" id="version-form">
|
||||
{%csrf_token %}
|
||||
{{ recipe_form.as_div }}
|
||||
<table>
|
||||
{{ version_form.as_table }}
|
||||
</table>
|
||||
{% if recipe_form %}
|
||||
{{ recipe_form.as_div }}
|
||||
{% endif %}
|
||||
{{ version_form.as_div }}
|
||||
{{ ingredients_formset.management_form }}
|
||||
{% for ingredient_form in ingredients_formset %}
|
||||
{{ ingredient_form.as_div }}
|
||||
|
|
@ -36,7 +36,7 @@
|
|||
<script>
|
||||
let firstIngredientDiv = document.querySelector("input[id^=id_ingredient][id$=text]").parentElement;
|
||||
let addIngredientButton = document.querySelector("#add-ingredient");
|
||||
let form = document.querySelector("#add-version-form");
|
||||
let form = document.querySelector("#version-form");
|
||||
let totalIngredientFormsInput = document.querySelector("#id_ingredient-TOTAL_FORMS");
|
||||
|
||||
addIngredientButton.addEventListener('click', addIngredient);
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
{#
|
||||
{% extends "base_main.html" %}
|
||||
{% comment %}
|
||||
Barn Web App - A collection of web-apps for my family's personal use,
|
||||
including a recipe database.
|
||||
Copyright © 2023 Benjamin Stadlbauer
|
||||
|
|
@ -15,8 +16,7 @@
|
|||
|
||||
This program comes with a copy of the GNU Affero General Public License
|
||||
file at the root of this project.
|
||||
#}
|
||||
{% extends "base_main.html" %}
|
||||
{% endcomment %}
|
||||
{% block title %}{{ recipe.title }}{% endblock %}
|
||||
{% block main %}
|
||||
<h1>{{ recipe.title }}</h1>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{#
|
||||
{% extends "base_main.html" %}
|
||||
{% comment %}
|
||||
Barn Web App - A collection of web-apps for my family's personal use,
|
||||
including a recipe database.
|
||||
Copyright © 2023 Benjamin Stadlbauer
|
||||
|
|
@ -15,8 +16,7 @@
|
|||
|
||||
This program comes with a copy of the GNU Affero General Public License
|
||||
file at the root of this project.
|
||||
#}
|
||||
{% extends "base_main.html" %}
|
||||
{% endcomment %}
|
||||
{% block title %}Recipes{% endblock %}
|
||||
{% block main %}
|
||||
<h1>Recipes</h1>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{#
|
||||
{% extends "base_main.html" %}
|
||||
{% comment %}
|
||||
Barn Web App - A collection of web-apps for my family's personal use,
|
||||
including a recipe database.
|
||||
Copyright © 2023 Benjamin Stadlbauer
|
||||
|
|
@ -15,8 +16,7 @@
|
|||
|
||||
This program comes with a copy of the GNU Affero General Public License
|
||||
file at the root of this project.
|
||||
#}
|
||||
{% extends "base_main.html" %}
|
||||
{% endcomment %}
|
||||
{% block title %}{{ recipe.title }}{% endblock %}
|
||||
{% block main %}
|
||||
<h1>{{ version.recipe.title }}{% if has_multiple_versions %} ({{ version.label }}){% endif %}</h1>
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ def add_recipe(request):
|
|||
version_form = VersionForm(prefix=VERSION_FORM_PREFIX, author_placeholder=get_name_of_user(request.user))
|
||||
ingredients_formset = IngredientFormSet(queryset=Ingredient.objects.none(), prefix=INGREDIENTS_FORMSET_PREFIX)
|
||||
|
||||
return render(request, 'add-recipe.html', {'recipe_form': recipe_form, 'version_form': version_form, 'ingredients_formset': ingredients_formset})
|
||||
return render(request, 'recipe-form.html', {'recipe_form': recipe_form, 'version_form': version_form, 'ingredients_formset': ingredients_formset})
|
||||
|
||||
@login_required
|
||||
def edit_recipe(request, slug):
|
||||
|
|
@ -135,7 +135,7 @@ def add_version(request, slug):
|
|||
version_form = VersionForm(prefix=VERSION_FORM_PREFIX, initial=version_initial, author_placeholder=get_name_of_user(request.user))
|
||||
ingredients_formset = IngredientFormSet(queryset=Ingredient.objects.none(), prefix=INGREDIENTS_FORMSET_PREFIX)
|
||||
|
||||
return render(request, 'add-version.html', {'version_form': version_form, 'ingredients_formset': ingredients_formset})
|
||||
return render(request, 'recipe-form.html', {'version_form': version_form, 'ingredients_formset': ingredients_formset})
|
||||
|
||||
@login_required
|
||||
def edit_version(request, slug_recipe, slug_version):
|
||||
|
|
@ -164,4 +164,4 @@ def edit_version(request, slug_recipe, slug_version):
|
|||
version_form = VersionForm(instance=version, prefix=VERSION_FORM_PREFIX, author_placeholder=get_name_of_user(request.user))
|
||||
ingredients_formset = IngredientFormSet(queryset=version.ingredients.all(), prefix=INGREDIENTS_FORMSET_PREFIX) # type: ignore
|
||||
|
||||
return render(request, 'edit-version.html', {'version_form': version_form, 'ingredients_formset': ingredients_formset})
|
||||
return render(request, 'recipe-form.html', {'version_form': version_form, 'ingredients_formset': ingredients_formset})
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{#
|
||||
{% comment %}
|
||||
Barn Web App - A collection of web-apps for my family's personal use,
|
||||
including a recipe database.
|
||||
Copyright © 2023 Benjamin Stadlbauer
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
This program comes with a copy of the GNU Affero General Public License
|
||||
file at the root of this project.
|
||||
#}
|
||||
{% endcomment %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{#
|
||||
{% extends "base.html" %}
|
||||
{% comment %}
|
||||
Barn Web App - A collection of web-apps for my family's personal use,
|
||||
including a recipe database.
|
||||
Copyright © 2023 Benjamin Stadlbauer
|
||||
|
|
@ -15,8 +16,7 @@
|
|||
|
||||
This program comes with a copy of the GNU Affero General Public License
|
||||
file at the root of this project.
|
||||
#}
|
||||
{% extends "base.html" %}
|
||||
{% endcomment %}
|
||||
|
||||
{% block head %}
|
||||
{% load static %}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{#
|
||||
{% extends "base_main.html" %}
|
||||
{% comment %}
|
||||
Barn Web App - A collection of web-apps for my family's personal use,
|
||||
including a recipe database.
|
||||
Copyright © 2023 Benjamin Stadlbauer
|
||||
|
|
@ -15,8 +16,7 @@
|
|||
|
||||
This program comes with a copy of the GNU Affero General Public License
|
||||
file at the root of this project.
|
||||
#}
|
||||
{% extends "base_main.html" %}
|
||||
{% endcomment %}
|
||||
{% block title %}Barn{% endblock %}
|
||||
{% block main %}
|
||||
<h1>Barn</h1>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{#
|
||||
{% extends "base_main.html" %}
|
||||
{% comment %}
|
||||
Barn Web App - A collection of web-apps for my family's personal use,
|
||||
including a recipe database.
|
||||
Copyright © 2023 Benjamin Stadlbauer
|
||||
|
|
@ -15,8 +16,7 @@
|
|||
|
||||
This program comes with a copy of the GNU Affero General Public License
|
||||
file at the root of this project.
|
||||
#}
|
||||
{% extends "base_main.html" %}
|
||||
{% endcomment %}
|
||||
|
||||
{% block main %}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{#
|
||||
{% extends "base_main.html" %}
|
||||
{% comment %}
|
||||
Barn Web App - A collection of web-apps for my family's personal use,
|
||||
including a recipe database.
|
||||
Copyright © 2023 Benjamin Stadlbauer
|
||||
|
|
@ -15,8 +16,7 @@
|
|||
|
||||
This program comes with a copy of the GNU Affero General Public License
|
||||
file at the root of this project.
|
||||
#}
|
||||
{% extends "base_main.html" %}
|
||||
{% endcomment %}
|
||||
|
||||
{% block main %}
|
||||
{% if form.errors %}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{#
|
||||
{% extends "base_main.html" %}
|
||||
{% comment %}
|
||||
Barn Web App - A collection of web-apps for my family's personal use,
|
||||
including a recipe database.
|
||||
Copyright © 2023 Benjamin Stadlbauer
|
||||
|
|
@ -15,8 +16,7 @@
|
|||
|
||||
This program comes with a copy of the GNU Affero General Public License
|
||||
file at the root of this project.
|
||||
#}
|
||||
{% extends "base_main.html" %}
|
||||
{% endcomment %}
|
||||
{% block title %}Profile {{ user.username }}{% endblock %}
|
||||
{% block main %}
|
||||
<h1>Profile {{ user.username }}</h1>
|
||||
|
|
|
|||
Loading…
Reference in a new issue