Removed uuid and added item_uuid to table schema
This commit is contained in:
parent
a5bb593f6d
commit
41e6cb9d05
Binary file not shown.
Binary file not shown.
@ -110,8 +110,10 @@ def login():
|
||||
|
||||
if 'user' not in session.keys():
|
||||
session['user'] = None
|
||||
|
||||
print(instance_config)
|
||||
|
||||
return render_template("login.html", sign_up_enabled=instance_config['signup_enabled'])
|
||||
return render_template("login.html", instance_settings=instance_config)
|
||||
|
||||
@access_api.route('/dashboard')
|
||||
def dashboard():
|
||||
|
||||
@ -30,12 +30,13 @@
|
||||
<img class="uk-align-center" src="{{ url_for('static', filename='pictures/logo.jpg') }}" style="width: 200px; border-radius: 50%;">
|
||||
<ul uk-tab>
|
||||
<li><a href="#">Login</a></li>
|
||||
{% if signup_enabled %}
|
||||
{% if instance_settings['signup_enabled'] %}
|
||||
<li><a href="#">Sign Up</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
<div class="uk-switcher">
|
||||
<div class="uk-grid-small" uk-grid>
|
||||
{% if instance_settings['internal_login_enabled'] %}
|
||||
<div class="uk-width-1-1">
|
||||
<div class="uk-margin">
|
||||
<label class="uk-form-label" for="login_username">Username</label>
|
||||
@ -56,11 +57,16 @@
|
||||
<a onclick="loginUser()" class="uk-button uk-button-primary uk-align-center">Login</a>
|
||||
</div>
|
||||
<p class="uk-text-meta uk-align-center uk-margin-remove-bottom">OR</p>
|
||||
{% else %}
|
||||
<p class="uk-text-meta uk-align-center">This instance only allows external logins through their configured authenticator. If you need to use your interal
|
||||
login you will need to contact your system admin.
|
||||
</p>
|
||||
{% endif %}
|
||||
<div class="uk-width-1-1">
|
||||
<a href="/access/login/oidc" class="uk-button uk-button-primary uk-align-center">Login with Authentik</a>
|
||||
</div>
|
||||
</div>
|
||||
{% if signup_enabled %}
|
||||
{% if instance_settings['signup_enabled'] %}
|
||||
<!-- Sign up Form -->
|
||||
<div class="uk-grid-small" uk-grid>
|
||||
<div class="uk-width-1-1">
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
CREATE TABLE IF NOT EXISTS %%site_name%%_recipe_items (
|
||||
id SERIAL PRIMARY KEY,
|
||||
uuid VARCHAR(32) NOT NULL,
|
||||
item_uuid UUID,
|
||||
rp_id INTEGER NOT NULL,
|
||||
item_type VARCHAR(32) NOT NULL,
|
||||
item_name TEXT NOT NULL,
|
||||
@ -8,7 +8,6 @@ CREATE TABLE IF NOT EXISTS %%site_name%%_recipe_items (
|
||||
qty FLOAT8 NOT NULL,
|
||||
item_id INTEGER DEFAULT NULL,
|
||||
links JSONB DEFAULT '{"main": ""}',
|
||||
UNIQUE(uuid),
|
||||
CONSTRAINT fk_rp_id
|
||||
FOREIGN KEY(rp_id)
|
||||
REFERENCES %%site_name%%_recipes(id)
|
||||
|
||||
Binary file not shown.
@ -177,7 +177,7 @@ def deleteRecipeItem():
|
||||
return jsonify({'recipe': recipe, 'error': False, 'message': f'Recipe Item {deleted_item['item_name']} was deleted successful!'})
|
||||
return jsonify({'recipe': recipe, 'error': True, 'message': f'method {request.method} is not allowed!'})
|
||||
|
||||
@recipes_api.route('/saveRecipeItem', methods=["POST"])
|
||||
@recipes_api.route('/api/saveRecipeItem', methods=["POST"])
|
||||
@access_api.login_required
|
||||
def saveRecipeItem():
|
||||
recipe = {}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
INSERT INTO %%site_name%%_recipe_items
|
||||
(uuid, rp_id, item_type, item_name, uom, qty, item_id, links)
|
||||
(item_uuid, rp_id, item_type, item_name, uom, qty, item_id, links)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s)
|
||||
RETURNING *;
|
||||
@ -148,7 +148,7 @@ async function saveLineItem(item){
|
||||
uom: document.getElementById('lineUOM').value,
|
||||
links: item.links
|
||||
}
|
||||
const response = await fetch(`/recipe/saveRecipeItem`, {
|
||||
const response = await fetch(`/recipes/api/saveRecipeItem`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
@ -31,7 +31,6 @@ def sites_config(filename='database.ini', section='manage'):
|
||||
first_setup = False
|
||||
if parser.has_section(section):
|
||||
params = parser.items(section)
|
||||
print(params)
|
||||
for param in params:
|
||||
instance_config[param[0]] = param[1].split(',')
|
||||
else:
|
||||
@ -39,9 +38,8 @@ def sites_config(filename='database.ini', section='manage'):
|
||||
|
||||
instance_config['first_setup'] = parser.getboolean('manage', 'first_setup')
|
||||
instance_config['signup_enabled'] = parser.getboolean('manage', 'signup_enabled')
|
||||
instance_config['internal_login_enabled'] = parser.getboolean('manage', 'internal_login_enabled')
|
||||
|
||||
|
||||
print(instance_config)
|
||||
return instance_config
|
||||
|
||||
def setFirstSetupDone():
|
||||
|
||||
@ -9,4 +9,5 @@ port = 5432
|
||||
sites =
|
||||
first_setup = False
|
||||
signup_enabled = False
|
||||
internal_login_enabled = True
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user