nebius/SWE-bench-extra huggingface dataset:
Repository: spiral-project/ihatemoney

Issue:
Creating new project on hosted site fails on captcha
Sorry in advance if this bug tracker is not meant for issues with the hosted site.

I tried to create a new project but the captcha validation always fails. I am 99.9% sure I am human and answering it correctly:

![Bildschirmfoto_2022-09-09_09-19-07](https://user-images.githubusercontent.com/7661092/189294623-be979967-42bc-437e-894c-49623e6ca4fb.png)

I tried in multiple browsers but always got the verification fail.

Comments:

Patch:
diff --git a/ihatemoney/forms.py b/ihatemoney/forms.py
index af44ead..c4fc32a 100644
--- a/ihatemoney/forms.py
+++ b/ihatemoney/forms.py
@@ -254,7 +254,7 @@ class ProjectFormWithCaptcha(ProjectForm):
     )
 
     def validate_captcha(self, field):
-        if not field.data.lower() == _("euro"):
+        if not field.data.lower() == _("euro").lower():
             message = _("Please, validate the captcha to proceed.")
             raise ValidationError(Markup(message))
 


Test patch:
diff --git a/ihatemoney/tests/main_test.py b/ihatemoney/tests/main_test.py
index 97ab82a..f0a11d6 100644
--- a/ihatemoney/tests/main_test.py
+++ b/ihatemoney/tests/main_test.py
@@ -301,6 +301,23 @@ class EmailFailureTestCase(IhatemoneyTestCase):
 class CaptchaTestCase(IhatemoneyTestCase):
     ENABLE_CAPTCHA = True
 
+    def test_project_creation_with_captcha_case_insensitive(self):
+        # Test that case doesn't matter
+        # Patch the lazy_gettext as it is imported as '_' in forms for captcha value check
+        with patch("ihatemoney.forms._", new=lambda x: "ÉÙÜẞ"), self.client as c:
+            c.post(
+                "/create",
+                data={
+                    "name": "raclette party",
+                    "id": "raclette",
+                    "password": "party",
+                    "contact_email": "raclette@notmyidea.org",
+                    "default_currency": "USD",
+                    "captcha": "éùüß",
+                },
+            )
+            assert len(models.Project.query.all()) == 1
+
     def test_project_creation_with_captcha(self):
         with self.client as c:
             c.post(
Repository: spiral-project/ihatemoney

Issue:
Creating a project doesn't remember it
Currently, authentication form adds the project in a list that is rendered to quickly switch between project.

However, **creating** a project doesn't add it to this list.

Comments:

Patch:
diff --git a/ihatemoney/web.py b/ihatemoney/web.py
index c14c9b9..9e03402 100644
--- a/ihatemoney/web.py
+++ b/ihatemoney/web.py
@@ -322,8 +322,7 @@ def create_project():
             db.session.commit()
 
             # create the session object (authenticate)
-            session[project.id] = True
-            session.update()
+            set_authorized_project(project)
 
             # send reminder email
             g.project = project


Test patch:
diff --git a/ihatemoney/tests/budget_test.py b/ihatemoney/tests/budget_test.py
index 696a4cd..1b51554 100644
--- a/ihatemoney/tests/budget_test.py
+++ b/ihatemoney/tests/budget_test.py
@@ -119,6 +119,16 @@ class BudgetTestCase(IhatemoneyTestCase):
         resp = self.client.get("/raclette/join/token.invalid", follow_redirects=True)
         self.assertIn("Provided token is invalid", resp.data.decode("utf-8"))
 
+    def test_create_should_remember_project(self):
+        """Test that creating a project adds it to the "logged in project" list,
+        as it does for authentication
+        """
+        self.login("raclette")
+        self.post_project("raclette")
+        self.post_project("tartiflette")
+        data = self.client.get("/raclette/").data.decode("utf-8")
+        self.assertEqual(data.count('href="/tartiflette/"'), 1)
+
     def test_multiple_join(self):
         """Test that joining multiple times a project
         doesn't add it multiple times in the session"""