init
This commit is contained in:
27
templates/base.html
Normal file
27
templates/base.html
Normal file
@@ -0,0 +1,27 @@
|
||||
<!doctype html>
|
||||
<html lang="pl">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{% block title %}Książka adresowa{% endblock %}</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1><a href="{{ url_for('index') }}">Książka adresowa</a></h1>
|
||||
<nav>
|
||||
<a class="btn primary" href="{{ url_for('new') }}">+ Dodaj kontakt</a>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
{% if error %}
|
||||
<div class="alert">{{ error }}</div>
|
||||
{% endif %}
|
||||
|
||||
<main>
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
|
||||
<footer>WMT - CRUD - Flask - SQLAlchemy ORM - SQLite</footer>
|
||||
</body>
|
||||
</html>
|
||||
26
templates/form.html
Normal file
26
templates/form.html
Normal file
@@ -0,0 +1,26 @@
|
||||
{% extends 'base.html' %}
|
||||
{% block title %}{{ 'Edycja' if contact and (contact.id if contact is not mapping else contact.get('id')) else 'Nowy' }} kontakt{% endblock %}
|
||||
{% block content %}
|
||||
{% set cid = (contact.id if contact and contact is not mapping else (contact.get('id') if contact else None)) %}
|
||||
<form method="post" action="{{ url_for('update' if cid else 'create') }}">
|
||||
{% if cid %}
|
||||
<input type="hidden" name="id" value="{{ cid }}">
|
||||
{% endif %}
|
||||
<div class="row">
|
||||
<label>Imię i nazwisko</label>
|
||||
<input type="text" name="name" value="{{ (contact.name if contact and contact is not mapping else (contact['name'] if contact else ''))|e }}" required>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>Email</label>
|
||||
<input type="email" name="email" value="{{ (contact.email if contact and contact is not mapping else (contact['email'] if contact else ''))|e }}">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>Telefon</label>
|
||||
<input type="text" name="phone" value="{{ (contact.phone if contact and contact is not mapping else (contact['phone'] if contact else ''))|e }}">
|
||||
</div>
|
||||
<p>
|
||||
<button class="btn primary" type="submit">Zapisz</button>
|
||||
<a class="btn" href="{{ url_for('index') }}">Anuluj</a>
|
||||
</p>
|
||||
</form>
|
||||
{% endblock %}
|
||||
26
templates/index.html
Normal file
26
templates/index.html
Normal file
@@ -0,0 +1,26 @@
|
||||
{% extends 'base.html' %}
|
||||
{% block title %}Lista kontaktów{% endblock %}
|
||||
{% block content %}
|
||||
<table>
|
||||
<tr><th>ID</th><th>Imię i nazwisko</th><th>Email</th><th>Telefon</th><th>Akcje</th></tr>
|
||||
{% if contacts %}
|
||||
{% for c in contacts %}
|
||||
<tr>
|
||||
<td>{{ c.id }}</td>
|
||||
<td>{{ c.name }}</td>
|
||||
<td>{{ c.email or '' }}</td>
|
||||
<td>{{ c.phone or '' }}</td>
|
||||
<td class="actions">
|
||||
<a class="btn" href="{{ url_for('edit', cid=c.id) }}">Edytuj</a>
|
||||
<form method="post" action="{{ url_for('delete') }}" onsubmit="return confirm('Usunąć?');">
|
||||
<input type="hidden" name="id" value="{{ c.id }}">
|
||||
<button class="btn warn" type="submit">Usuń</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<tr><td colspan="5"><i>Brak adresów</i></td></tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user