Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: TAG 2021/22 Summer Sprint 1
    • Fix Version/s: Current Version
    • Component/s: OIOIOI
    • Labels:
      None

      Description

      In some rare occasions registration fails with 500 error (see attachment).

      Go to szkopul:
      1. Login
      2. Logout
      3. click "login"
      4. enter fake data (non-existent user)
      5. click "create new account"

        Activity

        Hide
        Tomek Waleń added a comment -
        Possible solution:

        diff --git a/oioioi/base/views.py b/oioioi/base/views.py
        index d5466e29..71819b6f 100644
        --- a/oioioi/base/views.py
        +++ b/oioioi/base/views.py
        @@ -99,6 +99,8 @@ def adjust_preferences_factory_fields(request):
             choices_not_translated = [("", "None")] + list(settings.LANGUAGES)
             choices = [(k, _(v)) for k, v in choices_not_translated]
         
        + ensure_preferences_exist_for_user(request)
        +
             PreferencesFactory.add_field(
                 "preferred_language",
                 ChoiceField,
        Show
        Tomek Waleń added a comment - Possible solution: diff --git a/oioioi/base/views.py b/oioioi/base/views.py index d5466e29..71819b6f 100644 --- a/oioioi/base/views.py +++ b/oioioi/base/views.py @@ -99,6 +99,8 @@ def adjust_preferences_factory_fields(request):      choices_not_translated = [("", "None")] + list(settings.LANGUAGES)      choices = [(k, _(v)) for k, v in choices_not_translated]   + ensure_preferences_exist_for_user(request) +      PreferencesFactory.add_field(          "preferred_language",          ChoiceField,
        Andrzej Radzimiński made changes -
        Field Original Value New Value
        Assignee Andrzej Radzimiński [ ar429586 ]
        Andrzej Radzimiński made changes -
        Description In some rare occasions registration fails with 500 error (see attachment).

        Go to szkopul:
        1. click "login"
        2. enter fake data (non-existent user)
        3. click "create new account"
        In some rare occasions registration fails with 500 error (see attachment).

        Go to szkopul:
        1. Login
        2. Logout
        3. click "login"
        4. enter fake data (non-existent user)
        5. click "create new account"
        Hide
        Andrzej Radzimiński added a comment -
        Reason:
        `adjust_preferences_factory_fields` adds field, that uses `user` to get default view. Then `RegistrationView` generates form using `PreferenceFactory` with `user` set to `None`.

        Possible fix:
        Lambda added in adjust_preferences_factory_fields can test is User is None. This fixes the problem, but `RegistrationView` now may or may not has preferences fields. Additionally preferences fields visible in registration form have will have no effect. To fix this `adjust_preferences_factory_fields`+`handle_new_preference_fields` logic should be added to `RegistrationView`.

        `Adjust_preferences_factory_fields` could be called once in same way `_maybe_add_field` is called, but I'm not sure if it will always work.
        Show
        Andrzej Radzimiński added a comment - Reason: `adjust_preferences_factory_fields` adds field, that uses `user` to get default view. Then `RegistrationView` generates form using `PreferenceFactory` with `user` set to `None`. Possible fix: Lambda added in adjust_preferences_factory_fields can test is User is None. This fixes the problem, but `RegistrationView` now may or may not has preferences fields. Additionally preferences fields visible in registration form have will have no effect. To fix this `adjust_preferences_factory_fields`+`handle_new_preference_fields` logic should be added to `RegistrationView`. `Adjust_preferences_factory_fields` could be called once in same way `_maybe_add_field` is called, but I'm not sure if it will always work.
        Andrzej Radzimiński made changes -
        Status New [ 10000 ] Resolved [ 5 ]
        Assignee Andrzej Radzimiński [ ar429586 ] Tomasz Waleń [ tomasz_walen ]
        Fix Version/s Current Version [ 11000 ]
        Resolution Fixed [ 1 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        New New Resolved Resolved
        14d 15m 1 Andrzej Radzimiński 2022-05-18 16:24

          People

          • Assignee:
            Tomasz Waleń
            Reporter:
            Aleksander Tudruj
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: