1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Add support for locked wiki pages

This commit is contained in:
Steffo 2019-02-03 17:57:46 +01:00
parent 5e507fbb5e
commit eb08b51e59
3 changed files with 15 additions and 20 deletions

11
db.py
View file

@ -1015,17 +1015,6 @@ class WikiLog(Base):
return f"<WikiLog {self.edit_id}>"
class WikiAuthorization(Base):
__tablename__ = "wikiauthorization"
royal_id = Column(Integer, ForeignKey("royals.id"))
royal = relationship("Royal", backref="profile_data", uselist=False, lazy="joined")
page_key = Column(String, ForeignKey("wikientries.key"), nullable=False)
page = relationship("WikiEntry", backref="edit_logs", lazy="joined")
__table_args__ = (PrimaryKeyConstraint("royal_id", "page_key"),)
class Event(Base):
__tablename__ = "events"

View file

@ -870,7 +870,7 @@ img {
.wiki {
.wiki-log {
.wiki-log, .wiki-locked {
font-family: "Consolas", "Source Code Pro", monospace;
font-size: small;
margin-bottom: 12px;

View file

@ -43,14 +43,20 @@
Ultima modifica di <span class="last-author"><a href="/profile/{{ wiki_log.editor.username }}">{{ wiki_log.editor.username }}</a></span> alle <span class="last-timestamp">{{ wiki_log.timestamp.strftime('%Y-%m-%d %H:%M:%S %Z') }}</span>{% if wiki_log.reason %}, motivo: <span class="last-reason">{{ wiki_log.reason }}</span>{% endif %}
</div>
{% endif %}
{% if g.user and not wiki_page.locked %}
<div class="wiki-edit">
<h4>Modifica</h4>
<form action="{{ url_for('page_wiki', key=key) }}" method="POST">
<textarea oninput="newEdit()" class="content" name="content" placeholder="Inserisci il Markdown per la pagina qui.">{% if wiki_page %}{{ wiki_page.content }}{% endif %}</textarea><br>
<input class="reason" name="reason" type="text" placeholder="Motivo per la modifica"><br>
<input class="submit" type="submit" onmouseenter="onEnter()" onmouseleave="onExit()" value="Invia">
</form>
{% if not wiki_page.locked %}
{% if g.user %}
<div class="wiki-edit">
<h4>Modifica</h4>
<form action="{{ url_for('page_wiki', key=key) }}" method="POST">
<textarea oninput="newEdit()" class="content" name="content" placeholder="Inserisci il Markdown per la pagina qui.">{% if wiki_page %}{{ wiki_page.content }}{% endif %}</textarea><br>
<input class="reason" name="reason" type="text" placeholder="Motivo per la modifica"><br>
<input class="submit" type="submit" onmouseenter="onEnter()" onmouseleave="onExit()" value="Invia">
</form>
</div>
{% endif %}
{% else %}
<div class="wiki-locked">
<span>🔒 Pagina bloccata: non possono essere effettuate ulteriori modifiche.</span>
</div>
{% endif %}
</div>