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("--join", dest="join", action="store_const", const=True)
|
||||
@add_argument("--no-join", dest="join", action="store_const", const=False)
|
||||
@add_argument("--char-limit", type=int, default=None)
|
||||
def command_edit(args):
|
||||
"""
|
||||
Update a lexicon's configuration.
|
||||
|
@ -67,9 +66,6 @@ def command_edit(args):
|
|||
elif args.join == 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))
|
||||
LOG.info(f"Updated {result.rowcount} lexicons")
|
||||
db.session.commit()
|
||||
|
|
|
@ -95,6 +95,9 @@ div.contentblock {
|
|||
border-radius: 5px;
|
||||
word-break: break-word;
|
||||
}
|
||||
div.contentblock h3 {
|
||||
margin: 0.3em 0;
|
||||
}
|
||||
a.phantom {
|
||||
color: #cc2200;
|
||||
}
|
||||
|
@ -136,21 +139,10 @@ ul.blockitem-list li {
|
|||
border-inline-start: 3px solid black;
|
||||
padding-inline-start: 0.5em;
|
||||
}
|
||||
ul.blockitem-list * {
|
||||
ul.blockitem-list p {
|
||||
margin-block-start: 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 {
|
||||
border-left-color: blue;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
{% block sb_logo %}{% endblock %}
|
||||
{% block sb_characters %}<a
|
||||
{% 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 %}
|
||||
{% block sb_contents %}<a
|
||||
{% if current_page == "contents" %}class="current-page"
|
||||
|
|
|
@ -2,7 +2,6 @@ from typing import Optional
|
|||
import uuid
|
||||
|
||||
from flask import Blueprint, render_template, url_for, g, flash
|
||||
from flask_login import current_user
|
||||
from werkzeug.utils import redirect
|
||||
|
||||
from amanuensis.backend import charq
|
||||
|
@ -18,8 +17,8 @@ bp = Blueprint("characters", __name__, url_prefix="/characters", template_folder
|
|||
@bp.get('/')
|
||||
@lexicon_param
|
||||
@player_required
|
||||
def list(name):
|
||||
return render_template('characters.jinja', name=name)
|
||||
def characters(name):
|
||||
return render_template('characters.jinja')
|
||||
|
||||
|
||||
@bp.route('/edit/<character_id>', methods=['GET', 'POST'])
|
||||
|
@ -30,11 +29,11 @@ def edit(name, character_id):
|
|||
char_uuid = uuid.UUID(character_id)
|
||||
except:
|
||||
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)
|
||||
if not character:
|
||||
flash("Character not found")
|
||||
return redirect(url_for('lexicon.characters.list', name=name))
|
||||
return redirect(url_for('lexicon.characters.characters', name=name))
|
||||
|
||||
form = CharacterCreateForm()
|
||||
|
||||
|
@ -51,18 +50,38 @@ def edit(name, character_id):
|
|||
character.name = form.name.data
|
||||
character.signature = form.signature.data
|
||||
g.db.session.commit()
|
||||
return redirect(url_for('lexicon.characters.list', name=name))
|
||||
return redirect(url_for('lexicon.characters.characters', name=name))
|
||||
|
||||
else:
|
||||
# POST submitted invalid data
|
||||
return render_template('characters.edit.jinja', character=character, form=form)
|
||||
|
||||
|
||||
@bp.get('/new/')
|
||||
@lexicon_param
|
||||
@player_required
|
||||
def new(name):
|
||||
dummy_name = f"{current_user.username}'s new character"
|
||||
dummy_signature = "~"
|
||||
charq.create(g.db, g.lexicon.id, current_user.id, dummy_name, dummy_signature)
|
||||
return redirect(url_for('lexicon.characters.list', name=name))
|
||||
# def create_character(name: str, form: LexiconCharacterForm):
|
||||
# # Characters can't be created if the game has already started
|
||||
# if g.lexicon.status != LexiconModel.PREGAME:
|
||||
# flash("Characters can't be added after the game has started")
|
||||
# return redirect(url_for('session.session', name=name))
|
||||
# # Characters can't be created beyond the per-player limit
|
||||
# player_characters = get_player_characters(g.lexicon, current_user.uid)
|
||||
# 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>
|
||||
{% endfor %}
|
||||
<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 %}
|
||||
<li>
|
||||
<h3>{{ character.name }}</h3>
|
||||
{% if character.user == current_user %}
|
||||
<pre>{{ character.signature }}</pre>
|
||||
{% endif %}
|
||||
<p>Player: {{ character.user.username }}</p>
|
||||
{% 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>
|
||||
|
|
Loading…
Reference in New Issue