Housekeeping.
This commit is contained in:
parent
e37b014d4a
commit
f9999119e2
3 changed files with 13 additions and 4 deletions
|
|
@ -67,7 +67,15 @@ def general_context(request):
|
||||||
Returns common Evennia-related context stuff, which
|
Returns common Evennia-related context stuff, which
|
||||||
is automatically added to context of all views.
|
is automatically added to context of all views.
|
||||||
"""
|
"""
|
||||||
|
account = None
|
||||||
|
if request.user.is_authenticated(): account = request.user
|
||||||
|
|
||||||
|
puppet = None
|
||||||
|
if request.session.get('puppet'): puppet = request.session['puppet']
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
'account': account,
|
||||||
|
'puppet': puppet,
|
||||||
'game_name': GAME_NAME,
|
'game_name': GAME_NAME,
|
||||||
'game_slogan': GAME_SLOGAN,
|
'game_slogan': GAME_SLOGAN,
|
||||||
'evennia_userapps': ACCOUNT_RELATED,
|
'evennia_userapps': ACCOUNT_RELATED,
|
||||||
|
|
|
||||||
|
|
@ -39,14 +39,14 @@ folder and edit it to add/remove links to the menu.
|
||||||
{% block navbar_right %}
|
{% block navbar_right %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block navbar_user %}
|
{% block navbar_user %}
|
||||||
{% if user.is_authenticated %}
|
{% if account %}
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" id="user_options" aria-expanded="false">Logged in as {{user.username}} <span class="caret"></span></a>
|
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" id="user_options" aria-expanded="false">Logged in as {{user.username}} <span class="caret"></span></a>
|
||||||
<div class="dropdown-menu" aria-labelledby="user_options">
|
<div class="dropdown-menu" aria-labelledby="user_options">
|
||||||
<a class="dropdown-item" href="{% url 'character-create' %}">Create Character</a>
|
<a class="dropdown-item" href="{% url 'character-create' %}">Create Character</a>
|
||||||
<a class="dropdown-item" href="{% url 'character-manage' %}">Manage Characters</a>
|
<a class="dropdown-item" href="{% url 'character-manage' %}">Manage Characters</a>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
{% for character in user.characters|slice:"10" %}
|
{% for character in account.characters|slice:"10" %}
|
||||||
<a class="dropdown-item" href="#">{{ character }}</a>
|
<a class="dropdown-item" href="#">{{ character }}</a>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<a class="dropdown-item" href="#">No characters found!</a>
|
<a class="dropdown-item" href="#">No characters found!</a>
|
||||||
|
|
|
||||||
|
|
@ -328,7 +328,7 @@ class CharacterMixin(object):
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
# Get IDs of characters owned by account
|
# Get IDs of characters owned by account
|
||||||
ids = [getattr(x, 'id') for x in self.request.user.db._playable_characters if x]
|
ids = [getattr(x, 'id') for x in self.request.user.characters if x]
|
||||||
|
|
||||||
# Return a queryset consisting of those characters
|
# Return a queryset consisting of those characters
|
||||||
return self.model.objects.filter(id__in=ids).order_by(Lower('db_key'))
|
return self.model.objects.filter(id__in=ids).order_by(Lower('db_key'))
|
||||||
|
|
@ -337,7 +337,7 @@ class CharacterManageView(LoginRequiredMixin, CharacterMixin, ListView):
|
||||||
|
|
||||||
paginate_by = 10
|
paginate_by = 10
|
||||||
template_name = 'website/character_manage_list.html'
|
template_name = 'website/character_manage_list.html'
|
||||||
page_title = 'Manage: Characters'
|
page_title = 'Manage Characters'
|
||||||
|
|
||||||
class CharacterUpdateView(CharacterMixin, ObjectUpdateView):
|
class CharacterUpdateView(CharacterMixin, ObjectUpdateView):
|
||||||
|
|
||||||
|
|
@ -390,6 +390,7 @@ class CharacterCreateView(CharacterMixin, ObjectCreateView):
|
||||||
[setattr(character.db, key, value) for key,value in self.attributes.items()]
|
[setattr(character.db, key, value) for key,value in self.attributes.items()]
|
||||||
character.db.creator_id = account.id
|
character.db.creator_id = account.id
|
||||||
character.save()
|
character.save()
|
||||||
|
account.save()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
messages.error(self.request, "There was an error creating your character. If this problem persists, contact an admin.")
|
messages.error(self.request, "There was an error creating your character. If this problem persists, contact an admin.")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue