Compare commits

...

3 Commits

Author SHA1 Message Date
Michal Kunc
182d0c0c86
Add trait list to action 2021-11-19 11:52:42 +01:00
Michal Kunc
b459f5f4b1
Optimize docker builds 2021-11-19 11:52:09 +01:00
Michal Kunc
6c1b479bd5
Fix HTML typo 2021-11-19 11:39:35 +01:00
5 changed files with 20 additions and 5 deletions

View File

@ -1,2 +1,4 @@
.git/
db-importer/
db-importer/
# poetry
poetry.lock

View File

@ -5,10 +5,12 @@ RUN python3 -m pip install poetry
EXPOSE 5000
WORKDIR /app
COPY db_explorer/ /app/
COPY db_explorer/pyproject.toml /app/
RUN poetry update
RUN poetry run pip install setuptools
COPY db_explorer/ /app/
ENTRYPOINT [ "poetry", "run" ]
CMD [ "gunicorn", "-b=0.0.0.0:5000", "db_explorer:app" ]

View File

@ -54,6 +54,7 @@ def list_actions():
@app.route("/action/<name>")
def show_action(name):
item = mongo.db.action.find_one_or_404({"name": name})
# Actions
if item["data"]["actions"]["value"] == None:
if item["data"]["actionType"]["value"] == 'passive':
item['_action_icon'] = None
@ -67,8 +68,13 @@ def show_action(name):
item['_action_icon'] = item["data"]["actions"]["value"]
else:
raise ValueError(f'Unknown action: {item["data"]["actionType"]["value"]} - {item["data"]["actions"]["value"]}')
# Traits
_traits = item.get("data", {}).get("traits", {})
item["_all_traits"] = []
item["_all_traits"].append(_traits.get("rarity", {}).get("value", "unkown rarity"))
item["_all_traits"] += _traits.get("value", [])
item["_all_traits"] += _traits.get("custom").split(',')
return render_template("action.html", action=item)
if __name__ == "__main__":
app.run()
app.run()

View File

@ -5,7 +5,7 @@
{% block head %}
<title>{% block title %}PF2 DB{% endblock %}</title>
{% endblock %}
<link rel="stylesheet" href="{{ url_for('static', filename='css/base.css') }}"
<link rel="stylesheet" href="{{ url_for('static', filename='css/base.css') }}">
</head>
<body>
{% block body %}

View File

@ -2,6 +2,11 @@
{% block title %}{{action.name}} - PF2 DB{% endblock %}
{% block body %}
<h1>{{action["name"]}}{{c.actions[action["_action_icon"]]|safe}}</h1>
<ul class="traits">
{%- for trait in action["_all_traits"] %}
<li class="trait">{{trait|upper}}</li>
{% endfor -%}
</ul>
<p>{{action["data"]["description"]["value"]|filter_vtt|safe}}</p>
<p class="sourcebook">{{action["data"]["source"]["value"]}}</p>
{% endblock %}