Fix CLI character creation
This commit is contained in:
parent
eb5c52ea85
commit
92e12ae83c
@ -1,3 +1,7 @@
|
||||
# Standard library imports
|
||||
import json
|
||||
|
||||
# Module imports
|
||||
from amanuensis.cli.helpers import (
|
||||
add_argument, no_argument, requires_lexicon, requires_user, alias,
|
||||
config_get, config_set, CONFIG_GET_ROOT_VALUE)
|
||||
@ -199,7 +203,7 @@ def command_player_list(args):
|
||||
|
||||
@alias('lcc')
|
||||
@requires_lexicon
|
||||
# @requires_username
|
||||
@requires_user
|
||||
@add_argument("--charname", required=True, help="The character's name")
|
||||
def command_char_create(args):
|
||||
"""
|
||||
@ -214,18 +218,17 @@ def command_char_create(args):
|
||||
from amanuensis.user import UserModel
|
||||
|
||||
# Verify arguments
|
||||
u = UserModel.by(name=args.username)
|
||||
if u is None:
|
||||
logger.error("Could not find user '{}'".format(args.username))
|
||||
if args.user.id not in args.lexicon.join.joined:
|
||||
logger.error('"{0.username}" is not a player in lexicon "{1.name}"'
|
||||
''.format(args.user, args.lexicon))
|
||||
return -1
|
||||
lex = LexiconModel.by(name=args.lexicon)
|
||||
if lex is None:
|
||||
logger.error("Could not find lexicon '{}'".format(args.lexicon))
|
||||
return -1
|
||||
# u in lx TODO
|
||||
|
||||
# Internal call
|
||||
add_character(lex, u, {"name": args.charname})
|
||||
# Perform command
|
||||
add_character(args.lexicon, args.user, {"name": args.charname})
|
||||
|
||||
# Output
|
||||
logger.info('Created character "{0.charname}" for "{0.user.username}" in '
|
||||
'"{0.lexicon.name}"'.format(args))
|
||||
return 0
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Standard imports
|
||||
# Standard library imports
|
||||
import getpass
|
||||
import os
|
||||
import shutil
|
||||
|
@ -8,18 +8,20 @@
|
||||
Created: {{ g.lexicon.time.created|asdate }}<br>
|
||||
Completed: {{ g.lexicon.time.completed|asdate }}<br>
|
||||
Players:
|
||||
{% for uid in g.lexicon.join.joined[:-1] %}
|
||||
{{ uid|user_attr('username') }},
|
||||
{% endfor %}
|
||||
{{ g.lexicon.join.joined[-1]|user_attr('username') }}<br>
|
||||
Log:
|
||||
<div style="width: 100%; height: 10em; overflow-y:auto; resize: vertical;
|
||||
border: 1px solid #bbbbbb; font-size: 0.9em; padding:3px; box-sizing: border-box;">
|
||||
{% for log_entry in g.lexicon.log %}
|
||||
[{{ log_entry[0]|asdate }}] {{ log_entry[1] }}<br>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% for uid in g.lexicon.join.joined %}
|
||||
{{ uid|user_attr('username') }}{% if not loop.last %},{% endif %}
|
||||
{% endfor %}<br>
|
||||
Characters:
|
||||
{% for char in g.lexicon.character.values() %}
|
||||
{{ char.name }} ({{ char.player|user_attr('username') }}){% if not loop.last %},{% endif %}
|
||||
{% endfor %}<br>
|
||||
</p>
|
||||
<div style="width: 100%; height: 10em; overflow-y:auto; resize: vertical;
|
||||
border: 1px solid #bbbbbb; font-size: 0.9em; padding:3px; box-sizing: border-box;">
|
||||
{% for log_entry in g.lexicon.log %}
|
||||
[{{ log_entry[0]|asdate }}] {{ log_entry[1] }}<br>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% macro number_setting(field) %}
|
||||
|
Loading…
Reference in New Issue
Block a user