Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix various: authorize null value for organism or role name #126

Merged
merged 2 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions app/genericRepository.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@ class GenericRepository(db.Model):

@classmethod
def get_one(cls, id, as_model=False):

"""
Methode qui retourne un dictionnaire d'un élément d'un Model
Avec pour paramètres l'id de l'élément
Si as_model != False alors au lieu de retourner un dictionnaire on retourne l'object du modèle
"""
if not id:
return None

data = db.session.query(cls).get(id)

if as_model == False:
data = db.session.query(cls).get(id)
if not as_model:
return data.as_dict(True)
else:
return db.session.query(cls).get(id)
return data

@classmethod
def get_all(
Expand Down
23 changes: 13 additions & 10 deletions app/t_roles/route.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ def updatepass(id_role=None):
"""
form = t_rolesforms.UserPass()
myuser = TRoles.get_one(id_role)
# Build title
role_fullname= buildUserFullName(myuser)
title=f"Changer le mot de passe de l'utilisateur '{role_fullname}'"

if request.method == "POST":
if form.validate_on_submit() and form.validate():
Expand All @@ -241,11 +244,7 @@ def updatepass(id_role=None):
return render_template(
"user_pass.html",
form=form,
title="Changer le mot de passe de l'utilisateur '"
+ myuser["nom_role"]
+ " "
+ myuser["prenom_role"]
+ "'",
title=title,
id_role=id_role,
)
form_user["id_role"] = id_role
Expand All @@ -257,11 +256,7 @@ def updatepass(id_role=None):
return render_template(
"user_pass.html",
form=form,
title="Changer le mot de passe de l'utilisateur '"
+ myuser["nom_role"]
+ " "
+ myuser["prenom_role"]
+ "'",
title=title,
id_role=id_role,
)

Expand Down Expand Up @@ -300,6 +295,14 @@ def info(id_role):
pathU=URL_APPLICATION + "/user/update/",
)

def buildUserFullName(user):
fullname = []
if user["nom_role"]:
fullname.append(user["nom_role"].upper())
if user["prenom_role"]:
fullname.append(user["prenom_role"].title())
return ' '.join(fullname)


def pops(form, with_group=True):
"""
Expand Down
6 changes: 3 additions & 3 deletions app/templates/info_user.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

{%set is_identifiant = user['identifiant'] is not none and user['identifiant'] != '' %}
{%set is_uuid = user['uuid_role'] is not none and user['uuid_role'] != '' %}
{%set is_organisme = organisme.nom_organisme is not none and organisme.nom_organisme != '' %}
{%set is_organisme = organisme is not none and organisme['nom_organisme'] != '' %}
{%set is_desc = user['desc_role'] is not none and user['desc_role'] != '' %}
{%set is_remarques = user['remarques'] is not none and user['remarques'] != '' %}
{%set is_mail = user['email'] is not none and user['email'] != '' %}
{%set is_group = groups|length > 0 %}
{%set is_list = lists|length > 0 %}
{%set is_right = rights|length > 0 %}
<div class="container main-zone ng-scope ">
<h3>Utilisateur "{{user['nom_role']}} {{user['prenom_role']}}"</h3>
<h3>Utilisateur "{{user['fullname']}}"</h3>
<div class="ml-5">
<small>
{% if is_desc %}
Expand All @@ -21,7 +21,7 @@ <h3>Utilisateur "{{user['nom_role']}} {{user['prenom_role']}}"</h3>
<br /><strong>UUID :</strong> {{user['uuid_role']}}
{% endif %}
{% if is_identifiant %}
<br /><strong>Identifiant :</strong>{{user['identifiant']}}
<br /><strong>Identifiant :</strong> {{user['identifiant']}}
{% endif %}
{% if is_mail %}
<br /><strong>Email :</strong> <a href="mailto:{{user['email']}}">{{user['email']}}</a>
Expand Down