From 4ebe8e317e961779ec747ac7fed222e429005c09 Mon Sep 17 00:00:00 2001 From: Jose Rafael Ferrer-Paris Date: Tue, 20 Jun 2023 15:46:23 +1000 Subject: [PATCH 1/8] Adding some info and checks for the presentation --- Instructions-flask.md | 1 + requirements.txt | 89 ++++++----------------- webapp/sites.py | 2 +- webapp/species.py | 5 +- webapp/templates/sites/survey_list.html | 12 +-- webapp/templates/species/threat-list.html | 6 ++ 6 files changed, 42 insertions(+), 73 deletions(-) diff --git a/Instructions-flask.md b/Instructions-flask.md index 65cc2bd..0e1e6f5 100644 --- a/Instructions-flask.md +++ b/Instructions-flask.md @@ -18,6 +18,7 @@ or with venv... in our local machine ```sh python3 -m venv ~/proyectos/flsk +# or python3 -m venv ~/venv/flsk source ~/proyectos/flsk/bin/activate ## or source ~/proyectos/venv/flsk/bin/activate diff --git a/requirements.txt b/requirements.txt index 4b734eb..449d6b1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,70 +1,27 @@ -alembic==1.7.6 -aniso8601==9.0.1 -attrs==21.4.0 -branca==0.4.2 -certifi==2021.10.8 -charset-normalizer==2.0.12 -click==8.0.3 -dnspython==2.2.0 -email-validator==1.1.3 +blinker==1.6.2 +branca==0.6.0 +certifi==2023.5.7 +charset-normalizer==3.1.0 +click==8.1.3 +DateTime==5.1 et-xmlfile==1.1.0 -Flask==2.1.2 -Flask-Login==0.5.0 -Flask-Migrate==3.1.0 -flask-restx==0.5.1 -Flask-SQLAlchemy==2.5.1 -Flask-WTF==1.0.0 -folium==0.12.1.post1 -GDAL==3.5.0 -greenlet==1.1.2 -gunicorn==20.1.0 -idna==3.3 -importlib-metadata==4.12.0 -itsdangerous==2.0.1 -Jinja2==3.0.3 -jsonschema==4.4.0 -Mako==1.1.6 -MarkupSafe==2.0.1 -numpy==1.23.0 -openpyxl==3.0.9 -# packaging @ file:///private/tmp/sip--packaging-20220416-83003-1hqovwb/packaging-21.3 -pandas==1.4.1 -Pillow==9.1.1 -ply==3.11 -postgis==1.0.4 -protobuf==3.19.4 -psycopg-postgis==0.4.0 -psycopg2==2.9.3 -psycopg2-binary==2.9.3 -pybind11==2.9.2 -pycairo==1.21.0 -pycountry==22.3.5 -PyGObject==3.42.1 -PyQt6==6.2.0 -PyQt6-3D==6.2.0 -PyQt6-Charts==6.2.0 -PyQt6-DataVisualization==6.2.0 -PyQt6-NetworkAuth==6.2.0 -PyQt6-sip==13.1.0 -PyQt6-WebEngine==6.2.0 -pyrsistent==0.18.1 -PySide6==6.2.4 +Flask==2.3.2 +Flask-WTF==1.1.1 +folium==0.14.0 +idna==3.4 +itsdangerous==2.1.2 +Jinja2==3.1.2 +MarkupSafe==2.1.3 +numpy==1.25.0 +openpyxl==3.1.2 +pandas==2.0.2 +psycopg2-binary==2.9.6 python-dateutil==2.8.2 -python-decouple==3.5 -python-dotenv==0.19.2 -pytz==2021.3 -reportlab==3.6.10 -requests==2.27.1 -scipy==1.8.1 -shiboken6==6.2.4 -shiboken6-generator==6.2.4 -sip==6.6.1 +pytz==2023.3 +requests==2.31.0 six==1.16.0 -SQLAlchemy==1.4.29 -TBB==0.2 -toml==0.10.2 -urllib3==1.26.8 -Werkzeug==2.0.2 +tzdata==2023.3 +urllib3==2.0.3 +Werkzeug==2.3.6 WTForms==3.0.1 -wxPython==4.1.1 -zipp==3.8.0 +zope.interface==6.0 diff --git a/webapp/sites.py b/webapp/sites.py index e99663c..415da60 100644 --- a/webapp/sites.py +++ b/webapp/sites.py @@ -18,7 +18,7 @@ def survey_list(): pg = get_pg_connection() cur = pg.cursor() - cur.execute('SELECT survey_name,count(distinct visit_id), count(*),min(visit_date),max(visit_date) FROM form.field_visit GROUP BY survey_name;') + cur.execute('SELECT survey_name,survey_description,count(distinct visit_id), count(*),min(visit_date),max(visit_date) FROM form.field_visit LEFT JOIN form.surveys USING (survey_name) GROUP BY survey_name, survey_description;') survey_list = cur.fetchall() cur.close() return render_template('sites/survey_list.html', pairs=survey_list, the_title="List of surveys") diff --git a/webapp/species.py b/webapp/species.py index 1272eef..7c74293 100644 --- a/webapp/species.py +++ b/webapp/species.py @@ -55,8 +55,11 @@ def threat_list(): cur.execute(create_spp_trait_table) cur.execute('SELECT \"stateConservation\" AS fam,count(distinct "speciesID"), count(distinct s.species_code), count(distinct q.species_code) FROM species.caps LEFT JOIN species_traits s ON "speciesCode_Synonym"=s.species_code::text LEFT JOIN form.quadrat_samples q ON "speciesCode_Synonym"=q.species_code::text GROUP BY fam;') fam_list = cur.fetchall() + cur.execute('SELECT count(distinct "speciesID"), count(distinct s.species_code), count(distinct q.species_code) FROM species.caps LEFT JOIN species_traits s ON "speciesCode_Synonym"=s.species_code::text LEFT JOIN form.quadrat_samples q ON "speciesCode_Synonym"=q.species_code::text;') + fam_total = cur.fetchall() cur.close() - return render_template('species/threat-list.html', pairs=fam_list, the_title="Species per family") + + return render_template('species/threat-list.html', pairs=fam_list, ttl=fam_total, the_title="Species per family") @bp.route('/family/', methods=['GET', 'POST']) @login_required diff --git a/webapp/templates/sites/survey_list.html b/webapp/templates/sites/survey_list.html index 7fc58e8..7c1dce6 100644 --- a/webapp/templates/sites/survey_list.html +++ b/webapp/templates/sites/survey_list.html @@ -9,6 +9,7 @@

{% block title %}List of field surveys{% endblock %}

+ @@ -17,17 +18,18 @@

{% block title %}List of field surveys{% endblock %}

{% if pair[0] == 'TO BE CLASSIFIED' %} - + {% else %} + {% endif %} - - - + + + - + {% endfor %}
Survey nameSurvey description Nr. of distinct sites Nr. of distinct visits Dates
Not assigned to surveyNot assigned to survey{{ pair[0] }} {{ pair[1] }}{{ pair[1] }}Map {{ pair[2] }}Map {{ pair[3] }} List {{ pair[3] }} - {{ pair[4] }}{{ pair[4] }} - {{ pair[5] }}
diff --git a/webapp/templates/species/threat-list.html b/webapp/templates/species/threat-list.html index 796abf3..ae2d6d4 100644 --- a/webapp/templates/species/threat-list.html +++ b/webapp/templates/species/threat-list.html @@ -32,6 +32,12 @@

{% block title %}List of species{% endblock %}

{% endif %} {% endfor %} + + Totals + {{ttl[0][0]}} + {{ttl[0][1]}} + {{ttl[0][2]}} + {% endblock %} From a8614f1d12955ac18379c5d65d42c6e3febf8b0a Mon Sep 17 00:00:00 2001 From: Jose Rafael Ferrer-Paris Date: Wed, 21 Jun 2023 10:20:03 +1000 Subject: [PATCH 2/8] Check information about species link to external sources --- webapp/species.py | 2 ++ webapp/templates/visits/list.html | 8 ++++++++ webapp/visits.py | 9 +++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/webapp/species.py b/webapp/species.py index 7c74293..0a72b5a 100644 --- a/webapp/species.py +++ b/webapp/species.py @@ -202,3 +202,5 @@ def sp_info(id): return render_template('species/info.html', info=spp_info, fsamp=samples, traits=traits, mainrefs=ref_list, addrefs=add_list, check=synonym, vag=vag_info) else: return redirect(url_for('.search_list', id=request.form['speciesname'])) + +## use TSProfileID to link to https://www.environment.nsw.gov.au/threatenedspeciesapp/profile.aspx?id= \ No newline at end of file diff --git a/webapp/templates/visits/list.html b/webapp/templates/visits/list.html index 9484a9b..fdd7cf3 100644 --- a/webapp/templates/visits/list.html +++ b/webapp/templates/visits/list.html @@ -26,6 +26,14 @@

{% block title %} {% endif %} + {% if ttl == None %} +

+ No survey has been selected, so this list shows all sites. If you want to narrow down the list, go to the list of surveys. +

+ {% else %} +

This survey includes {{ttl[0]}} sites, {{ttl[1]}} visits, {{ttl[2]}} subplots, {{ttl[3]}} species and {{ttl[4]}} main observers.

+ {% endif %} +

Sites are identified by a site label. One site can be visited multiple times. Click any site's label to see more information about site description and coordinates. Click on the visit's date to see more information regarding the visit event.

diff --git a/webapp/visits.py b/webapp/visits.py index ada39eb..f45f648 100644 --- a/webapp/visits.py +++ b/webapp/visits.py @@ -24,16 +24,21 @@ def visits_list(survey): qry="SELECT * FROM form.surveys where survey_name=%s" cur.execute(qry,(survey,)) survinfo=cur.fetchone() - + + qry='SELECT count(distinct visit_id) as nlocs, count(distinct concat(visit_id,visit_date)) as nvisits, count(distinct CONCAT(visit_date, sample_nr)) as nsamples, count(distinct species_code) as nspp, count(distinct CONCAT(givennames,\' \',surname)) as main_observers FROM form.field_visit v LEFT JOIN form.field_samples s USING(visit_id,visit_date) LEFT JOIN form.quadrat_samples q USING (visit_id,visit_date,sample_nr) LEFT JOIN form.observerid ON mainobserver=userkey WHERE survey_name=%s ;' + cur.execute(qry, (survey,)) + visit_total=cur.fetchone() + qry='SELECT visit_id,visit_date,count(distinct sample_nr),count(distinct species_code),survey_name,CONCAT(givennames,\' \',surname) as main_observer, vegetation_formation, vegetation_class FROM form.field_visit v LEFT JOIN form.field_samples s USING(visit_id,visit_date) LEFT JOIN form.quadrat_samples q USING (visit_id,visit_date,sample_nr) LEFT JOIN form.observerid ON mainobserver=userkey LEFT JOIN form.field_visit_veg_description USING(visit_id,visit_date) WHERE survey_name=%s GROUP BY survey_name,visit_id,visit_date, givennames, surname, vegetation_formation, vegetation_class ORDER BY survey_name,visit_id;' cur.execute(qry, (survey,)) + visit_list = cur.fetchall() cur.close() if survey == None: return render_template('visits/list.html', visits=visit_list, survey=survey) else: - return render_template('visits/list.html', visits=visit_list, survey=survinfo) + return render_template('visits/list.html', visits=visit_list, survey=survinfo, ttl=visit_total) @bp.route('//
') @login_required From cbd7e91d36dcfd2b91b5e6d4defbdd9ba250bd9f Mon Sep 17 00:00:00 2001 From: jrfep Date: Thu, 22 Jun 2023 15:38:04 +1000 Subject: [PATCH 3/8] include images from iNaturalist --- Instructions-flask.md | 3 +++ webapp/species.py | 19 ++++++++++++++++++- webapp/templates/species/info.html | 18 +++++++++++++++++- webapp/xlinit.py | 5 +++-- 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/Instructions-flask.md b/Instructions-flask.md index 65cc2bd..388bf7c 100644 --- a/Instructions-flask.md +++ b/Instructions-flask.md @@ -45,6 +45,9 @@ pip install folium pip install pandas pip install datetime pip install openpyxl +pip install pillow ipyplot +pip install pyinaturalist +pip install pickle5 ``` diff --git a/webapp/species.py b/webapp/species.py index 1272eef..26814f8 100644 --- a/webapp/species.py +++ b/webapp/species.py @@ -10,6 +10,17 @@ from psycopg2.extras import DictCursor import pandas as pd + +from datetime import datetime, timedelta +import ipyplot +from dateutil.relativedelta import relativedelta +from pyinaturalist import ( + Observation, + get_observations, + pprint, +) +from rich import print + bp = Blueprint('species', __name__, url_prefix='/species') create_spp_trait_table=""" CREATE TEMP TABLE species_traits (species_code,trait_codes) AS ( @@ -196,6 +207,12 @@ def sp_info(id): vag_info = cur.fetchone() cur.close() - return render_template('species/info.html', info=spp_info, fsamp=samples, traits=traits, mainrefs=ref_list, addrefs=add_list, check=synonym, vag=vag_info) + + raw_obs = get_observations(taxon_name=spp_info[0], per_page=1) + iNobs = Observation.from_json_list(raw_obs) + #images = [obs.photos[0].small_url for obs in iNobs[:3]] + #labels = [str(obs) for obs in iNobs[:3]] + + return render_template('species/info.html', info=spp_info, inat_obs=iNobs, fsamp=samples, traits=traits, mainrefs=ref_list, addrefs=add_list, check=synonym, vag=vag_info) else: return redirect(url_for('.search_list', id=request.form['speciesname'])) diff --git a/webapp/templates/species/info.html b/webapp/templates/species/info.html index 39c4e35..af88533 100644 --- a/webapp/templates/species/info.html +++ b/webapp/templates/species/info.html @@ -23,7 +23,7 @@

{% block title %}{{ info[0] }}{% endblock %}

{% block content %} Check: {{check}} -
+

Species information

(from BioNET export)

@@ -83,8 +83,21 @@

(from BioNET export)

{% endif %}
+ +
+{% for obs in inat_obs %} + + {{ obs.place_guess }} +

+ {{ obs.place_guess }}
+ {{ obs.observed_on }}
+ By: {{ obs.user.name }} @ iNaturalist +

+ +{% endfor %}
+

Click tab to display information on:

@@ -354,4 +367,7 @@

Additional references

{%endif%} + + + {% endblock %} diff --git a/webapp/xlinit.py b/webapp/xlinit.py index 1c3f51a..837d0ff 100644 --- a/webapp/xlinit.py +++ b/webapp/xlinit.py @@ -11,8 +11,9 @@ from webapp.pg import get_pg_connection from psycopg2.extras import DictCursor -import pickle - +# https://stackoverflow.com/questions/63329657/python-3-7-error-unsupported-pickle-protocol-5 +#import pickle +import pickle5 as pickle ## First, load SQL queries with open('webapp/content/sql_queries.pik', 'rb') as f: From 2097da553e2a3a0fb5067aea067e1a93972c64fc Mon Sep 17 00:00:00 2001 From: jrfep Date: Thu, 22 Jun 2023 15:50:52 +1000 Subject: [PATCH 4/8] add link to conservation profile NSW --- webapp/species.py | 2 +- webapp/templates/species/info.html | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/webapp/species.py b/webapp/species.py index 26814f8..8cf8326 100644 --- a/webapp/species.py +++ b/webapp/species.py @@ -141,7 +141,7 @@ def sp_info(id): column="speciesCode_Synonym" else: column="speciesID" - qryspp=f"SELECT \"scientificName\", \"speciesID\"::int, family, \"taxonRank\", family, \"speciesCode_Synonym\", \"scientificNameAuthorship\", \"vernacularName\", \"establishmentMeans\", \"primaryGrowthFormGroup\", \"secondaryGrowthFormGroups\", \"stateConservation\", \"protectedInNSW\", \"countryConservation\" from species.caps WHERE \"{column}\"=%s" + qryspp=f"SELECT \"scientificName\", \"speciesID\"::int, family, \"taxonRank\", family, \"speciesCode_Synonym\", \"scientificNameAuthorship\", \"vernacularName\", \"establishmentMeans\", \"primaryGrowthFormGroup\", \"secondaryGrowthFormGroups\", \"stateConservation\", \"protectedInNSW\", \"countryConservation\", \"TSProfileID\" from species.caps WHERE \"{column}\"=%s" cur.execute(qryspp, (id,)) try: diff --git a/webapp/templates/species/info.html b/webapp/templates/species/info.html index af88533..573851b 100644 --- a/webapp/templates/species/info.html +++ b/webapp/templates/species/info.html @@ -57,7 +57,14 @@

(from BioNET export)

{% if info[11] == None %} No value recorded. {% else %} - {{ info[11] }} + + {% if info[14] %} + {{ info[11] }} + {% else %} + {{ info[11] }} + + {% endif %} + {% endif %} From 4ac96af92e779fd2ec8b2b140dd270dbe03fb182 Mon Sep 17 00:00:00 2001 From: Jose Rafael Ferrer-Paris Date: Fri, 23 Jun 2023 09:29:19 +1000 Subject: [PATCH 5/8] Back to pickle --- webapp/xlinit.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/xlinit.py b/webapp/xlinit.py index 837d0ff..262bc6f 100644 --- a/webapp/xlinit.py +++ b/webapp/xlinit.py @@ -12,8 +12,8 @@ from psycopg2.extras import DictCursor # https://stackoverflow.com/questions/63329657/python-3-7-error-unsupported-pickle-protocol-5 -#import pickle -import pickle5 as pickle +import pickle +#import pickle5 as pickle ## First, load SQL queries with open('webapp/content/sql_queries.pik', 'rb') as f: From a60f461b560b4d0502785a53f631b9c94077a018 Mon Sep 17 00:00:00 2001 From: Jose Rafael Ferrer-Paris Date: Tue, 20 Jun 2023 15:46:23 +1000 Subject: [PATCH 6/8] Adding some info and checks for the presentation --- Instructions-flask.md | 1 + requirements.txt | 89 ++++++----------------- webapp/sites.py | 2 +- webapp/species.py | 5 +- webapp/templates/sites/survey_list.html | 12 +-- webapp/templates/species/threat-list.html | 6 ++ 6 files changed, 42 insertions(+), 73 deletions(-) diff --git a/Instructions-flask.md b/Instructions-flask.md index 388bf7c..2be167a 100644 --- a/Instructions-flask.md +++ b/Instructions-flask.md @@ -18,6 +18,7 @@ or with venv... in our local machine ```sh python3 -m venv ~/proyectos/flsk +# or python3 -m venv ~/venv/flsk source ~/proyectos/flsk/bin/activate ## or source ~/proyectos/venv/flsk/bin/activate diff --git a/requirements.txt b/requirements.txt index 4b734eb..449d6b1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,70 +1,27 @@ -alembic==1.7.6 -aniso8601==9.0.1 -attrs==21.4.0 -branca==0.4.2 -certifi==2021.10.8 -charset-normalizer==2.0.12 -click==8.0.3 -dnspython==2.2.0 -email-validator==1.1.3 +blinker==1.6.2 +branca==0.6.0 +certifi==2023.5.7 +charset-normalizer==3.1.0 +click==8.1.3 +DateTime==5.1 et-xmlfile==1.1.0 -Flask==2.1.2 -Flask-Login==0.5.0 -Flask-Migrate==3.1.0 -flask-restx==0.5.1 -Flask-SQLAlchemy==2.5.1 -Flask-WTF==1.0.0 -folium==0.12.1.post1 -GDAL==3.5.0 -greenlet==1.1.2 -gunicorn==20.1.0 -idna==3.3 -importlib-metadata==4.12.0 -itsdangerous==2.0.1 -Jinja2==3.0.3 -jsonschema==4.4.0 -Mako==1.1.6 -MarkupSafe==2.0.1 -numpy==1.23.0 -openpyxl==3.0.9 -# packaging @ file:///private/tmp/sip--packaging-20220416-83003-1hqovwb/packaging-21.3 -pandas==1.4.1 -Pillow==9.1.1 -ply==3.11 -postgis==1.0.4 -protobuf==3.19.4 -psycopg-postgis==0.4.0 -psycopg2==2.9.3 -psycopg2-binary==2.9.3 -pybind11==2.9.2 -pycairo==1.21.0 -pycountry==22.3.5 -PyGObject==3.42.1 -PyQt6==6.2.0 -PyQt6-3D==6.2.0 -PyQt6-Charts==6.2.0 -PyQt6-DataVisualization==6.2.0 -PyQt6-NetworkAuth==6.2.0 -PyQt6-sip==13.1.0 -PyQt6-WebEngine==6.2.0 -pyrsistent==0.18.1 -PySide6==6.2.4 +Flask==2.3.2 +Flask-WTF==1.1.1 +folium==0.14.0 +idna==3.4 +itsdangerous==2.1.2 +Jinja2==3.1.2 +MarkupSafe==2.1.3 +numpy==1.25.0 +openpyxl==3.1.2 +pandas==2.0.2 +psycopg2-binary==2.9.6 python-dateutil==2.8.2 -python-decouple==3.5 -python-dotenv==0.19.2 -pytz==2021.3 -reportlab==3.6.10 -requests==2.27.1 -scipy==1.8.1 -shiboken6==6.2.4 -shiboken6-generator==6.2.4 -sip==6.6.1 +pytz==2023.3 +requests==2.31.0 six==1.16.0 -SQLAlchemy==1.4.29 -TBB==0.2 -toml==0.10.2 -urllib3==1.26.8 -Werkzeug==2.0.2 +tzdata==2023.3 +urllib3==2.0.3 +Werkzeug==2.3.6 WTForms==3.0.1 -wxPython==4.1.1 -zipp==3.8.0 +zope.interface==6.0 diff --git a/webapp/sites.py b/webapp/sites.py index e99663c..415da60 100644 --- a/webapp/sites.py +++ b/webapp/sites.py @@ -18,7 +18,7 @@ def survey_list(): pg = get_pg_connection() cur = pg.cursor() - cur.execute('SELECT survey_name,count(distinct visit_id), count(*),min(visit_date),max(visit_date) FROM form.field_visit GROUP BY survey_name;') + cur.execute('SELECT survey_name,survey_description,count(distinct visit_id), count(*),min(visit_date),max(visit_date) FROM form.field_visit LEFT JOIN form.surveys USING (survey_name) GROUP BY survey_name, survey_description;') survey_list = cur.fetchall() cur.close() return render_template('sites/survey_list.html', pairs=survey_list, the_title="List of surveys") diff --git a/webapp/species.py b/webapp/species.py index 8cf8326..dd165bc 100644 --- a/webapp/species.py +++ b/webapp/species.py @@ -66,8 +66,11 @@ def threat_list(): cur.execute(create_spp_trait_table) cur.execute('SELECT \"stateConservation\" AS fam,count(distinct "speciesID"), count(distinct s.species_code), count(distinct q.species_code) FROM species.caps LEFT JOIN species_traits s ON "speciesCode_Synonym"=s.species_code::text LEFT JOIN form.quadrat_samples q ON "speciesCode_Synonym"=q.species_code::text GROUP BY fam;') fam_list = cur.fetchall() + cur.execute('SELECT count(distinct "speciesID"), count(distinct s.species_code), count(distinct q.species_code) FROM species.caps LEFT JOIN species_traits s ON "speciesCode_Synonym"=s.species_code::text LEFT JOIN form.quadrat_samples q ON "speciesCode_Synonym"=q.species_code::text;') + fam_total = cur.fetchall() cur.close() - return render_template('species/threat-list.html', pairs=fam_list, the_title="Species per family") + + return render_template('species/threat-list.html', pairs=fam_list, ttl=fam_total, the_title="Species per family") @bp.route('/family/', methods=['GET', 'POST']) @login_required diff --git a/webapp/templates/sites/survey_list.html b/webapp/templates/sites/survey_list.html index 7fc58e8..7c1dce6 100644 --- a/webapp/templates/sites/survey_list.html +++ b/webapp/templates/sites/survey_list.html @@ -9,6 +9,7 @@

{% block title %}List of field surveys{% endblock %}

+ @@ -17,17 +18,18 @@

{% block title %}List of field surveys{% endblock %}

{% if pair[0] == 'TO BE CLASSIFIED' %} - + {% else %} + {% endif %} - - - + + + - + {% endfor %}
Survey nameSurvey description Nr. of distinct sites Nr. of distinct visits Dates
Not assigned to surveyNot assigned to survey{{ pair[0] }} {{ pair[1] }}{{ pair[1] }}Map {{ pair[2] }}Map {{ pair[3] }} List {{ pair[3] }} - {{ pair[4] }}{{ pair[4] }} - {{ pair[5] }}
diff --git a/webapp/templates/species/threat-list.html b/webapp/templates/species/threat-list.html index 796abf3..ae2d6d4 100644 --- a/webapp/templates/species/threat-list.html +++ b/webapp/templates/species/threat-list.html @@ -32,6 +32,12 @@

{% block title %}List of species{% endblock %}

{% endif %} {% endfor %} + + Totals + {{ttl[0][0]}} + {{ttl[0][1]}} + {{ttl[0][2]}} + {% endblock %} From bdfae5604623d768d36ca8d14bcdfe293a92bf16 Mon Sep 17 00:00:00 2001 From: Jose Rafael Ferrer-Paris Date: Wed, 21 Jun 2023 10:20:03 +1000 Subject: [PATCH 7/8] Check information about species link to external sources --- webapp/species.py | 2 ++ webapp/templates/visits/list.html | 8 ++++++++ webapp/visits.py | 9 +++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/webapp/species.py b/webapp/species.py index dd165bc..3c3cd40 100644 --- a/webapp/species.py +++ b/webapp/species.py @@ -219,3 +219,5 @@ def sp_info(id): return render_template('species/info.html', info=spp_info, inat_obs=iNobs, fsamp=samples, traits=traits, mainrefs=ref_list, addrefs=add_list, check=synonym, vag=vag_info) else: return redirect(url_for('.search_list', id=request.form['speciesname'])) + +## use TSProfileID to link to https://www.environment.nsw.gov.au/threatenedspeciesapp/profile.aspx?id= \ No newline at end of file diff --git a/webapp/templates/visits/list.html b/webapp/templates/visits/list.html index 9484a9b..fdd7cf3 100644 --- a/webapp/templates/visits/list.html +++ b/webapp/templates/visits/list.html @@ -26,6 +26,14 @@

{% block title %} {% endif %} + {% if ttl == None %} +

+ No survey has been selected, so this list shows all sites. If you want to narrow down the list, go to the list of surveys. +

+ {% else %} +

This survey includes {{ttl[0]}} sites, {{ttl[1]}} visits, {{ttl[2]}} subplots, {{ttl[3]}} species and {{ttl[4]}} main observers.

+ {% endif %} +

Sites are identified by a site label. One site can be visited multiple times. Click any site's label to see more information about site description and coordinates. Click on the visit's date to see more information regarding the visit event.

diff --git a/webapp/visits.py b/webapp/visits.py index ada39eb..f45f648 100644 --- a/webapp/visits.py +++ b/webapp/visits.py @@ -24,16 +24,21 @@ def visits_list(survey): qry="SELECT * FROM form.surveys where survey_name=%s" cur.execute(qry,(survey,)) survinfo=cur.fetchone() - + + qry='SELECT count(distinct visit_id) as nlocs, count(distinct concat(visit_id,visit_date)) as nvisits, count(distinct CONCAT(visit_date, sample_nr)) as nsamples, count(distinct species_code) as nspp, count(distinct CONCAT(givennames,\' \',surname)) as main_observers FROM form.field_visit v LEFT JOIN form.field_samples s USING(visit_id,visit_date) LEFT JOIN form.quadrat_samples q USING (visit_id,visit_date,sample_nr) LEFT JOIN form.observerid ON mainobserver=userkey WHERE survey_name=%s ;' + cur.execute(qry, (survey,)) + visit_total=cur.fetchone() + qry='SELECT visit_id,visit_date,count(distinct sample_nr),count(distinct species_code),survey_name,CONCAT(givennames,\' \',surname) as main_observer, vegetation_formation, vegetation_class FROM form.field_visit v LEFT JOIN form.field_samples s USING(visit_id,visit_date) LEFT JOIN form.quadrat_samples q USING (visit_id,visit_date,sample_nr) LEFT JOIN form.observerid ON mainobserver=userkey LEFT JOIN form.field_visit_veg_description USING(visit_id,visit_date) WHERE survey_name=%s GROUP BY survey_name,visit_id,visit_date, givennames, surname, vegetation_formation, vegetation_class ORDER BY survey_name,visit_id;' cur.execute(qry, (survey,)) + visit_list = cur.fetchall() cur.close() if survey == None: return render_template('visits/list.html', visits=visit_list, survey=survey) else: - return render_template('visits/list.html', visits=visit_list, survey=survinfo) + return render_template('visits/list.html', visits=visit_list, survey=survinfo, ttl=visit_total) @bp.route('//
') @login_required From dd03af822b29feac5e1edf51b9488ff520d744d5 Mon Sep 17 00:00:00 2001 From: Jose Rafael Ferrer-Paris Date: Fri, 1 Mar 2024 08:31:17 +1100 Subject: [PATCH 8/8] update pickle --- webapp/xlinit.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/webapp/xlinit.py b/webapp/xlinit.py index 262bc6f..93ef8ec 100644 --- a/webapp/xlinit.py +++ b/webapp/xlinit.py @@ -12,8 +12,10 @@ from psycopg2.extras import DictCursor # https://stackoverflow.com/questions/63329657/python-3-7-error-unsupported-pickle-protocol-5 -import pickle #import pickle5 as pickle + +import pickle + ## First, load SQL queries with open('webapp/content/sql_queries.pik', 'rb') as f: