Make PEP8 cleanup of line spaces and character distances as well as indents

This commit is contained in:
Griatch 2017-08-19 23:16:36 +02:00
parent 7ff783fea1
commit b278337172
189 changed files with 2039 additions and 1583 deletions

View file

@ -4,4 +4,3 @@ Django to relate the database contents to web pages. Also the basic
webclient and the website are defined in here (the webserver itself is
found under the `server` package).
"""

View file

@ -14,11 +14,11 @@ from django.views.generic import RedirectView
urlpatterns = [
# Front page (note that we shouldn't specify namespace here since we will
# not be able to load django-auth/admin stuff (will probably work in Django>1.9)
url(r'^', include('evennia.web.website.urls')),#, namespace='website', app_name='website')),
url(r'^', include('evennia.web.website.urls')), # , namespace='website', app_name='website')),
# webclient
url(r'^webclient/', include('evennia.web.webclient.urls', namespace='webclient', app_name='webclient')),
# favicon
url(r'^favicon\.ico$', RedirectView.as_view(url='/media/images/favicon.ico', permanent=False))
]
url(r'^favicon\.ico$', RedirectView.as_view(url='/media/images/favicon.ico', permanent=False))
]

View file

@ -1,40 +1,42 @@
from django.contrib.auth.backends import ModelBackend
from django.contrib.auth import get_user_model
class CaseInsensitiveModelBackend(ModelBackend):
"""
By default ModelBackend does case _sensitive_ username
authentication, which isn't what is generally expected. This
backend supports case insensitive username authentication.
"""
By default ModelBackend does case _sensitive_ username
authentication, which isn't what is generally expected. This
backend supports case insensitive username authentication.
"""
def authenticate(self, username=None, password=None, autologin=None):
"""
Custom authenticate with bypass for auto-logins
"""
Args:
username (str, optional): Name of user to authenticate.
password (str, optional): Password of user
autologin (Account, optional): If given, assume this is
an already authenticated account and bypass authentication.
"""
if autologin:
# 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
autologin.backend = "evennia.web.utils.backends.CaseInsensitiveModelBackend"
return autologin
else:
# In this case .backend will be assigned automatically
# somewhere along the way.
Account = get_user_model()
try:
account = Account.objects.get(username__iexact=username)
if account.check_password(password):
return account
else:
return None
except Account.DoesNotExist:
return None
def authenticate(self, username=None, password=None, autologin=None):
"""
Custom authenticate with bypass for auto-logins
Args:
username (str, optional): Name of user to authenticate.
password (str, optional): Password of user
autologin (Account, optional): If given, assume this is
an already authenticated account and bypass authentication.
"""
if autologin:
# 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
autologin.backend = "evennia.web.utils.backends.CaseInsensitiveModelBackend"
return autologin
else:
# In this case .backend will be assigned automatically
# somewhere along the way.
Account = get_user_model()
try:
account = Account.objects.get(username__iexact=username)
if account.check_password(password):
return account
else:
return None
except Account.DoesNotExist:
return None

View file

@ -38,6 +38,7 @@ WEBSOCKET_CLIENT_ENABLED = settings.WEBSOCKET_CLIENT_ENABLED
WEBSOCKET_PORT = settings.WEBSOCKET_CLIENT_PORT
WEBSOCKET_URL = settings.WEBSOCKET_CLIENT_URL
def general_context(request):
"""
Returns common Evennia-related context stuff, which
@ -50,9 +51,9 @@ def general_context(request):
'evennia_entityapps': GAME_ENTITIES,
'evennia_setupapps': GAME_SETUP,
'evennia_connectapps': CONNECTIONS,
'evennia_websiteapps':WEBSITE,
"webclient_enabled" : WEBCLIENT_ENABLED,
"websocket_enabled" : WEBSOCKET_CLIENT_ENABLED,
"websocket_port" : WEBSOCKET_PORT,
"websocket_url" : WEBSOCKET_URL
'evennia_websiteapps': WEBSITE,
"webclient_enabled": WEBCLIENT_ENABLED,
"websocket_enabled": WEBSOCKET_CLIENT_ENABLED,
"websocket_port": WEBSOCKET_PORT,
"websocket_url": WEBSOCKET_URL
}

View file

@ -6,4 +6,4 @@ from django.conf.urls import *
from evennia.web.webclient import views as webclient_views
urlpatterns = [
url(r'^$', webclient_views.webclient, name="index")]
url(r'^$', webclient_views.webclient, name="index")]

View file

@ -2,6 +2,7 @@ from django import template
register = template.Library()
@register.filter(name='addclass')
def addclass(field, given_class):
existing_classes = field.field.widget.attrs.get('class', None)

View file

@ -14,19 +14,19 @@ from evennia.web.website import views as website_views
admin.autodiscover()
urlpatterns = [
url(r'^$', website_views.page_index, name="index"),
url(r'^tbi/', website_views.to_be_implemented, name='to_be_implemented'),
url(r'^$', website_views.page_index, name="index"),
url(r'^tbi/', website_views.to_be_implemented, name='to_be_implemented'),
# User Authentication (makes login/logout url names available)
url(r'^authenticate', include('django.contrib.auth.urls')),
# User Authentication (makes login/logout url names available)
url(r'^authenticate', include('django.contrib.auth.urls')),
# Django original admin page. Make this URL is always available, whether
# we've chosen to use Evennia's custom admin or not.
url(r'django_admin/', website_views.admin_wrapper, name="django_admin"),
# Django original admin page. Make this URL is always available, whether
# we've chosen to use Evennia's custom admin or not.
url(r'django_admin/', website_views.admin_wrapper, name="django_admin"),
# Admin docs
url(r'^admin/doc/', include('django.contrib.admindocs.urls'))
]
# Admin docs
url(r'^admin/doc/', include('django.contrib.admindocs.urls'))
]
if settings.EVENNIA_ADMIN:
urlpatterns += [