Merge pull request #98 from ThomasRubini/npc
This commit is contained in:
commit
d39de3eecb
@ -15,7 +15,7 @@ class Text(Base):
|
|||||||
LID = Column(Integer, ForeignKey("T_LOCALE.LID"), comment="Reference to the locale that this text provides")
|
LID = Column(Integer, ForeignKey("T_LOCALE.LID"), comment="Reference to the locale that this text provides")
|
||||||
LANG = Column(VARCHAR(2), comment="lang ID of the text value in this row, e.g FR, EN, ES")
|
LANG = Column(VARCHAR(2), comment="lang ID of the text value in this row, e.g FR, EN, ES")
|
||||||
TEXT = Column(Text, comment="Actual text stored")
|
TEXT = Column(Text, comment="Actual text stored")
|
||||||
LOCALE = relationship("Locale")
|
LOCALE = relationship("Locale", backref='TEXTS')
|
||||||
|
|
||||||
def __init__(self, TEXT_ID, LID, LANG, TEXT):
|
def __init__(self, TEXT_ID, LID, LANG, TEXT):
|
||||||
self.TEXT_ID = TEXT_ID
|
self.TEXT_ID = TEXT_ID
|
||||||
@ -104,7 +104,7 @@ class Answer(Base):
|
|||||||
NPC_ID = Column(Integer, ForeignKey("T_NPC.NPC_ID"), primary_key=True, comment="ID of the NPC that will say this answer")
|
NPC_ID = Column(Integer, ForeignKey("T_NPC.NPC_ID"), primary_key=True, comment="ID of the NPC that will say this answer")
|
||||||
TEXT_LID = Column(Integer, ForeignKey("T_LOCALE.LID"), comment="Text of the answer")
|
TEXT_LID = Column(Integer, ForeignKey("T_LOCALE.LID"), comment="Text of the answer")
|
||||||
LOCALE = relationship("Locale")
|
LOCALE = relationship("Locale")
|
||||||
NPC = relationship("Npc")
|
NPC = relationship("Npc", backref="ANSWERS")
|
||||||
|
|
||||||
def __init__(self, QUESTION_TYPE_ID, NPC_ID, TEXT_LID):
|
def __init__(self, QUESTION_TYPE_ID, NPC_ID, TEXT_LID):
|
||||||
self.QUESTION_TYPE_ID = QUESTION_TYPE_ID
|
self.QUESTION_TYPE_ID = QUESTION_TYPE_ID
|
||||||
|
|||||||
@ -1,14 +1,42 @@
|
|||||||
import flask
|
import flask
|
||||||
|
|
||||||
|
from truthinquiry.ext.database.models import *
|
||||||
|
from truthinquiry.ext.database.fsa import db
|
||||||
|
|
||||||
routes_admin = flask.Blueprint("admin", __name__)
|
routes_admin = flask.Blueprint("admin", __name__)
|
||||||
|
|
||||||
|
def get_or_empty(obj, key):
|
||||||
|
if obj == None:
|
||||||
|
return ""
|
||||||
|
else:
|
||||||
|
return getattr(obj, key)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@routes_admin.route("/")
|
@routes_admin.route("/")
|
||||||
def index():
|
def index():
|
||||||
return flask.render_template("admin/index.html")
|
return flask.render_template("admin/index.html")
|
||||||
|
|
||||||
@routes_admin.route("/npc/<npc_id>")
|
@routes_admin.route("/npc/<npc_id>")
|
||||||
def npc(npc_id):
|
def npc(npc_id):
|
||||||
return flask.render_template("admin/npc.html")
|
if npc_id == "new":
|
||||||
|
return flask.render_template("admin/npc.html", npc={})
|
||||||
|
else:
|
||||||
|
npc_obj = db.session.get(Npc, npc_id)
|
||||||
|
|
||||||
|
npc_answers = []
|
||||||
|
for answer_type in npc_obj.ANSWERS:
|
||||||
|
answer_list = [answer.TEXT for answer in answer_type.LOCALE.TEXTS]
|
||||||
|
npc_answers.append(answer_list)
|
||||||
|
|
||||||
|
npc_dict = {
|
||||||
|
"name": npc_obj.LOCALE.TEXTS[0].TEXT,
|
||||||
|
"img": npc_obj.NPC_ID,
|
||||||
|
"answers": npc_answers,
|
||||||
|
}
|
||||||
|
|
||||||
|
return flask.render_template("admin/npc.html", npc=npc_dict)
|
||||||
|
|
||||||
@routes_admin.route("/questions")
|
@routes_admin.route("/questions")
|
||||||
def questions():
|
def questions():
|
||||||
|
|||||||
@ -10,4 +10,6 @@
|
|||||||
<a href="/admin/npc/2"> Barron </a>
|
<a href="/admin/npc/2"> Barron </a>
|
||||||
<br>
|
<br>
|
||||||
<a href="/admin/npc/3"> Machin </a>
|
<a href="/admin/npc/3"> Machin </a>
|
||||||
|
<br>
|
||||||
|
<a href="/admin/npc/new"> Nouveau </a>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@ -1 +1,19 @@
|
|||||||
<a href="/admin"> go Back </a> <br>
|
<a href="/admin"> go Back </a> <br>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<span>Npc name: </span> <input value="{{ npc.get('name') or ''}}">
|
||||||
|
<img href="{{npc.get('img')}}">
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<p>Answers:</p>
|
||||||
|
{%for answer_type in npc.get("answers") or []%}
|
||||||
|
<section>
|
||||||
|
{%for answer in answer_type%}
|
||||||
|
<input value="{{answer}}">
|
||||||
|
{%endfor%}
|
||||||
|
</section>
|
||||||
|
{%endfor%}
|
||||||
|
|
||||||
|
</section>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user