1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +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}>" 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): class Event(Base):
__tablename__ = "events" __tablename__ = "events"

View file

@ -870,7 +870,7 @@ img {
.wiki { .wiki {
.wiki-log { .wiki-log, .wiki-locked {
font-family: "Consolas", "Source Code Pro", monospace; font-family: "Consolas", "Source Code Pro", monospace;
font-size: small; font-size: small;
margin-bottom: 12px; 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 %} 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> </div>
{% endif %} {% endif %}
{% if g.user and not wiki_page.locked %} {% if not wiki_page.locked %}
<div class="wiki-edit"> {% if g.user %}
<h4>Modifica</h4> <div class="wiki-edit">
<form action="{{ url_for('page_wiki', key=key) }}" method="POST"> <h4>Modifica</h4>
<textarea oninput="newEdit()" class="content" name="content" placeholder="Inserisci il Markdown per la pagina qui.">{% if wiki_page %}{{ wiki_page.content }}{% endif %}</textarea><br> <form action="{{ url_for('page_wiki', key=key) }}" method="POST">
<input class="reason" name="reason" type="text" placeholder="Motivo per la modifica"><br> <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="submit" type="submit" onmouseenter="onEnter()" onmouseleave="onExit()" value="Invia"> <input class="reason" name="reason" type="text" placeholder="Motivo per la modifica"><br>
</form> <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> </div>
{% endif %} {% endif %}
</div> </div>