Update CHANGELOG, pep8 fixes

This commit is contained in:
Griatch 2018-10-23 01:04:25 +02:00
parent 0b6d869902
commit b6b07ccdb5
10 changed files with 290 additions and 264 deletions

View file

@ -10,6 +10,30 @@
- Add the Portal uptime to the `@time` command. - Add the Portal uptime to the `@time` command.
- Make the `@link` command first make a local search before a global search. - Make the `@link` command first make a local search before a global search.
### Typeclasses
- Add new methods on all typeclasses, useful specifically for viewing the object in the web/admin:
+ `web_get_admin_url()`: Returns a path that, if followed, will display the object in the Admin backend.
+ `web_get_create_url()`: Returns a path for a view allowing the creation of new instances of this object.
+ `web_get_absolute_url()`: Django construct; returns a path that should display the object in a DetailView.
+ `web_get_update_url()`: Returns a path that should display the object in an UpdateView.
+ `web_get_delete_url()`: Returns a path that should display the object in a DeleteView.
- All typeclasses has new helper class method `create`, which encompasses useful functionality
that used to be embedded for example in the respective `@create` or `@connect` commands.
- DefaultAccount now has new class methods implementing many things that used to be in unloggedin
commands (these can now be customized on the class instead):
+ `is_banned()`: Checks if a given username or IP is banned.
+ `get_username_validators`: Return list of validators for username validation (see
`settings.AUTH_USERNAME_VALIDATORS`)
+ `authenticate`: Method to check given username/password.
+ `normalize_username`: Normalizes names so you can't fake names with similar-looking Unicode
chars.
+ `validate_username`: Mechanism for validating a username.
+ `validate_password`: Mechanism for validating a password.
+ `set_password`: Apply password to account, using validation checks.
### Utils ### Utils
- Added more unit tests. - Added more unit tests.

View file

@ -7,10 +7,8 @@ from unittest import TestCase
from django.test import override_settings from django.test import override_settings
from evennia.accounts.accounts import AccountSessionHandler from evennia.accounts.accounts import AccountSessionHandler
from evennia.accounts.accounts import DefaultAccount, DefaultGuest from evennia.accounts.accounts import DefaultAccount, DefaultGuest
from evennia.server.session import Session
from evennia.utils.test_resources import EvenniaTest from evennia.utils.test_resources import EvenniaTest
from evennia.utils import create from evennia.utils import create
from evennia.utils.test_resources import EvenniaTest
from django.conf import settings from django.conf import settings

View file

@ -2,17 +2,11 @@
Commands that are available from the connect screen. Commands that are available from the connect screen.
""" """
import re import re
import time
import datetime import datetime
from django.conf import settings from django.conf import settings
from django.contrib.auth import authenticate
from evennia.accounts.models import AccountDB
from evennia.objects.models import ObjectDB
from evennia.comms.models import ChannelDB from evennia.comms.models import ChannelDB
from evennia.server.models import ServerConfig
from evennia.server.sessionhandler import SESSIONS from evennia.server.sessionhandler import SESSIONS
from evennia.server.throttle import Throttle
from evennia.utils import class_from_module, create, logger, utils, gametime from evennia.utils import class_from_module, create, logger, utils, gametime
from evennia.commands.cmdhandler import CMD_LOGINSTART from evennia.commands.cmdhandler import CMD_LOGINSTART
@ -26,6 +20,7 @@ __all__ = ("CmdUnconnectedConnect", "CmdUnconnectedCreate",
MULTISESSION_MODE = settings.MULTISESSION_MODE MULTISESSION_MODE = settings.MULTISESSION_MODE
CONNECTION_SCREEN_MODULE = settings.CONNECTION_SCREEN_MODULE CONNECTION_SCREEN_MODULE = settings.CONNECTION_SCREEN_MODULE
def create_guest_account(session): def create_guest_account(session):
""" """
Creates a guest account/character for this session, if one is available. Creates a guest account/character for this session, if one is available.
@ -53,6 +48,7 @@ def create_guest_account(session):
session.msg("|R%s|n" % '\n'.join(errors)) session.msg("|R%s|n" % '\n'.join(errors))
return enabled, None return enabled, None
def create_normal_account(session, name, password): def create_normal_account(session, name, password):
""" """
Creates an account with the given name and password. Creates an account with the given name and password.

View file

@ -1,6 +1,7 @@
from evennia.utils.test_resources import EvenniaTest from evennia.utils.test_resources import EvenniaTest
from evennia import DefaultObject, DefaultCharacter, DefaultRoom, DefaultExit from evennia import DefaultObject, DefaultCharacter, DefaultRoom, DefaultExit
class DefaultObjectTest(EvenniaTest): class DefaultObjectTest(EvenniaTest):
ip = '212.216.139.14' ip = '212.216.139.14'

View file

@ -2,6 +2,7 @@ from collections import defaultdict, deque
from evennia.utils import logger from evennia.utils import logger
import time import time
class Throttle(object): class Throttle(object):
""" """
Keeps a running count of failed actions per IP address. Keeps a running count of failed actions per IP address.
@ -110,5 +111,3 @@ class Throttle(object):
return False return False
else: else:
return False return False

View file

@ -4,6 +4,7 @@ from django.utils.translation import gettext as _
from evennia.accounts.models import AccountDB from evennia.accounts.models import AccountDB
import re import re
class EvenniaUsernameAvailabilityValidator: class EvenniaUsernameAvailabilityValidator:
""" """
Checks to make sure a given username is not taken or otherwise reserved. Checks to make sure a given username is not taken or otherwise reserved.
@ -37,9 +38,12 @@ class EvenniaUsernameAvailabilityValidator:
code='evennia_username_taken', code='evennia_username_taken',
) )
class EvenniaPasswordValidator: class EvenniaPasswordValidator:
def __init__(self, regex=r"^[\w. @+\-',]+$", policy="Password should contain a mix of letters, spaces, digits and @/./+/-/_/'/, only."): def __init__(self, regex=r"^[\w. @+\-',]+$",
policy="Password should contain a mix of letters, "
"spaces, digits and @/./+/-/_/'/, only."):
""" """
Constructs a standard Django password validator. Constructs a standard Django password validator.
@ -82,5 +86,6 @@ class EvenniaPasswordValidator:
""" """
return _( return _(
"%s From a terminal client, you can also use a phrase of multiple words if you enclose the password in double quotes." % self.policy "%s From a terminal client, you can also use a phrase of multiple words if "
"you enclose the password in double quotes." % self.policy
) )

