Compare commits
No commits in common. "8ca037f257a225aea62ee610a9e82a8417702b6c" and "9f939fe57c34619edc7bc5c99abba22e4ae30b90" have entirely different histories.
8ca037f257
...
9f939fe57c
|
@ -49,7 +49,6 @@ def command_create(args):
|
||||||
@add_argument("--no-public", dest="public", action="store_const", const=False)
|
@add_argument("--no-public", dest="public", action="store_const", const=False)
|
||||||
@add_argument("--join", dest="join", action="store_const", const=True)
|
@add_argument("--join", dest="join", action="store_const", const=True)
|
||||||
@add_argument("--no-join", dest="join", action="store_const", const=False)
|
@add_argument("--no-join", dest="join", action="store_const", const=False)
|
||||||
@add_argument("--char-limit", type=int, default=None)
|
|
||||||
def command_edit(args):
|
def command_edit(args):
|
||||||
"""
|
"""
|
||||||
Update a lexicon's configuration.
|
Update a lexicon's configuration.
|
||||||
|
@ -67,9 +66,6 @@ def command_edit(args):
|
||||||
elif args.join == False:
|
elif args.join == False:
|
||||||
values["joinable"] = False
|
values["joinable"] = False
|
||||||
|
|
||||||
if args.char_limit:
|
|
||||||
values["character_limit"] = args.char_limit
|
|
||||||
|
|
||||||
result = db(update(Lexicon).where(Lexicon.name == args.name).values(**values))
|
result = db(update(Lexicon).where(Lexicon.name == args.name).values(**values))
|
||||||
LOG.info(f"Updated {result.rowcount} lexicons")
|
LOG.info(f"Updated {result.rowcount} lexicons")
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
|
@ -95,6 +95,9 @@ div.contentblock {
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
}
|
}
|
||||||
|
div.contentblock h3 {
|
||||||
|
margin: 0.3em 0;
|
||||||
|
}
|
||||||
a.phantom {
|
a.phantom {
|
||||||
color: #cc2200;
|
color: #cc2200;
|
||||||
}
|
}
|
||||||
|
@ -136,21 +139,10 @@ ul.blockitem-list li {
|
||||||
border-inline-start: 3px solid black;
|
border-inline-start: 3px solid black;
|
||||||
padding-inline-start: 0.5em;
|
padding-inline-start: 0.5em;
|
||||||
}
|
}
|
||||||
ul.blockitem-list * {
|
ul.blockitem-list p {
|
||||||
margin-block-start: 0.5em;
|
margin-block-start: 0.5em;
|
||||||
margin-block-end: 0.5em;
|
margin-block-end: 0.5em;
|
||||||
}
|
}
|
||||||
ul.blockitem-list pre {
|
|
||||||
background-color: lightgray;
|
|
||||||
padding-block-start: 2px;
|
|
||||||
padding-block-end: 2px;
|
|
||||||
padding-inline-start: 2px;
|
|
||||||
padding-inline-end: 2px;
|
|
||||||
border: 1px solid gray;
|
|
||||||
border-radius: 2px;
|
|
||||||
font-size: smaller;
|
|
||||||
white-space: break-spaces;
|
|
||||||
}
|
|
||||||
div.dashboard-lexicon-unstarted {
|
div.dashboard-lexicon-unstarted {
|
||||||
border-left-color: blue;
|
border-left-color: blue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
{% block sb_logo %}{% endblock %}
|
{% block sb_logo %}{% endblock %}
|
||||||
{% block sb_characters %}<a
|
{% block sb_characters %}<a
|
||||||
{% if current_page == "characters" %}class="current-page"
|
{% if current_page == "characters" %}class="current-page"
|
||||||
{% else %}href="{{ url_for('lexicon.characters.list', name=g.lexicon.name) }}"
|
{% else %}href="{{ url_for('lexicon.characters.characters', name=g.lexicon.name) }}"
|
||||||
{% endif %}>Characters</a>{% endblock %}
|
{% endif %}>Characters</a>{% endblock %}
|
||||||
{% block sb_contents %}<a
|
{% block sb_contents %}<a
|
||||||
{% if current_page == "contents" %}class="current-page"
|
{% if current_page == "contents" %}class="current-page"
|
||||||
|
|
|
@ -2,7 +2,6 @@ from typing import Optional
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from flask import Blueprint, render_template, url_for, g, flash
|
from flask import Blueprint, render_template, url_for, g, flash
|
||||||
from flask_login import current_user
|
|
||||||
from werkzeug.utils import redirect
|
from werkzeug.utils import redirect
|
||||||
|
|
||||||
from amanuensis.backend import charq
|
from amanuensis.backend import charq
|
||||||
|
@ -18,8 +17,8 @@ bp = Blueprint("characters", __name__, url_prefix="/characters", template_folder
|
||||||
@bp.get('/')
|
@bp.get('/')
|
||||||
@lexicon_param
|
@lexicon_param
|
||||||
@player_required
|
@player_required
|
||||||
def list(name):
|
def characters(name):
|
||||||
return render_template('characters.jinja', name=name)
|
return render_template('characters.jinja')
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/edit/<character_id>', methods=['GET', 'POST'])
|
@bp.route('/edit/<character_id>', methods=['GET', 'POST'])
|
||||||
|
@ -30,11 +29,11 @@ def edit(name, character_id):
|
||||||
char_uuid = uuid.UUID(character_id)
|
char_uuid = uuid.UUID(character_id)
|
||||||
except:
|
except:
|
||||||
flash("Character not found")
|
flash("Character not found")
|
||||||
return redirect(url_for('lexicon.characters.list', name=name))
|
return redirect(url_for('lexicon.characters.characters', name=name))
|
||||||
character: Optional[Character] = charq.try_from_public_id(g.db, char_uuid)
|
character: Optional[Character] = charq.try_from_public_id(g.db, char_uuid)
|
||||||
if not character:
|
if not character:
|
||||||
flash("Character not found")
|
flash("Character not found")
|
||||||
return redirect(url_for('lexicon.characters.list', name=name))
|
return redirect(url_for('lexicon.characters.characters', name=name))
|
||||||
|
|
||||||
form = CharacterCreateForm()
|
form = CharacterCreateForm()
|
||||||
|
|
||||||
|
@ -51,18 +50,38 @@ def edit(name, character_id):
|
||||||
character.name = form.name.data
|
character.name = form.name.data
|
||||||
character.signature = form.signature.data
|
character.signature = form.signature.data
|
||||||
g.db.session.commit()
|
g.db.session.commit()
|
||||||
return redirect(url_for('lexicon.characters.list', name=name))
|
return redirect(url_for('lexicon.characters.characters', name=name))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# POST submitted invalid data
|
# POST submitted invalid data
|
||||||
return render_template('characters.edit.jinja', character=character, form=form)
|
return render_template('characters.edit.jinja', character=character, form=form)
|
||||||
|
|
||||||
|
|
||||||
@bp.get('/new/')
|
# def create_character(name: str, form: LexiconCharacterForm):
|
||||||
@lexicon_param
|
# # Characters can't be created if the game has already started
|
||||||
@player_required
|
# if g.lexicon.status != LexiconModel.PREGAME:
|
||||||
def new(name):
|
# flash("Characters can't be added after the game has started")
|
||||||
dummy_name = f"{current_user.username}'s new character"
|
# return redirect(url_for('session.session', name=name))
|
||||||
dummy_signature = "~"
|
# # Characters can't be created beyond the per-player limit
|
||||||
charq.create(g.db, g.lexicon.id, current_user.id, dummy_name, dummy_signature)
|
# player_characters = get_player_characters(g.lexicon, current_user.uid)
|
||||||
return redirect(url_for('lexicon.characters.list', name=name))
|
# if len(list(player_characters)) >= g.lexicon.cfg.join.chars_per_player:
|
||||||
|
# flash("Can't create more characters")
|
||||||
|
# return redirect(url_for('session.session', name=name))
|
||||||
|
|
||||||
|
# if not form.is_submitted():
|
||||||
|
# # GET, populate with default values
|
||||||
|
# return render_template(
|
||||||
|
# 'session.character.jinja', form=form.for_new())
|
||||||
|
|
||||||
|
# if not form.validate():
|
||||||
|
# # POST with invalid data, return unchanged
|
||||||
|
# return render_template('session.character.jinja', form=form)
|
||||||
|
|
||||||
|
# # POST with valid data, create character
|
||||||
|
# char_name = form.characterName.data
|
||||||
|
# cid = create_character_in_lexicon(current_user, g.lexicon, char_name)
|
||||||
|
# with g.lexicon.ctx.edit_config() as cfg:
|
||||||
|
# cfg.character[cid].signature = form.defaultSignature.data
|
||||||
|
# flash('Character created')
|
||||||
|
# return redirect(url_for('session.session', name=name))
|
||||||
|
|
||||||
|
|
|
@ -10,18 +10,9 @@
|
||||||
<span style="color:#ff0000">{{ message }}</span><br>
|
<span style="color:#ff0000">{{ message }}</span><br>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<ul class="blockitem-list">
|
<ul class="blockitem-list">
|
||||||
{% if characters|map(attribute="user_id")|select("equalto", current_user.id)|list|count < g.lexicon.character_limit %}
|
|
||||||
<li>
|
|
||||||
<h3><a href="{{ url_for('lexicon.characters.new', name=name) }}">Create a new character</a></h3>
|
|
||||||
<p>You have created {{ characters|map(attribute="user_id")|select("equalto", current_user.id)|list|count }} out of {{ g.lexicon.character_limit }} allowed characters.</p>
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
|
||||||
{% for character in characters %}
|
{% for character in characters %}
|
||||||
<li>
|
<li>
|
||||||
<h3>{{ character.name }}</h3>
|
<h3>{{ character.name }}</h3>
|
||||||
{% if character.user == current_user %}
|
|
||||||
<pre>{{ character.signature }}</pre>
|
|
||||||
{% endif %}
|
|
||||||
<p>Player: {{ character.user.username }}</p>
|
<p>Player: {{ character.user.username }}</p>
|
||||||
{% if character.user == current_user %}
|
{% if character.user == current_user %}
|
||||||
<p><a href="{{ url_for('lexicon.characters.edit', name=g.lexicon.name, character_id=character.public_id) }}">Edit this character</a></p>
|
<p><a href="{{ url_for('lexicon.characters.edit', name=g.lexicon.name, character_id=character.public_id) }}">Edit this character</a></p>
|
||||||
|
|
Loading…
Reference in New Issue