Rename all instances of Player->Account.

This commit is contained in:
Griatch 2017-07-07 23:47:21 +02:00
parent a14e11640b
commit 5590ee2258
94 changed files with 1316 additions and 2327 deletions

View file

@ -15,12 +15,12 @@ class CaseInsensitiveModelBackend(ModelBackend):
Args:
username (str, optional): Name of user to authenticate.
password (str, optional): Password of user
autologin (Player, optional): If given, assume this is
an already authenticated player and bypass authentication.
autologin (Account, optional): If given, assume this is
an already authenticated account and bypass authentication.
"""
if autologin:
# Note: Setting .backend on player is critical in order to
# be allowed to call django.auth.login(player) later. This
# Note: Setting .backend on account is critical in order to
# be allowed to call django.auth.login(account) later. This
# is necessary for the auto-login feature of the webclient,
# but it's important to make sure Django doesn't change this
# requirement or the name of the property down the line. /Griatch
@ -29,12 +29,12 @@ class CaseInsensitiveModelBackend(ModelBackend):
else:
# In this case .backend will be assigned automatically
# somewhere along the way.
Player = get_user_model()
Account = get_user_model()
try:
player = Player.objects.get(username__iexact=username)
if player.check_password(password):
return player
account = Account.objects.get(username__iexact=username)
if account.check_password(password):
return account
else:
return None
except Player.DoesNotExist:
except Account.DoesNotExist:
return None

View file

@ -25,7 +25,7 @@ except AttributeError:
# Setup lists of the most relevant apps so
# the adminsite becomes more readable.
PLAYER_RELATED = ['Players']
ACCOUNT_RELATED = ['Accounts']
GAME_ENTITIES = ['Objects', 'Scripts', 'Comms', 'Help']
GAME_SETUP = ['Permissions', 'Config']
CONNECTIONS = ['Irc']
@ -46,7 +46,7 @@ def general_context(request):
return {
'game_name': GAME_NAME,
'game_slogan': GAME_SLOGAN,
'evennia_userapps': PLAYER_RELATED,
'evennia_userapps': ACCOUNT_RELATED,
'evennia_entityapps': GAME_ENTITIES,
'evennia_setupapps': GAME_SETUP,
'evennia_connectapps': CONNECTIONS,

View file

@ -8,7 +8,7 @@ from __future__ import print_function
from django.shortcuts import render
from django.contrib.auth import login, authenticate
from evennia.players.models import PlayerDB
from evennia.accounts.models import AccountDB
from evennia.utils import logger
@ -18,24 +18,24 @@ def _shared_login(request):
"""
csession = request.session
player = request.user
account = request.user
sesslogin = csession.get("logged_in", None)
# check if user has authenticated to website
if csession.session_key is None:
# this is necessary to build the sessid key
csession.save()
elif player.is_authenticated():
elif account.is_authenticated():
if not sesslogin:
# User has already authenticated to website
csession["logged_in"] = player.id
csession["logged_in"] = account.id
elif sesslogin:
# The webclient has previously registered a login to this browser_session
player = PlayerDB.objects.get(id=sesslogin)
account = AccountDB.objects.get(id=sesslogin)
try:
# calls our custom authenticate in web/utils/backends.py
player = authenticate(autologin=player)
login(request, player)
account = authenticate(autologin=account)
login(request, account)
except AttributeError:
logger.log_trace()

View file

@ -13,7 +13,7 @@ from django.shortcuts import render
from evennia import SESSION_HANDLER
from evennia.objects.models import ObjectDB
from evennia.players.models import PlayerDB
from evennia.accounts.models import AccountDB
from evennia.utils import logger
from django.contrib.auth import login
@ -27,22 +27,22 @@ def _shared_login(request):
"""
csession = request.session
player = request.user
account = request.user
sesslogin = csession.get("logged_in", None)
if csession.session_key is None:
# this is necessary to build the sessid key
csession.save()
elif player.is_authenticated():
elif account.is_authenticated():
if not sesslogin:
csession["logged_in"] = player.id
csession["logged_in"] = account.id
elif sesslogin:
# The webclient has previously registered a login to this csession
player = PlayerDB.objects.get(id=sesslogin)
account = AccountDB.objects.get(id=sesslogin)
try:
# calls our custom authenticate, in web/utils/backend.py
authenticate(autologin=player)
login(request, player)
authenticate(autologin=account)
login(request, account)
except AttributeError:
logger.log_trace()
@ -50,15 +50,15 @@ def _shared_login(request):
def _gamestats():
# Some misc. configurable stuff.
# TODO: Move this to either SQL or settings.py based configuration.
fpage_player_limit = 4
fpage_account_limit = 4
# A QuerySet of the most recently connected players.
recent_users = PlayerDB.objects.get_recently_connected_players()[:fpage_player_limit]
# A QuerySet of the most recently connected accounts.
recent_users = AccountDB.objects.get_recently_connected_accounts()[:fpage_account_limit]
nplyrs_conn_recent = len(recent_users) or "none"
nplyrs = PlayerDB.objects.num_total_players() or "none"
nplyrs_reg_recent = len(PlayerDB.objects.get_recently_created_players()) or "none"
nsess = SESSION_HANDLER.player_count()
# nsess = len(PlayerDB.objects.get_connected_players()) or "no one"
nplyrs = AccountDB.objects.num_total_accounts() or "none"
nplyrs_reg_recent = len(AccountDB.objects.get_recently_created_accounts()) or "none"
nsess = SESSION_HANDLER.account_count()
# nsess = len(AccountDB.objects.get_connected_accounts()) or "no one"
nobjs = ObjectDB.objects.all().count()
nrooms = ObjectDB.objects.filter(db_location__isnull=True).exclude(db_typeclass_path=_BASE_CHAR_TYPECLASS).count()
@ -68,11 +68,11 @@ def _gamestats():
pagevars = {
"page_title": "Front Page",
"players_connected_recent": recent_users,
"num_players_connected": nsess or "no one",
"num_players_registered": nplyrs or "no",
"num_players_connected_recent": nplyrs_conn_recent or "no",
"num_players_registered_recent": nplyrs_reg_recent or "no one",
"accounts_connected_recent": recent_users,
"num_accounts_connected": nsess or "no one",
"num_accounts_registered": nplyrs or "no",
"num_accounts_connected_recent": nplyrs_conn_recent or "no",
"num_accounts_registered_recent": nplyrs_reg_recent or "no one",
"num_rooms": nrooms or "none",
"num_exits": nexits or "no",
"num_objects": nobjs or "none",
@ -116,7 +116,7 @@ def evennia_admin(request):
"""
return render(
request, 'evennia_admin.html', {
'playerdb': PlayerDB})
'accountdb': AccountDB})
def admin_wrapper(request):