View file

@ -222,7 +222,8 @@ COMMAND_RATE_WARNING = "You entered commands too fast. Wait a moment and try aga
# 0 or less. # 0 or less.
MAX_CHAR_LIMIT = 6000 MAX_CHAR_LIMIT = 6000
# The warning to echo back to users if they enter a very large string # The warning to echo back to users if they enter a very large string
MAX_CHAR_LIMIT_WARNING = "You entered a string that was too long. Please break it up into multiple parts." MAX_CHAR_LIMIT_WARNING = ("You entered a string that was too long. "
"Please break it up into multiple parts.")
# If this is true, errors and tracebacks from the engine will be # If this is true, errors and tracebacks from the engine will be
# echoed as text in-game as well as to the log. This can speed up # echoed as text in-game as well as to the log. This can speed up
# debugging. OBS: Showing full tracebacks to regular users could be a # debugging. OBS: Showing full tracebacks to regular users could be a
@ -410,12 +411,14 @@ CMDSET_CHARACTER = "commands.default_cmdsets.CharacterCmdSet"
CMDSET_ACCOUNT = "commands.default_cmdsets.AccountCmdSet" CMDSET_ACCOUNT = "commands.default_cmdsets.AccountCmdSet"
# Location to search for cmdsets if full path not given # Location to search for cmdsets if full path not given
CMDSET_PATHS = ["commands", "evennia", "contribs"] CMDSET_PATHS = ["commands", "evennia", "contribs"]
# Fallbacks for cmdset paths that fail to load. Note that if you change the path for your default cmdsets, # Fallbacks for cmdset paths that fail to load. Note that if you change the path for your
# you will also need to copy CMDSET_FALLBACKS after your change in your settings file for it to detect the change. # default cmdsets, you will also need to copy CMDSET_FALLBACKS after your change in your
CMDSET_FALLBACKS = {CMDSET_CHARACTER: 'evennia.commands.default.cmdset_character.CharacterCmdSet', # settings file for it to detect the change.
CMDSET_ACCOUNT: 'evennia.commands.default.cmdset_account.AccountCmdSet', CMDSET_FALLBACKS = {
CMDSET_SESSION: 'evennia.commands.default.cmdset_session.SessionCmdSet', CMDSET_CHARACTER: 'evennia.commands.default.cmdset_character.CharacterCmdSet',
CMDSET_UNLOGGEDIN: 'evennia.commands.default.cmdset_unloggedin.UnloggedinCmdSet'} CMDSET_ACCOUNT: 'evennia.commands.default.cmdset_account.AccountCmdSet',
CMDSET_SESSION: 'evennia.commands.default.cmdset_session.SessionCmdSet',
CMDSET_UNLOGGEDIN: 'evennia.commands.default.cmdset_unloggedin.UnloggedinCmdSet'}
# Parent class for all default commands. Changing this class will # Parent class for all default commands. Changing this class will
# modify all default commands, so do so carefully. # modify all default commands, so do so carefully.
COMMAND_DEFAULT_CLASS = "evennia.commands.default.muxcommand.MuxCommand" COMMAND_DEFAULT_CLASS = "evennia.commands.default.muxcommand.MuxCommand"
@ -830,7 +833,7 @@ TEST_RUNNER = 'evennia.server.tests.EvenniaTestSuiteRunner'
# Django extesions are useful third-party tools that are not # Django extesions are useful third-party tools that are not
# always included in the default django distro. # always included in the default django distro.
try: try:
import django_extensions import django_extensions # noqa
INSTALLED_APPS = INSTALLED_APPS + ('django_extensions',) INSTALLED_APPS = INSTALLED_APPS + ('django_extensions',)
except ImportError: except ImportError:
# Django extensions are not installed in all distros. # Django extensions are not installed in all distros.