|
4 | 4 | import re
|
5 | 5 | import secrets
|
6 | 6 |
|
7 |
| -import coreapi |
8 | 7 | from allauth.socialaccount import helpers
|
9 | 8 | from allauth.socialaccount.models import SocialAccount
|
10 | 9 | from allauth.socialaccount.views import SignupView as SocialSignupViewDefault
|
|
16 | 15 | from django.db import transaction
|
17 | 16 | from django.http import HttpResponse, JsonResponse
|
18 | 17 | from django.shortcuts import redirect, render
|
19 |
| -from django.urls import reverse |
20 | 18 | from google.auth.transport import requests as grequests
|
21 | 19 | from google.oauth2 import id_token
|
22 | 20 | from rest_framework import permissions, status
|
23 |
| -from rest_framework.compat import coreapi |
24 | 21 | from rest_framework.decorators import api_view, permission_classes
|
25 | 22 | from rest_framework.parsers import JSONParser
|
26 |
| -from rest_framework.schemas import AutoSchema |
27 | 23 |
|
28 | 24 | from .filestore import (delete_filestore_user, login_filestore_user,
|
29 | 25 | set_filestore_scope)
|
@@ -375,19 +371,19 @@ def my_scenes(request):
|
375 | 371 | except (ValueError, SocialAccount.DoesNotExist) as err:
|
376 | 372 | return JsonResponse({"error": err}, status=status.HTTP_403_FORBIDDEN)
|
377 | 373 |
|
378 |
| - serializer = SceneNameSerializer(get_my_scenes(user), many=True) |
| 374 | + serializer = SceneNameSerializer(get_my_scenes(user, request.version), many=True) |
379 | 375 | return JsonResponse(serializer.data, safe=False)
|
380 | 376 |
|
381 | 377 |
|
382 |
| -def get_my_scenes(user): |
| 378 | +def get_my_scenes(user, version): |
383 | 379 | """
|
384 | 380 | Internal method to update scene permissions table:
|
385 | 381 | 1. Requests list of any scenes with objects saved from /persist/!allscenes to add to scene permissions table.
|
386 | 382 | 2. Requests and returns list of user's editable scenes from scene permissions table.
|
387 | 383 | """
|
388 | 384 | # update scene list from object persistance db
|
389 | 385 | if user.is_authenticated:
|
390 |
| - token = all_scenes_read_token() |
| 386 | + token = all_scenes_read_token(version) |
391 | 387 | if user.is_staff: # admin/staff
|
392 | 388 | p_scenes = get_persist_scenes_all(token)
|
393 | 389 | else: # standard user
|
@@ -474,9 +470,8 @@ def user_profile(request):
|
474 | 470 | - Shows scenes that the user has permissions to edit and a button to edit them.
|
475 | 471 | - Handles account deletes.
|
476 | 472 | """
|
477 |
| - # TODO (mwfarb): make remote post status 426, local post redirect to valid |
478 |
| - # if request.version not in TOPIC_SUPPORTED_API_VERSIONS: |
479 |
| - # return reverse("users:user_profile", current_app="users") |
| 473 | + if request.version not in TOPIC_SUPPORTED_API_VERSIONS: |
| 474 | + return redirect(f"/{TOPIC_SUPPORTED_API_VERSIONS[0]}/user_profile/") |
480 | 475 |
|
481 | 476 | if request.method == 'POST':
|
482 | 477 | # account delete request
|
@@ -512,7 +507,7 @@ def user_profile(request):
|
512 | 507 | except User.DoesNotExist:
|
513 | 508 | messages.error(request, "Unable to complete account delete.")
|
514 | 509 |
|
515 |
| - scenes = get_my_scenes(request.user) |
| 510 | + scenes = get_my_scenes(request.user, request.version) |
516 | 511 | devices = get_my_devices(request.user)
|
517 | 512 | staff = None
|
518 | 513 | if request.user.is_staff: # admin/staff
|
|
0 commit comments