Make evennia lib importable without created gamedir
This commit is contained in:
parent
2227f16e17
commit
5aed34c844
9 changed files with 62 additions and 32 deletions
|
|
@ -52,7 +52,8 @@ class AccountForm(UserCreationForm):
|
|||
"""
|
||||
|
||||
# The model/typeclass this form creates
|
||||
model = class_from_module(settings.BASE_ACCOUNT_TYPECLASS)
|
||||
model = class_from_module(settings.BASE_ACCOUNT_TYPECLASS,
|
||||
fallback=settings.FALLBACK_ACCOUNT_TYPECLASS)
|
||||
|
||||
# The fields to display on the form, in the given order
|
||||
fields = ("username", "email")
|
||||
|
|
@ -87,7 +88,8 @@ class ObjectForm(EvenniaForm, ModelForm):
|
|||
"""
|
||||
|
||||
# The model/typeclass this form creates
|
||||
model = class_from_module(settings.BASE_OBJECT_TYPECLASS)
|
||||
model = class_from_module(settings.BASE_OBJECT_TYPECLASS,
|
||||
fallback=settings.FALLBACK_OBJECT_TYPECLASS)
|
||||
|
||||
# The fields to display on the form, in the given order
|
||||
fields = ("db_key",)
|
||||
|
|
@ -140,7 +142,8 @@ class CharacterForm(ObjectForm):
|
|||
"""
|
||||
|
||||
# Get the correct object model
|
||||
model = class_from_module(settings.BASE_CHARACTER_TYPECLASS)
|
||||
model = class_from_module(settings.BASE_CHARACTER_TYPECLASS,
|
||||
fallback=settings.FALLBACK_CHARACTER_TYPECLASS)
|
||||
|
||||
# Allow entry of the 'key' field
|
||||
fields = ("db_key",)
|
||||
|
|
|
|||
|
|
@ -125,7 +125,8 @@ class ChannelDetailTest(EvenniaWebTest):
|
|||
def setUp(self):
|
||||
super(ChannelDetailTest, self).setUp()
|
||||
|
||||
klass = class_from_module(self.channel_typeclass)
|
||||
klass = class_from_module(self.channel_typeclass,
|
||||
fallback=settings.FALLBACK_CHANNEL_TYPECLASS)
|
||||
|
||||
# Create a channel
|
||||
klass.create("demo")
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ from django.utils.text import slugify
|
|||
|
||||
_BASE_CHAR_TYPECLASS = settings.BASE_CHARACTER_TYPECLASS
|
||||
|
||||
# typeclass fallbacks
|
||||
|
||||
def _gamestats():
|
||||
# Some misc. configurable stuff.
|
||||
|
|
@ -48,11 +49,14 @@ def _gamestats():
|
|||
|
||||
nobjs = ObjectDB.objects.count()
|
||||
nobjs = nobjs or 1 # fix zero-div error with empty database
|
||||
Character = class_from_module(settings.BASE_CHARACTER_TYPECLASS)
|
||||
Character = class_from_module(settings.BASE_CHARACTER_TYPECLASS,
|
||||
fallback=settings.FALLBACK_CHARACTER_TYPECLASS)
|
||||
nchars = Character.objects.all_family().count()
|
||||
Room = class_from_module(settings.BASE_ROOM_TYPECLASS)
|
||||
Room = class_from_module(settings.BASE_ROOM_TYPECLASS,
|
||||
fallback=settings.FALLBACK_ROOM_TYPECLASS)
|
||||
nrooms = Room.objects.all_family().count()
|
||||
Exit = class_from_module(settings.BASE_EXIT_TYPECLASS)
|
||||
Exit = class_from_module(settings.BASE_EXIT_TYPECLASS,
|
||||
fallback=settings.FALLBACK_EXIT_TYPECLASS)
|
||||
nexits = Exit.objects.all_family().count()
|
||||
nothers = nobjs - nchars - nrooms - nexits
|
||||
|
||||
|
|
@ -269,7 +273,8 @@ class ObjectDetailView(EvenniaDetailView):
|
|||
#
|
||||
# So when you extend it, this line should look simple, like:
|
||||
# model = Object
|
||||
model = class_from_module(settings.BASE_OBJECT_TYPECLASS)
|
||||
model = class_from_module(settings.BASE_OBJECT_TYPECLASS,
|
||||
fallback=settings.FALLBACK_OBJECT_TYPECLASS)
|
||||
|
||||
# What HTML template you wish to use to display this page.
|
||||
template_name = "website/object_detail.html"
|
||||
|
|
@ -372,7 +377,8 @@ class ObjectCreateView(LoginRequiredMixin, EvenniaCreateView):
|
|||
|
||||
"""
|
||||
|
||||
model = class_from_module(settings.BASE_OBJECT_TYPECLASS)
|
||||
model = class_from_module(settings.BASE_OBJECT_TYPECLASS,
|
||||
fallback=settings.FALLBACK_OBJECT_TYPECLASS)
|
||||
|
||||
|
||||
class ObjectDeleteView(LoginRequiredMixin, ObjectDetailView, EvenniaDeleteView):
|
||||
|
|
@ -387,7 +393,8 @@ class ObjectDeleteView(LoginRequiredMixin, ObjectDetailView, EvenniaDeleteView):
|
|||
"""
|
||||
|
||||
# -- Django constructs --
|
||||
model = class_from_module(settings.BASE_OBJECT_TYPECLASS)
|
||||
model = class_from_module(settings.BASE_OBJECT_TYPECLASS,
|
||||
fallback=settings.FALLBACK_OBJECT_TYPECLASS)
|
||||
template_name = "website/object_confirm_delete.html"
|
||||
|
||||
# -- Evennia constructs --
|
||||
|
|
@ -430,7 +437,8 @@ class ObjectUpdateView(LoginRequiredMixin, ObjectDetailView, EvenniaUpdateView):
|
|||
"""
|
||||
|
||||
# -- Django constructs --
|
||||
model = class_from_module(settings.BASE_OBJECT_TYPECLASS)
|
||||
model = class_from_module(settings.BASE_OBJECT_TYPECLASS,
|
||||
fallback=settings.FALLBACK_OBJECT_TYPECLASS)
|
||||
|
||||
# -- Evennia constructs --
|
||||
access_type = "edit"
|
||||
|
|
@ -513,7 +521,8 @@ class AccountMixin(TypeclassMixin):
|
|||
"""
|
||||
|
||||
# -- Django constructs --
|
||||
model = class_from_module(settings.BASE_ACCOUNT_TYPECLASS)
|
||||
model = class_from_module(settings.BASE_ACCOUNT_TYPECLASS,
|
||||
fallback=settings.FALLBACK_ACCOUNT_TYPECLASS)
|
||||
form_class = website_forms.AccountForm
|
||||
|
||||
|
||||
|
|
@ -578,7 +587,8 @@ class CharacterMixin(TypeclassMixin):
|
|||
"""
|
||||
|
||||
# -- Django constructs --
|
||||
model = class_from_module(settings.BASE_CHARACTER_TYPECLASS)
|
||||
model = class_from_module(settings.BASE_CHARACTER_TYPECLASS,
|
||||
fallback=settings.FALLBACK_CHARACTER_TYPECLASS)
|
||||
form_class = website_forms.CharacterForm
|
||||
success_url = reverse_lazy("character-manage")
|
||||
|
||||
|
|
@ -817,7 +827,8 @@ class ChannelMixin(TypeclassMixin):
|
|||
"""
|
||||
|
||||
# -- Django constructs --
|
||||
model = class_from_module(settings.BASE_CHANNEL_TYPECLASS)
|
||||
model = class_from_module(settings.BASE_CHANNEL_TYPECLASS,
|
||||
fallback=settings.FALLBACK_CHANNEL_TYPECLASS)
|
||||
|
||||
# -- Evennia constructs --
|
||||
page_title = "Channels"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue