Skip to content

Commit

Permalink
Merge branch 'PnX-SI:master' into champs-libres
Browse files Browse the repository at this point in the history
  • Loading branch information
nobohan committed Aug 23, 2021
2 parents 9eddf3c + 197e64b commit 8834fd1
Show file tree
Hide file tree
Showing 29 changed files with 8,201 additions and 5,141 deletions.
5 changes: 0 additions & 5 deletions .gitignore
Expand Up @@ -245,11 +245,6 @@ contrib/gnc_*
#FrontEnd config files
frontend/src/conf/*.ts

#Frontend custom files
frontend/custom/**/*.css
frontend/custom/**/*.html
frontend/custom/**/*.ico

# pipenv: comment when migrating from traditional pip+v(irtual)env
Pipfile
Pipfile.lock
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.99.0-dev
0.99.3-dev
26 changes: 14 additions & 12 deletions backend/gncitizen/core/badges/routes.py
Expand Up @@ -7,11 +7,12 @@
from sqlalchemy.sql.expression import func
from datetime import date, datetime, timedelta
from calendar import monthrange
from server import db

routes = Blueprint("routes", __name__)
badges_api = Blueprint("badges", __name__)


@routes.route("/rewards/<int:id>", methods=["GET"])
@badges_api.route("/rewards/<int:id>", methods=["GET"])
def get_rewards(id):

total_obs = 0
Expand All @@ -33,24 +34,25 @@ def get_rewards(id):
program_scores.append({"id_program": item.id, "nb_obs": item.nb_obs})
total_obs = total_obs + item.nb_obs
taxon_classe_query = (
ObservationModel.query.filter(ObservationModel.id_role == id)
.outerjoin(Taxref, Taxref.cd_nom == ObservationModel.cd_nom)
.group_by(Taxref.classe)
.values(
Taxref.classe.label("classe"), func.count(Taxref.classe).label("nb_obs")
db.session.query(
Taxref.classe.label("classe"), func.count(Taxref.famille).label("nb_obs")
)
.join(ObservationModel, Taxref.cd_nom == ObservationModel.cd_nom)
.filter(ObservationModel.id_role == id)
.group_by(Taxref.classe)
)
for item in taxon_classe_query:
taxon_scores.append({"classe": item.classe, "nb_obs": item.nb_obs})

taxon_famille_query = (
ObservationModel.query.filter(ObservationModel.id_role == id)
.outerjoin(Taxref, Taxref.cd_nom == ObservationModel.cd_nom)
.group_by(Taxref.famille)
.values(
db.session.query(
Taxref.famille.label("famille"), func.count(Taxref.famille).label("nb_obs")
)
.join(ObservationModel, Taxref.cd_nom == ObservationModel.cd_nom)
.filter(ObservationModel.id_role == id)
.group_by(Taxref.famille)
)

for item in taxon_famille_query:
taxon_scores.append({"famille": item.famille, "nb_obs": item.nb_obs})

Expand Down Expand Up @@ -156,7 +158,7 @@ def monthdelta(d1, d2):
return delta


@routes.route("/stats", methods=["GET"])
@badges_api.route("/stats", methods=["GET"])
@json_resp
def get_stat():
try:
Expand Down
13 changes: 4 additions & 9 deletions backend/gncitizen/core/commons/admin.py
Expand Up @@ -10,15 +10,8 @@
from flask_admin.contrib.geoa import ModelView
from flask_admin.form import SecureForm
from flask_admin.form.upload import FileUploadField
from flask_ckeditor import CKEditorField
from flask_jwt_extended import get_jwt_identity
from flask_jwt_extended.exceptions import UserLoadError
from flask_jwt_extended.utils import (
decode_token,
has_user_loader,
user_loader,
verify_token_not_blacklisted,
)
from flask_ckeditor import CKEditorField

from geoalchemy2.shape import from_shape
from geojson import FeatureCollection
from shapely.geometry import MultiPolygon, asShape
Expand Down Expand Up @@ -84,6 +77,7 @@ class ProjectView(ModelView):
create_template = "edit.html"
edit_template = "edit.html"
form_excluded_columns = ["timestamp_create", "timestamp_update"]
column_exclude_list = ['long_desc','short_desc']


class ProgramView(ModelView):
Expand All @@ -93,6 +87,7 @@ class ProgramView(ModelView):
create_template = "edit.html"
edit_template = "edit.html"
form_excluded_columns = ["timestamp_create", "timestamp_update"]
column_exclude_list = ['long_desc','form_message','short_desc','image','logo']
inline_models = [
(
CorProgramSiteTypeModel,
Expand Down

0 comments on commit 8834fd1

Please sign in to comment.