Merge.
This commit is contained in:
commit
71346dcc67
5 changed files with 57 additions and 44 deletions
|
|
@ -666,7 +666,6 @@ class CmdDig(ObjManipCommand):
|
||||||
if not typeclass:
|
if not typeclass:
|
||||||
typeclass = settings.BASE_EXIT_TYPECLASS
|
typeclass = settings.BASE_EXIT_TYPECLASS
|
||||||
|
|
||||||
print typeclass, to_exit["name"], location, to_exit["aliases"],lockstring, new_room, caller
|
|
||||||
new_to_exit = create.create_object(typeclass, to_exit["name"], location,
|
new_to_exit = create.create_object(typeclass, to_exit["name"], location,
|
||||||
aliases=to_exit["aliases"],
|
aliases=to_exit["aliases"],
|
||||||
locks=lockstring, destination=new_room, report_to=caller)
|
locks=lockstring, destination=new_room, report_to=caller)
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
#
|
#
|
||||||
# This sets up how models are displayed
|
# This sets up how models are displayed
|
||||||
# in the web admin interface.
|
# in the web admin interface.
|
||||||
#
|
#
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
||||||
from django.contrib.admin import widgets
|
from django.contrib.admin import widgets
|
||||||
|
|
@ -13,39 +13,39 @@ from django.contrib.auth.forms import UserChangeForm, UserCreationForm
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from src.players.models import PlayerDB, PlayerAttribute
|
from src.players.models import PlayerDB, PlayerAttribute
|
||||||
from src.utils import logger, create
|
from src.utils import logger, create
|
||||||
|
|
||||||
# remove User itself from admin site
|
# remove User itself from admin site
|
||||||
admin.site.unregister(User)
|
admin.site.unregister(User)
|
||||||
|
|
||||||
# handle the custom User editor
|
# handle the custom User editor
|
||||||
class CustomUserChangeForm(UserChangeForm):
|
class CustomUserChangeForm(UserChangeForm):
|
||||||
username = forms.RegexField(label="Username",
|
username = forms.RegexField(label="Username",
|
||||||
max_length=30,
|
max_length=30,
|
||||||
regex=r'^[\w. @+-]+$',
|
regex=r'^[\w. @+-]+$',
|
||||||
widget=forms.TextInput(attrs={'size':'30'}),
|
widget=forms.TextInput(attrs={'size':'30'}),
|
||||||
error_messages = {'invalid': "This value may contain only letters, spaces, numbers and @/./+/-/_ characters."},
|
error_messages = {'invalid': "This value may contain only letters, spaces, numbers and @/./+/-/_ characters."},
|
||||||
help_text = "30 characters or fewer. Letters, spaces, digits and @/./+/-/_ only.")
|
help_text = "30 characters or fewer. Letters, spaces, digits and @/./+/-/_ only.")
|
||||||
|
|
||||||
class CustomUserCreationForm(UserCreationForm):
|
class CustomUserCreationForm(UserCreationForm):
|
||||||
username = forms.RegexField(label="Username",
|
username = forms.RegexField(label="Username",
|
||||||
max_length=30,
|
max_length=30,
|
||||||
regex=r'^[\w. @+-]+$',
|
regex=r'^[\w. @+-]+$',
|
||||||
widget=forms.TextInput(attrs={'size':'30'}),
|
widget=forms.TextInput(attrs={'size':'30'}),
|
||||||
error_messages = {'invalid': "This value may contain only letters, spaces, numbers and @/./+/-/_ characters."},
|
error_messages = {'invalid': "This value may contain only letters, spaces, numbers and @/./+/-/_ characters."},
|
||||||
help_text = "30 characters or fewer. Letters, spaces, digits and @/./+/-/_ only.")
|
help_text = "30 characters or fewer. Letters, spaces, digits and @/./+/-/_ only.")
|
||||||
|
|
||||||
# # The Player editor
|
# # The Player editor
|
||||||
# class PlayerAttributeForm(forms.ModelForm):
|
# class PlayerAttributeForm(forms.ModelForm):
|
||||||
# "Defines how to display the atttributes"
|
# "Defines how to display the atttributes"
|
||||||
# class Meta:
|
# class Meta:
|
||||||
# model = PlayerAttribute
|
# model = PlayerAttribute
|
||||||
# db_key = forms.CharField(label="Key",
|
# db_key = forms.CharField(label="Key",
|
||||||
# widget=forms.TextInput(attrs={'size':'15'}))
|
# widget=forms.TextInput(attrs={'size':'15'}))
|
||||||
# db_value = forms.CharField(label="Value",
|
# db_value = forms.CharField(label="Value",
|
||||||
# widget=forms.Textarea(attrs={'rows':'2'}))
|
# widget=forms.Textarea(attrs={'rows':'2'}))
|
||||||
|
|
||||||
# class PlayerAttributeInline(admin.TabularInline):
|
# class PlayerAttributeInline(admin.TabularInline):
|
||||||
# "Inline creation of player attributes"
|
# "Inline creation of player attributes"
|
||||||
# model = PlayerAttribute
|
# model = PlayerAttribute
|
||||||
# extra = 0
|
# extra = 0
|
||||||
# form = PlayerAttributeForm
|
# form = PlayerAttributeForm
|
||||||
|
|
@ -57,34 +57,34 @@ class PlayerForm(forms.ModelForm):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PlayerDB
|
model = PlayerDB
|
||||||
db_key = forms.RegexField(label="Username",
|
db_key = forms.RegexField(label="Username",
|
||||||
initial="PlayerDummy",
|
initial="PlayerDummy",
|
||||||
max_length=30,
|
max_length=30,
|
||||||
regex=r'^[\w. @+-]+$',
|
regex=r'^[\w. @+-]+$',
|
||||||
required=False,
|
required=False,
|
||||||
widget=forms.TextInput(attrs={'size':'30'}),
|
widget=forms.TextInput(attrs={'size':'30'}),
|
||||||
error_messages = {'invalid': "This value may contain only letters, spaces, numbers and @/./+/-/_ characters."},
|
error_messages = {'invalid': "This value may contain only letters, spaces, numbers and @/./+/-/_ characters."},
|
||||||
help_text = "This should be the same as the connected Player's key name. 30 characters or fewer. Letters, spaces, digits and @/./+/-/_ only.")
|
help_text = "This should be the same as the connected Player's key name. 30 characters or fewer. Letters, spaces, digits and @/./+/-/_ only.")
|
||||||
|
|
||||||
db_typeclass_path = forms.CharField(label="Typeclass",
|
db_typeclass_path = forms.CharField(label="Typeclass",
|
||||||
initial=settings.BASE_PLAYER_TYPECLASS,
|
initial=settings.BASE_PLAYER_TYPECLASS,
|
||||||
widget=forms.TextInput(attrs={'size':'78'}),
|
widget=forms.TextInput(attrs={'size':'78'}),
|
||||||
help_text="Required. Defines what 'type' of entity this is. This variable holds a Python path to a module with a valid Evennia Typeclass. Defaults to settings.BASE_PLAYER_TYPECLASS.")
|
help_text="Required. Defines what 'type' of entity this is. This variable holds a Python path to a module with a valid Evennia Typeclass. Defaults to settings.BASE_PLAYER_TYPECLASS.")
|
||||||
db_permissions = forms.CharField(label="Permissions",
|
db_permissions = forms.CharField(label="Permissions",
|
||||||
initial=settings.PERMISSION_PLAYER_DEFAULT,
|
initial=settings.PERMISSION_PLAYER_DEFAULT,
|
||||||
required=False,
|
required=False,
|
||||||
widget=forms.TextInput(attrs={'size':'78'}),
|
widget=forms.TextInput(attrs={'size':'78'}),
|
||||||
help_text="In-game permissions. A comma-separated list of text strings checked by certain locks. They are often used for hierarchies, such as letting a Player have permission 'Wizards', 'Builders' etc. A Player permission can be overloaded by the permissions of a controlled Character. Normal players use 'Players' by default.")
|
help_text="In-game permissions. A comma-separated list of text strings checked by certain locks. They are often used for hierarchies, such as letting a Player have permission 'Wizards', 'Builders' etc. A Player permission can be overloaded by the permissions of a controlled Character. Normal players use 'Players' by default.")
|
||||||
db_lock_storage = forms.CharField(label="Locks",
|
db_lock_storage = forms.CharField(label="Locks",
|
||||||
widget=forms.Textarea(attrs={'cols':'100', 'rows':'2'}),
|
widget=forms.Textarea(attrs={'cols':'100', 'rows':'2'}),
|
||||||
required=False,
|
required=False,
|
||||||
help_text="In-game lock definition string. If not given, defaults will be used. This string should be on the form <i>type:lockfunction(args);type2:lockfunction2(args);...")
|
help_text="In-game lock definition string. If not given, defaults will be used. This string should be on the form <i>type:lockfunction(args);type2:lockfunction2(args);...")
|
||||||
db_cmdset_storage = forms.CharField(label="cmdset",
|
db_cmdset_storage = forms.CharField(label="cmdset",
|
||||||
initial=settings.CMDSET_OOC,
|
initial=settings.CMDSET_OOC,
|
||||||
widget=forms.TextInput(attrs={'size':'78'}),
|
widget=forms.TextInput(attrs={'size':'78'}),
|
||||||
required=False,
|
required=False,
|
||||||
help_text="python path to player cmdset class (settings.CMDSET_OOC by default)")
|
help_text="python path to player cmdset class (settings.CMDSET_OOC by default)")
|
||||||
|
|
||||||
class PlayerInline(admin.StackedInline):
|
class PlayerInline(admin.StackedInline):
|
||||||
"Inline creation of Player"
|
"Inline creation of Player"
|
||||||
model = PlayerDB
|
model = PlayerDB
|
||||||
|
|
@ -100,11 +100,11 @@ class PlayerInline(admin.StackedInline):
|
||||||
("Evennia In-game Character",
|
("Evennia In-game Character",
|
||||||
{'fields':('db_obj',),
|
{'fields':('db_obj',),
|
||||||
'description': "<i>To actually play the game, a Player must control a Character. This could be added in-game instead of from here if some sort of character creation system is in play. If not, you should normally create a new Character here rather than assigning an existing one. Observe that the admin does not check for puppet-access rights when assigning Characters! If not creating a new Character, make sure the one you assign is not puppeted by someone else!</i>"}))
|
'description': "<i>To actually play the game, a Player must control a Character. This could be added in-game instead of from here if some sort of character creation system is in play. If not, you should normally create a new Character here rather than assigning an existing one. Observe that the admin does not check for puppet-access rights when assigning Characters! If not creating a new Character, make sure the one you assign is not puppeted by someone else!</i>"}))
|
||||||
|
|
||||||
|
|
||||||
extra = 1
|
extra = 1
|
||||||
max_num = 1
|
max_num = 1
|
||||||
|
|
||||||
class UserAdmin(BaseUserAdmin):
|
class UserAdmin(BaseUserAdmin):
|
||||||
"This is the main creation screen for Users/players"
|
"This is the main creation screen for Users/players"
|
||||||
|
|
||||||
|
|
@ -126,23 +126,30 @@ class UserAdmin(BaseUserAdmin):
|
||||||
|
|
||||||
|
|
||||||
add_fieldsets = (
|
add_fieldsets = (
|
||||||
(None,
|
(None,
|
||||||
{'fields': ('username', 'password1', 'password2', 'email'),
|
{'fields': ('username', 'password1', 'password2', 'email'),
|
||||||
'description':"<i>These account details are shared by the admin system and the game.</i>"},),)
|
'description':"<i>These account details are shared by the admin system and the game.</i>"},),)
|
||||||
|
|
||||||
def save_formset(self, request, form, formset, change):
|
def save_formset(self, request, form, formset, change):
|
||||||
"Run all hooks on the player object"
|
"Run all hooks on the player object"
|
||||||
super(UserAdmin, self).save_formset(request, form, formset, change)
|
super(UserAdmin, self).save_formset(request, form, formset, change)
|
||||||
playerdb = form.instance.get_profile()
|
userobj = form.instance
|
||||||
if not change:
|
playerobj = userobj.get_profile()
|
||||||
create.create_player("", "", "",
|
if not change:
|
||||||
typeclass=playerdb.db_typeclass_path,
|
#uname, passwd, email = str(request.POST.get(u"username")), \
|
||||||
create_character=False,
|
# str(request.POST.get(u"password1")), str(request.POST.get(u"email"))
|
||||||
player_dbobj=playerdb)
|
typeclass = str(request.POST.get(u"playerdb_set-0-db_typeclass_path"))
|
||||||
if playerdb.db_obj:
|
|
||||||
playerdb.db_obj.db_player = playerdb
|
create.create_player("","","",
|
||||||
playerdb.db_obj.save()
|
user=userobj,
|
||||||
|
typeclass=typeclass,
|
||||||
|
player_dbobj=playerobj,
|
||||||
|
create_character=False)
|
||||||
|
|
||||||
|
# if playerdb.db_obj:
|
||||||
|
# playerdb.db_obj.db_player = playerdb
|
||||||
|
# playerdb.db_obj.save()
|
||||||
|
|
||||||
#assert False, (form.instance, form.instance.get_profile())
|
#assert False, (form.instance, form.instance.get_profile())
|
||||||
|
|
||||||
admin.site.register(User, UserAdmin)
|
admin.site.register(User, UserAdmin)
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,6 @@ from django.utils.encoding import smart_str
|
||||||
|
|
||||||
from src.server.caches import get_field_cache, set_field_cache, del_field_cache
|
from src.server.caches import get_field_cache, set_field_cache, del_field_cache
|
||||||
from src.server.caches import get_prop_cache, set_prop_cache, del_prop_cache
|
from src.server.caches import get_prop_cache, set_prop_cache, del_prop_cache
|
||||||
from src.server.sessionhandler import SESSIONS
|
|
||||||
from src.players import manager
|
from src.players import manager
|
||||||
from src.typeclasses.models import Attribute, TypedObject, TypeNick, TypeNickHandler
|
from src.typeclasses.models import Attribute, TypedObject, TypeNick, TypeNickHandler
|
||||||
from src.typeclasses.typeclass import TypeClass
|
from src.typeclasses.typeclass import TypeClass
|
||||||
|
|
@ -58,6 +57,7 @@ from src.utils.utils import inherits_from
|
||||||
|
|
||||||
__all__ = ("PlayerAttribute", "PlayerNick", "PlayerDB")
|
__all__ = ("PlayerAttribute", "PlayerNick", "PlayerDB")
|
||||||
|
|
||||||
|
_SESSIONS = None
|
||||||
_AT_SEARCH_RESULT = utils.variable_from_module(*settings.SEARCH_AT_RESULT.rsplit('.', 1))
|
_AT_SEARCH_RESULT = utils.variable_from_module(*settings.SEARCH_AT_RESULT.rsplit('.', 1))
|
||||||
|
|
||||||
_GA = object.__getattribute__
|
_GA = object.__getattribute__
|
||||||
|
|
@ -340,7 +340,10 @@ class PlayerDB(TypedObject):
|
||||||
#@property
|
#@property
|
||||||
def sessions_get(self):
|
def sessions_get(self):
|
||||||
"Getter. Retrieve sessions related to this player/user"
|
"Getter. Retrieve sessions related to this player/user"
|
||||||
return SESSIONS.sessions_from_player(self)
|
global _SESSIONS
|
||||||
|
if not _SESSIONS:
|
||||||
|
from src.server.sessionhandler import SESSIONS as _SESSIONS
|
||||||
|
return _SESSIONS.sessions_from_player(self)
|
||||||
#@sessions.setter
|
#@sessions.setter
|
||||||
def sessions_set(self, value):
|
def sessions_set(self, value):
|
||||||
"Setter. Protects the sessions property from adding things"
|
"Setter. Protects the sessions property from adding things"
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ from twisted.internet.defer import maybeDeferred
|
||||||
from twisted.internet.task import LoopingCall
|
from twisted.internet.task import LoopingCall
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from src.server import caches
|
from src.server import caches
|
||||||
from src.server.sessionhandler import SESSIONS
|
|
||||||
from src.typeclasses.typeclass import TypeClass
|
from src.typeclasses.typeclass import TypeClass
|
||||||
from src.scripts.models import ScriptDB
|
from src.scripts.models import ScriptDB
|
||||||
from src.comms import channelhandler
|
from src.comms import channelhandler
|
||||||
|
|
@ -23,6 +22,7 @@ __all__ = ["Script", "DoNothing", "CheckSessions", "ValidateScripts", "ValidateC
|
||||||
if not is_pypy:
|
if not is_pypy:
|
||||||
__all__.append("ClearAttributeCache")
|
__all__.append("ClearAttributeCache")
|
||||||
|
|
||||||
|
_SESSIONS = None
|
||||||
_ATTRIBUTE_CACHE_MAXSIZE = settings.ATTRIBUTE_CACHE_MAXSIZE # attr-cache size in MB.
|
_ATTRIBUTE_CACHE_MAXSIZE = settings.ATTRIBUTE_CACHE_MAXSIZE # attr-cache size in MB.
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
@ -416,9 +416,12 @@ class CheckSessions(Script):
|
||||||
|
|
||||||
def at_repeat(self):
|
def at_repeat(self):
|
||||||
"called every 60 seconds"
|
"called every 60 seconds"
|
||||||
|
global _SESSIONS
|
||||||
|
if not _SESSIONS:
|
||||||
|
from src.server.sessionhandler import SESSIONS as _SESSIONS
|
||||||
#print "session check!"
|
#print "session check!"
|
||||||
#print "ValidateSessions run"
|
#print "ValidateSessions run"
|
||||||
SESSIONS.validate_sessions()
|
_SESSIONS.validate_sessions()
|
||||||
|
|
||||||
class ValidateScripts(Script):
|
class ValidateScripts(Script):
|
||||||
"Check script validation regularly"
|
"Check script validation regularly"
|
||||||
|
|
|
||||||
|
|
@ -469,6 +469,7 @@ def create_player(name, email, password,
|
||||||
# use the typeclass from this object
|
# use the typeclass from this object
|
||||||
typeclass = new_db_player.typeclass_path
|
typeclass = new_db_player.typeclass_path
|
||||||
else:
|
else:
|
||||||
|
new_user = User.objects.get(username=new_user.username)
|
||||||
new_db_player = _PlayerDB(db_key=name, user=new_user)
|
new_db_player = _PlayerDB(db_key=name, user=new_user)
|
||||||
new_db_player.save()
|
new_db_player.save()
|
||||||
# assign the typeclass
|
# assign the typeclass
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue