mirror of
https://github.com/lucaspalomodevelop/eventcally.git
synced 2026-03-13 00:07:22 +00:00
Make comparison for deletion case insensitive #71
This commit is contained in:
parent
3fe12cb1b7
commit
e642557ac6
@ -65,7 +65,7 @@ app.config.update(
|
||||
plugins=[marshmallow_plugin],
|
||||
openapi_version="2.0",
|
||||
info=dict(
|
||||
description="This API provides endpoints to interact with the Oveda data. At the moment, there is no authorization neeeded."
|
||||
description="This API provides endpoints to interact with the Oveda data. At the moment, there is no authorization needed."
|
||||
),
|
||||
),
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ from project.views.utils import (
|
||||
permission_missing,
|
||||
handleSqlError,
|
||||
flash_errors,
|
||||
non_match_for_deletion,
|
||||
)
|
||||
from project.access import has_access
|
||||
from project.services.admin_unit import add_roles_to_admin_unit_member
|
||||
@ -63,7 +64,7 @@ def manage_admin_unit_member_delete(id):
|
||||
form = DeleteAdminUnitMemberForm()
|
||||
|
||||
if form.validate_on_submit():
|
||||
if form.email.data != member.user.email:
|
||||
if non_match_for_deletion(form.email.data, member.user.email):
|
||||
flash(gettext("Entered email does not match member email"), "danger")
|
||||
else:
|
||||
try:
|
||||
|
||||
@ -13,6 +13,7 @@ from project.views.utils import (
|
||||
send_mail,
|
||||
handleSqlError,
|
||||
flash_errors,
|
||||
non_match_for_deletion,
|
||||
)
|
||||
from project.access import get_admin_unit_for_manage_or_404, has_access
|
||||
from project.services.admin_unit import add_user_to_admin_unit_with_roles
|
||||
@ -111,7 +112,7 @@ def manage_admin_unit_invitation_delete(id):
|
||||
form = DeleteAdminUnitInvitationForm()
|
||||
|
||||
if form.validate_on_submit():
|
||||
if form.email.data != invitation.email:
|
||||
if non_match_for_deletion(form.email.data, invitation.email):
|
||||
flash(gettext("Entered email does not match invitation email"), "danger")
|
||||
else:
|
||||
try:
|
||||
|
||||
@ -27,6 +27,7 @@ from project.views.utils import (
|
||||
handleSqlError,
|
||||
flash_message,
|
||||
send_mail,
|
||||
non_match_for_deletion,
|
||||
)
|
||||
from project.utils import get_event_category_name
|
||||
from project.services.event import (
|
||||
@ -179,7 +180,7 @@ def event_delete(event_id):
|
||||
form = DeleteEventForm()
|
||||
|
||||
if form.validate_on_submit():
|
||||
if form.name.data != event.name:
|
||||
if non_match_for_deletion(form.name.data, event.name):
|
||||
flash(gettext("Entered name does not match event name"), "danger")
|
||||
else:
|
||||
try:
|
||||
|
||||
@ -12,6 +12,7 @@ from project.forms.event_place import (
|
||||
from project.views.utils import (
|
||||
flash_errors,
|
||||
handleSqlError,
|
||||
non_match_for_deletion,
|
||||
)
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
|
||||
@ -79,7 +80,7 @@ def event_place_delete(id):
|
||||
form = DeleteEventPlaceForm()
|
||||
|
||||
if form.validate_on_submit():
|
||||
if form.name.data != place.name:
|
||||
if non_match_for_deletion(form.name.data, place.name):
|
||||
flash(gettext("Entered name does not match place name"), "danger")
|
||||
else:
|
||||
try:
|
||||
|
||||
@ -12,6 +12,7 @@ from project.forms.organizer import (
|
||||
from project.views.utils import (
|
||||
flash_errors,
|
||||
handleSqlError,
|
||||
non_match_for_deletion,
|
||||
)
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
|
||||
@ -79,7 +80,7 @@ def organizer_delete(id):
|
||||
form = DeleteOrganizerForm()
|
||||
|
||||
if form.validate_on_submit():
|
||||
if form.name.data != organizer.name:
|
||||
if non_match_for_deletion(form.name.data, organizer.name):
|
||||
flash(gettext("Entered name does not match organizer name"), "danger")
|
||||
else:
|
||||
try:
|
||||
|
||||
@ -1,5 +1,10 @@
|
||||
from project import app, db
|
||||
from project.views.utils import get_pagination_urls, flash_errors, handleSqlError
|
||||
from project.views.utils import (
|
||||
get_pagination_urls,
|
||||
flash_errors,
|
||||
handleSqlError,
|
||||
non_match_for_deletion,
|
||||
)
|
||||
from project.access import (
|
||||
get_admin_unit_for_manage_or_404,
|
||||
get_admin_units_for_event_reference,
|
||||
@ -148,7 +153,7 @@ def reference_delete(id):
|
||||
form = DeleteReferenceForm()
|
||||
|
||||
if form.validate_on_submit():
|
||||
if form.name.data != reference.event.name:
|
||||
if non_match_for_deletion(form.name.data, reference.event.name):
|
||||
flash(gettext("Entered name does not match event name"), "danger")
|
||||
else:
|
||||
try:
|
||||
|
||||
@ -86,3 +86,7 @@ def send_mails(recipients, subject, template, **context):
|
||||
return
|
||||
|
||||
mail.send(msg)
|
||||
|
||||
|
||||
def non_match_for_deletion(str1: str, str2: str) -> bool:
|
||||
return str1 != str2 and str1.casefold() != str2.casefold()
|
||||
|
||||
@ -78,7 +78,7 @@ def test_delete(client, app, utils, seeder):
|
||||
url,
|
||||
data={
|
||||
"csrf_token": utils.get_csrf(response),
|
||||
"email": "test@test.de",
|
||||
"email": "Test@test.de",
|
||||
"submit": "Submit",
|
||||
},
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user