-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add only school users to game (#622)
* Reduced no. of students being added to game * Changed get_users again * Refactored get_users function * Imported Models from portal * Preview user required * Is preview user permission * Remove debugging statements * Remove redundant return statement * install portal for tests and aimmo_runner as well * install sass for portal * Add user profile to tests * add test_settings * Wrote a default preview_user decorator * Testing import get_users_for_new_game * Added prints for debugging * Debugging * More debugging * Stuff * Temporarily breaking new game for testing * Changed version of aimmo * testing * Testing * Testing aimmo version again * Temporarily commented out preview user decorator for testing * Added decorator back * More changes * Testing build * Testing again * ChANGES * More changes * STill not working * rm portal refs * trying add projects * Still testing * Attempt at fixing logging * It's gonna work! * Removed prints * Removed integration-tests app from all_tests * Removed more prints * Removed prints * Removed another print * Fixed something * More fixes * Refactored to follow pep8 * Refactored stuff * More refactoring * Refactored * Refactors * Renamed decorator to preview_user_required * Added comments for both functions in app_settings that import things from portal
- Loading branch information
1 parent
b957777
commit 3cf2214
Showing
15 changed files
with
96 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,7 +101,6 @@ def is_server_healthy(url): | |
|
||
attempts += 1 | ||
time.sleep(1) | ||
|
||
return False | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,42 @@ | ||
from django.conf import settings | ||
from django.utils.module_loading import import_string | ||
from permissions import default_preview_user | ||
from django.contrib.auth.models import User | ||
|
||
#: URL function for locating the game server, takes one parameter `game` | ||
GAME_SERVER_URL_FUNCTION = getattr(settings, 'AIMMO_GAME_SERVER_URL_FUNCTION', None) | ||
GAME_SERVER_PORT_FUNCTION = getattr(settings, 'AIMMO_GAME_SERVER_PORT_FUNCTION', None) | ||
GAME_SERVER_SSL_FLAG = getattr(settings, 'AIMMO_GAME_SERVER_SSL_FLAG', False) | ||
PREVIEW_USER_AIMMO_DECORATOR = getattr(settings, 'PREVIEW_USER_AIMMO_DECORATOR', None) | ||
USERS_FOR_NEW_AIMMO_GAME = getattr(settings, 'USERS_FOR_NEW_AIMMO_GAME', None) | ||
|
||
|
||
def get_aimmo_preview_user_decorator(): | ||
""" | ||
This function is used to import a decorator from portal, which | ||
checks whether the logged in user is a preview user. | ||
:return: A function decorator | ||
""" | ||
if PREVIEW_USER_AIMMO_DECORATOR: | ||
func = import_string(PREVIEW_USER_AIMMO_DECORATOR) | ||
return func | ||
return default_preview_user | ||
|
||
|
||
def get_users_for_new_game(request): | ||
""" | ||
Imports and calls a function defined in portal, that decides | ||
which users should be added to the newly created game. | ||
:param request: | ||
:return: List of User objects | ||
""" | ||
if USERS_FOR_NEW_AIMMO_GAME: | ||
func = import_string(USERS_FOR_NEW_AIMMO_GAME) | ||
return func(request) | ||
return User.objects.all() | ||
|
||
|
||
preview_user_required = get_aimmo_preview_user_decorator() | ||
|
||
MAX_LEVEL = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from functools import wraps | ||
|
||
|
||
def default_preview_user(view_func): | ||
@wraps(view_func) | ||
def wrapped(request, *args, **kwargs): | ||
return view_func(request, *args, **kwargs) | ||
return wrapped |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,25 @@ | ||
import os | ||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
'NAME': os.path.join(os.path.abspath(os.path.dirname(__file__)), 'db.sqlite3'), | ||
}, | ||
} | ||
|
||
INSTALLED_APPS = [ | ||
'django.contrib.admin', | ||
'django.contrib.auth', | ||
'players', | ||
'integration_tests', | ||
'aimmo_runner', | ||
] | ||
|
||
PIPELINE_ENABLED = False | ||
ROOT_URLCONF = 'django_autoconfig.autourlconf' | ||
STATIC_ROOT = '.tests_static/' | ||
|
||
SECRET_KEY = 'test_key' | ||
GAME_SERVER_URL_FUNCTION = lambda game_id: ('base %s' % game_id, 'path %s' % game_id) | ||
GAME_SERVER_PORT_FUNCTION = lambda game_id: 8001 | ||
GAME_SERVER_SSL_FLAG = False | ||
|
||
from django_autoconfig.autoconfig import configure_settings # noqa: E402 | ||
configure_settings(globals()) |