For Private page, add feature 'take note'
This makes this app much more meaningful. For this feature, a new database table is added. More complicated logics are also needed, for example, we use hash(user ID + timestamp + note contant) as the unique id of each note (it's necessary when we try to delete a note)
This commit is contained in:
@@ -5,16 +5,18 @@
|
||||
|
||||
{# only invoked when failed adding new ID due to duplication #}
|
||||
{% if id_to_add_is_duplicated %}
|
||||
<div class="text-danger">
|
||||
<strong>Warning!</strong> The account name already exists.
|
||||
</div>
|
||||
<div class="alert alert-dismissible alert-danger">
|
||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||
<strong>Warning!</strong> The account name already exists.
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{# only invoked when failed adding new ID due to invalid character #}
|
||||
{% if id_to_add_is_invalid %}
|
||||
<div class="text-danger">
|
||||
<strong>Warning!</strong> The account name is invalid.
|
||||
</div>
|
||||
<div class="alert alert-dismissible alert-danger">
|
||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||
<strong>Warning!</strong> The account name is invalid.
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class = "container">
|
||||
@@ -63,10 +65,4 @@
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
6
templates/page_403.html
Normal file
6
templates/page_403.html
Normal file
@@ -0,0 +1,6 @@
|
||||
{% extends "layout.html" %}
|
||||
{% block page_title %}Forbidden(403){% endblock %}
|
||||
{% block body %}
|
||||
{{ super() }}
|
||||
This operation is forbidden.
|
||||
{% endblock %}
|
||||
@@ -2,6 +2,44 @@
|
||||
{% block page_title %}Private Page{% endblock %}
|
||||
{% block body %}
|
||||
{{ super() }}
|
||||
<img src="{{ url_for('static', filename='img/private.jpg') }}" class="img-circle" alt="Cinque Terre" width="304" height="236">
|
||||
Only logged-in users, like you, can access this page.
|
||||
|
||||
<h4>You can take notes here. Only yourself can access them. They will be removed when your account is removed.</h4>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="textArea" class="col-lg-3 control-label">Note to Take</label>
|
||||
<div class="col-lg-9">
|
||||
<form action="/write_note" method="post">
|
||||
<input class="form-control" name="text_note_to_take"></input>
|
||||
<button type="submit" class="btn btn-success">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
{% if notes %}
|
||||
<h2>Your Notes</h2>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Note ID</th>
|
||||
<th>Timestamp</th>
|
||||
<th>Note</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% for note_id, timestamp, note, act in notes %}
|
||||
<tr>
|
||||
<td> {{ note_id }} </td>
|
||||
<td> {{ timestamp }} </td>
|
||||
<td> {{ note }} </td>
|
||||
<td><a href={{act}}>Delete</a></td>
|
||||
</tr>
|
||||
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user