Make approved articles viewable
This commit is contained in:
parent
c9f1f9a44f
commit
fd3ef7fbdc
@ -67,13 +67,19 @@ def get_bp():
|
||||
@player_required
|
||||
def session(name):
|
||||
drafts = []
|
||||
approved = []
|
||||
draft_ctx = g.lexicon.ctx.draft
|
||||
draft_filenames = draft_ctx.ls()
|
||||
for draft_filename in draft_filenames:
|
||||
with draft_ctx.read(draft_filename) as draft:
|
||||
if draft.status.ready and not draft.status.approved:
|
||||
drafts.append(draft)
|
||||
return render_template('lexicon/session.html', ready_articles=drafts)
|
||||
if draft.status.approved:
|
||||
approved.append(draft)
|
||||
return render_template(
|
||||
'lexicon/session.html',
|
||||
ready_articles=drafts,
|
||||
approved_articles=approved)
|
||||
|
||||
def edit_character(name, form, cid):
|
||||
if form.validate_on_submit():
|
||||
@ -152,24 +158,34 @@ def get_bp():
|
||||
return redirect(url_for('lexicon.session', name=name))
|
||||
|
||||
draft_ctx = g.lexicon.ctx.draft
|
||||
# TODO do this not terribly
|
||||
draft_filename = [fn for fn in draft_ctx.ls() if aid in fn][0]
|
||||
with draft_ctx.read(draft_filename) as draft:
|
||||
with draft_ctx.edit(draft_filename) as draft:
|
||||
# If the article was unreadied in the meantime, abort
|
||||
if not draft.status.ready:
|
||||
flash("Article was rescinded")
|
||||
return redirect(url_for('lexicon.session', name=name))
|
||||
|
||||
parsed_draft = parse_raw_markdown(draft.contents)
|
||||
rendered_html = parsed_draft.render(PreviewHtmlRenderer(
|
||||
{'Article':'default','Phantom':None}))
|
||||
|
||||
form = LexiconReviewForm()
|
||||
|
||||
if form.validate_on_submit():
|
||||
with draft_ctx.edit(draft_filename) as draft:
|
||||
if not draft.status.ready:
|
||||
flash("Article was rescinded")
|
||||
# If the article is ready and awaiting review
|
||||
if not draft.status.approved:
|
||||
form = LexiconReviewForm()
|
||||
if form.validate_on_submit():
|
||||
if form.approved.data == 'Y':
|
||||
draft.status.ready = True
|
||||
draft.status.approved = True
|
||||
g.lexicon.add_log(f"Article '{draft.title}' approved ({draft.aid})")
|
||||
else:
|
||||
draft.status.ready = False
|
||||
draft.status.approved = False
|
||||
g.lexicon.add_log(f"Article '{draft.title}' rejected ({draft.aid})")
|
||||
return redirect(url_for('lexicon.session', name=name))
|
||||
result = (form.approved.data == "Y")
|
||||
draft.status.ready = result
|
||||
draft.status.approved = result
|
||||
return redirect(url_for('lexicon.session', name=name))
|
||||
|
||||
# If the article was already reviewed and this is just the preview
|
||||
else:
|
||||
form = None
|
||||
|
||||
return render_template(
|
||||
"lexicon/review.html",
|
||||
|
@ -34,7 +34,7 @@
|
||||
<a href="{{ url_for('lexicon.session', name=g.lexicon.name) }}">
|
||||
{{ g.lexicon.title }}
|
||||
</a>
|
||||
{% if article %}
|
||||
{% if article and not article.status.approved %}
|
||||
<button id="button-submit" onclick="submitArticle()">Submit article</button>
|
||||
{% endif %}
|
||||
<span>
|
||||
|
@ -17,4 +17,8 @@
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
{% set template_content_blocks = [self.article(), self.evaluation()] %}
|
||||
{% if form %}
|
||||
{% set template_content_blocks = [self.article(), self.evaluation()] %}
|
||||
{% else %}
|
||||
{% set template_content_blocks = [self.article()] %}
|
||||
{% endif %}
|
@ -21,7 +21,17 @@
|
||||
{% for article in ready_articles %}
|
||||
<li>
|
||||
<a href="{{ url_for('lexicon.review', name=g.lexicon.name, aid=article.aid) }}">
|
||||
Review article by {{ g.lexicon.character[article.character].name }}
|
||||
Review <i>{{ article.title }}</i> by {{ g.lexicon.character[article.character].name }}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<p>Approved articles</p>
|
||||
<ul>
|
||||
{% for article in approved_articles %}
|
||||
<li>
|
||||
<a href="{{ url_for('lexicon.review', name=g.lexicon.name, aid=article.aid) }}">
|
||||
<i>{{ article.title }}</i> by {{ g.lexicon.character[article.character].name }}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
Loading…
Reference in New Issue
Block a user