Can now edit species from species_info page, can now update photo from species_editor, extinction category now pre-fills in species_editor
This commit is contained in:
1 parent
2952373e8e
commit
c518a03df5
5 files changed
+28
-32
No files matched your search
@@ -4,15 +4,13 @@ import sqlite3
|
||||
|
||||
page = Blueprint("species_information", __name__)
|
||||
|
||||
# this page works by taking the "species_id" from the url and using that to
|
||||
# read the database.
|
||||
# Because of this we are able to create one page and simply generate links
|
||||
# based on the contents of the database
|
||||
# this page works by taking the species name (in english) from the url and using that to read the database.
|
||||
# Because of this we are able to create one page and simply generate links based on the contents of the database
|
||||
# i.e. we can create a button with the hyperlink /species/iguana and this will
|
||||
# allow the user to view the information about the species
|
||||
# please be aware the page expects a .jpg at:
|
||||
# /static/images/species_database/{{species_id}}.jpg but this will be generated automatically
|
||||
# so long as you use the 'species_portal' page I created - CS
|
||||
# /static/images/species_database/{{photoid}}.jpg but this will be generated automatically
|
||||
# so long as you use the species_portal or species editor pages I created - CS
|
||||
|
||||
|
||||
@page.route("/species/<species_english>")
|
||||
@@ -29,7 +27,7 @@ def data(species_english):
|
||||
category =database_entry["category"].capitalize(),
|
||||
extinction_risk =database_entry["extinction_risk"],
|
||||
photoid =database_entry["photoid"],
|
||||
species_id =database_entry["species_id"]
|
||||
species_id =str(database_entry["species_id"])
|
||||
)
|
||||
except TypeError as error_information:
|
||||
return render_template(
|
||||
|
||||
@@ -30,15 +30,11 @@ def species_update(species_id):
|
||||
|
||||
if species_image and species_image.filename:
|
||||
image_id = str(uuid.uuid4())
|
||||
species_image.save(
|
||||
f"static/images/species_database/{image_id}.jpg"
|
||||
)
|
||||
species_image.save(f"static/images/species_database/{image_id}.jpg")
|
||||
|
||||
update_species(species_id, eng_name, latin_name, main_text, category, extinction_risk)
|
||||
|
||||
return redirect(
|
||||
url_for("species_editor.edit_success", eng_name=eng_name)
|
||||
)
|
||||
return redirect(url_for("species_information.data", species_english=eng_name))
|
||||
|
||||
except Exception as error_information:
|
||||
return render_template(
|
||||
|
||||
+1
-1
@@ -605,7 +605,7 @@ input:focus {
|
||||
width: 100%;
|
||||
max-width: 600px;
|
||||
background: var(--green3);
|
||||
padding: 40px;
|
||||
padding: 20px;
|
||||
border-radius: 20px;
|
||||
border: 2px solid var(--primary);
|
||||
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
<p></p>
|
||||
{% endif %}
|
||||
</section>
|
||||
<section id="hero" style="padding: 1px; text-align: center;" class="container">
|
||||
{# this button should only be visible to certain account types #}
|
||||
<a href="/species/editor/{{species_id}}">Edit Species</a>
|
||||
</section>
|
||||
{{ button(url='/species/editor/'+species_id, button_text='Edit Species') }}
|
||||
{% endblock %}
|
||||
@@ -5,7 +5,6 @@
|
||||
{% block content %}
|
||||
{% from 'button.jinja' import button %}
|
||||
<h1>SPECIES EDITOR</h1>
|
||||
<p>Species ID: {{ species_id }}</p>
|
||||
<section id="hero" class="form">
|
||||
<form action="{{ url_for('species_editor.species_update', species_id=species_id) }}" class="container" method="POST"
|
||||
enctype="multipart/form-data">
|
||||
@@ -21,34 +20,39 @@
|
||||
<label for="main_text">Species Information:</label>
|
||||
<textarea id="main_text" name="main_text" rows="5" required>{{ sp['body_text'] }}</textarea>
|
||||
</div>
|
||||
{# <div class="form-group">
|
||||
<div class="form-group">
|
||||
<label for="species_image">Species Image:</label>
|
||||
<input type="file" id="species_image" name="species_image" accept="image/*">
|
||||
</div> #}
|
||||
{# temporarily removed as i can't figure it out rn #}
|
||||
{# probably need to check if the value in the db is greater than the supplied value or something, don't wanna overwrite existing entry eith nothing #}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="category">Category (e.g. Reptile):</label>
|
||||
<textarea id="category" name="category" required>{{ sp['category'] }}</textarea>
|
||||
</div>
|
||||
{# can't figure out how to get this last one to pre-fill with the existing value, need to fix #}
|
||||
<div class="form-group">
|
||||
<label for="extinction_risk"> Extinction risk: </label>
|
||||
<select id="extinction_risk" name="extinction_risk">
|
||||
<option value="Not Evaluated" > Not Evaluated </option>
|
||||
<option value="Least Concern" > Least Concern </option>
|
||||
<option value="Near Threatened" > Near Threatened </option>
|
||||
<option value="Vulnerable" > Vulnerable </option>
|
||||
<option value="Endangered" > Endangered </option>
|
||||
<option value="Critically Endangered" > Critically Endangered </option>
|
||||
<option value="Extinct in Wild" > Extinct in Wild </option>
|
||||
<option value="Extinct" > Extinct </option>
|
||||
{%for option in [
|
||||
"Not Evaluated",
|
||||
"Least Concern",
|
||||
"Near Threatened",
|
||||
"Vulnerable",
|
||||
"Endangered",
|
||||
"Critically Endangered",
|
||||
"Extinct in Wild",
|
||||
"Extinct"]%}
|
||||
<option value='{{ option }}'{% if option == sp['extinction_risk'] %}
|
||||
selected='selected'
|
||||
{%endif%}
|
||||
>{{option}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit" class="submit-button">
|
||||
Add Species
|
||||
Update Species Information
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
</section>
|
||||
<img src="/images/species_database/{{ sp['photoid'] }}.jpg" style="width: 10%;">
|
||||
{% endblock %}
|
||||
Reference in new issue
Block a user