Skip to content

Create account #18

Merged
raynaldlao merged 3 commits intomasterfrom
create-account
Mar 6, 2026
Merged

Create account #18
raynaldlao merged 3 commits intomasterfrom
create-account

Conversation

@hlargitte
Copy link
Owner

Ajout de la fonctionnalité de création de compte

Cette Pull Request a son importance étant donné que nous créions les comptes en base de données pour les tests jusque là.
L'objectif était de pouvoir créer un compte directement via l'application.

Résumé des changements

  • Contrôleur et Service : Modification du contrôleur et du service lié à la création de compte tout en respectant la refactorisation du code.
  • Base de données : Modification de la base de données afin de prendre en compte l'impossibilité de créer un compte sans email. Il n'est également plus possible d'avoir le même email pour deux comptes différents.
  • Modele : Modification du modèle de account pour répercuter les modifications de la base de données sur l'objet.
  • Vue / template : Création d'un formulaire HTML qui prend en compte les contraintes de base de données citées précédemment et adapte l'affichage en conséquence.
  • Tests : Ajout des tests adéquats.

Validation Technique

  • Unit Tests : 60/60 tests passés avec succès (pytest).
  • Static Analysis : 0 erreur rapportée par pyright.
  • Linting : 0 erreur rapportée par ruff.

Contenu de la PR

app/controllers/registration_controller.py : Modification du Contrôleur du compte qui permet via le bouton du formulaire d'être redirigé.
app/services/registration_service.py : Logique métier de la création du compte.
app/templates/registration.html : Formulaire HTML de création de compte.
app/models/account_model.py : Modification du modèle pour prendre en compte l'unicité du email et l'impossibilité de créer un compte sans email.

@hlargitte hlargitte self-assigned this Mar 5, 2026
Copy link
Owner

@raynaldlao raynaldlao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Faut modifier certains fichiers mais dans l'ensemble c'est ok

page_number=page_number,
total_pages=total_pages
)
return render_template("index.html", articles=articles, page_number=page_number, total_pages=total_pages)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Faut le remettre comme avant, c'est à cause de ruff ça.

Quand tu fais :

render_template("index.html", articles=articles, page_number=page_number, total_pages=total_pages)

Si tu as un petit PC, tu seras obligé de scroll à droite.

Si tu fais ça par contre :

render_template(
"index.html",
articles=articles,
page_number=page_number,
total_pages=total_pages
)

content=content,
author_id=user_id
)
article_service.create_article(title=title, content=content, author_id=user_id)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem : Faut le remettre comme avant, c'est à cause de ruff ça.

title=title,
content=content
)
article = article_service.update_article(article_id=article_id, user_id=user_id, role=role, title=title, content=content)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem : Faut le remettre comme avant, c'est à cause de ruff ça.

user_id=user_id,
role=role
):
if article_service.delete_article(article_id=article_id, user_id=user_id, role=role):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem : Faut le remettre comme avant, c'est à cause de ruff ça.

user_id=session[SessionKey.USER_ID],
content=content
):
if comment_service.create_comment(article_id=article_id, user_id=session[SessionKey.USER_ID], content=content):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem : Faut le remettre comme avant, c'est à cause de ruff ça.

comment_written_account_id=user_id,
comment_content=content
)
new_comment = Comment(comment_article_id=article_id, comment_written_account_id=user_id, comment_content=content)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem : Faut le remettre comme avant, c'est à cause de ruff ça.

.options(joinedload(Comment.comment_author))
.order_by(Comment.comment_posted_at.asc())
)
query = select(Comment).where(Comment.comment_article_id == article_id).options(joinedload(Comment.comment_author)).order_by(Comment.comment_posted_at.asc())
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem : Faut le remettre comme avant, c'est à cause de ruff ça.

existing_username = self.session.execute(existing_username_query).scalar_one_or_none()

if existing_username:
return "This username is already taken."
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi c'est pas un résultat en flash ?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pour respecter le Principe de Responsabilité Unique (SRP — SOLID)

existing_email = self.session.execute(existing_email_query).scalar_one_or_none()

if existing_email:
return "This email is already taken."
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem : Pourquoi c'est pas un résultat en flash ?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pour respecter le Principe de Responsabilité Unique (SRP — SOLID)

"TESTING": True,
"SECRET_KEY": env_vars.test_secret_key
})
flask_app.config.update({"TESTING": True, "SECRET_KEY": env_vars.test_secret_key})
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem : Faut le remettre comme avant, c'est à cause de ruff ça.

@hlargitte hlargitte force-pushed the create-account branch 2 times, most recently from 1666ea0 to 5a393c5 Compare March 6, 2026 00:47
@hlargitte hlargitte closed this Mar 6, 2026
@raynaldlao raynaldlao reopened this Mar 6, 2026
@raynaldlao raynaldlao merged commit 5154f13 into master Mar 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants