Split db::Connection implementation in submodules (db::user and db::recipe).

This commit is contained in:
Greg Burri 2024-12-18 23:10:19 +01:00
parent 4248d11aa9
commit fce4eade73
17 changed files with 1307 additions and 1234 deletions

View file

@ -7,14 +7,14 @@
{% block main_container %}
<nav class="recipes-list">
<ul>
{% for (id, title) in recipes %}
{% for (id, title) in recipes.list %}
<li>
{% match current_recipe_id %}
{% match recipes.current_id %}
{# Don't know how to avoid
repetition: comparing (using '==' or .eq()) current_recipe_id.unwrap() and id doesn't work.
repetition: comparing (using '==' or .eq()) recipes.current_recipe_id.unwrap() and id doesn't work.
Guards for match don't exist.
See: https://github.com/djc/askama/issues/752 #}
{% when Some (current_id) %}
{% when Some(current_id) %}
{% if current_id == id %}
{% call recipe_item(id, title, "recipe-item-current") %}
{% else %}

View file

@ -6,7 +6,7 @@
id="title_field"
type="text"
name="title"
value="{{ current_recipe.title }}"
value="{{ recipe.title }}"
autocapitalize="none"
autocomplete="title"
autofocus="autofocus" />
@ -16,7 +16,7 @@
id="title_field"
type="text"
name="title"
value="{{ current_recipe.description }}"
value="{{ recipe.description }}"
autocapitalize="none"
autocomplete="title"
autofocus="autofocus" />

View file

@ -0,0 +1,18 @@
{% extends "base_with_list.html" %}
{% block content %}
<h2 class="recipe-title" >{{ recipe.title }}</h2>
{% if user.is_some() && recipe.user_id == user.as_ref().unwrap().id %}
<a class="edit-recipe" href="/recipe/edit/{{ recipe.id }}" >Edit</a>
{% endif %}
{% if !recipe.description.is_empty() %}
<div class="recipe-description" >
{{ recipe.description.clone()|markdown }}
</div>
{% endif %}
{% endblock %}

View file

@ -12,10 +12,10 @@
{{ message_email }}
<label for="input-password-1">Choose a password (minimum 8 characters)</label>
<input id="input-password-1" type="password" name="password_1" />
<input id="input-password-1" type="password" name="password_1" autocomplete="new-password" />
<label for="input-password-2">Re-enter password</label>
<input id="input-password-2" type="password" name="password_2" />
<input id="input-password-2" type="password" name="password_2" autocomplete="new-password" />
{{ message_password }}

View file

@ -1,18 +0,0 @@
{% extends "base_with_list.html" %}
{% block content %}
<h2 class="recipe-title" >{{ current_recipe.title }}</h2>
{% if user.is_some() && current_recipe.user_id == user.as_ref().unwrap().id %}
<a class="edit-recipe" href="/recipe/edit/{{ current_recipe.id }}" >Edit</a>
{% endif %}
{% if !current_recipe.description.is_empty() %}
<div class="recipe-description" >
{{ current_recipe.description.clone()|markdown }}
</div>
{% endif %}
{% endblock %}