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

Error when trying to join an already joined space #54

Closed
mustafacagataytulun opened this issue May 12, 2022 · 1 comment
Closed

Error when trying to join an already joined space #54

mustafacagataytulun opened this issue May 12, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@mustafacagataytulun
Copy link
Owner

Repro steps:

  1. Logout from the website.
  2. Go into a colearning space.
  3. Click Join button. The system will redirect to login page.
  4. Enter login credentials and submit. Important: The user must be already joined to that colearning space before.
  5. The system throws an error detailed below. It should quietly redirect the user to the colearning space without doing anything.
Environment:


Request Method: GET
Request URL: http://localhost:8000/spaces/14/join

Django Version: 4.0.4
Python Version: 3.8.10
Installed Applications:
['articles',
 'dashboard',
 'glossary',
 'spaces',
 'users',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django_bootstrap5',
 'markdownify.apps.MarkdownifyConfig',
 'storages']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback (most recent call last):
  File "/home/mustafacagataytulun/code/bounswe573-2022/colearnapp/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/home/mustafacagataytulun/code/bounswe573-2022/colearnapp/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/mustafacagataytulun/code/bounswe573-2022/colearnapp/venv/lib/python3.8/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/home/mustafacagataytulun/code/bounswe573-2022/colearnapp/spaces/views.py", line 75, in join
    return redirect('spaces:view', id=space.id)

Exception Type: UnboundLocalError at /spaces/14/join
Exception Value: local variable 'space' referenced before assignment
@mustafacagataytulun mustafacagataytulun added the bug Something isn't working label May 12, 2022
@mustafacagataytulun mustafacagataytulun self-assigned this May 12, 2022
@mustafacagataytulun
Copy link
Owner Author

This was an interesting behavior of Python (for example, C# throws a compile-time error for this).

Fixed by defining space variable outside of if block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant