aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--apioforum/__init__.py4
-rw-r--r--apioforum/permissions.py1
-rw-r--r--apioforum/templates/base.html2
-rw-r--r--apioforum/templates/common.html2
-rw-r--r--apioforum/templates/view_user.html2
-rw-r--r--apioforum/thread.py3
6 files changed, 8 insertions, 6 deletions
diff --git a/apioforum/__init__.py b/apioforum/__init__.py
index 06595c9..8163e45 100644
--- a/apioforum/__init__.py
+++ b/apioforum/__init__.py
@@ -58,13 +58,15 @@ def create_app():
app.jinja_env.globals.update(forum_path=forum.forum_path)
app.jinja_env.globals.update(post_jump=thread.post_jump)
+ from .permissions import is_admin
from .roles import has_permission, is_bureaucrat, get_user_role
from .thread import thread_info
app.jinja_env.globals.update(
has_permission=has_permission,
thread_info=thread_info,
is_bureaucrat=is_bureaucrat,
- get_user_role=get_user_role)
+ get_user_role=get_user_role,
+ is_admin=is_admin)
from .mdrender import render
@app.template_filter('md')
diff --git a/apioforum/permissions.py b/apioforum/permissions.py
index f705d08..60cba6f 100644
--- a/apioforum/permissions.py
+++ b/apioforum/permissions.py
@@ -38,6 +38,5 @@ def make_admin(username):
def init_app(app):
app.cli.add_command(make_admin)
- app.context_processor(lambda: dict(is_admin=is_admin()))
diff --git a/apioforum/templates/base.html b/apioforum/templates/base.html
index 753e78c..f66395d 100644
--- a/apioforum/templates/base.html
+++ b/apioforum/templates/base.html
@@ -26,7 +26,7 @@
{% if g.user %}
<p>{{ disp_user(g.user) }}</p>
- {% if is_admin %}
+ {% if is_admin() %}
<p><a href="{{url_for('admin.admin_page')}}">admin</a></p>
{% endif %}
diff --git a/apioforum/templates/common.html b/apioforum/templates/common.html
index 44c9036..be7b6ee 100644
--- a/apioforum/templates/common.html
+++ b/apioforum/templates/common.html
@@ -50,7 +50,7 @@
{% endif %}
<a class="actionbutton"
href="{{url_for('thread.view_post',post_id=post.id)}}">src</a>
- {% if post.wiki == 1 %}
+ {% if post.wiki == 1 or is_admin() or g.user == post.author %}
<a class="actionbutton"
href="{{url_for('thread.view_history',post_id=post.id)}}">history</a>
{% endif %}
diff --git a/apioforum/templates/view_user.html b/apioforum/templates/view_user.html
index 582f051..efaea6b 100644
--- a/apioforum/templates/view_user.html
+++ b/apioforum/templates/view_user.html
@@ -11,7 +11,7 @@
{% endif %}
{% if user.banned %}
<span><b>BANNED:</b> {{ user.banreason or "(no reason given)" }}</span>
- {%elif is_admin%}
+ {%elif is_admin()%}
<a class="actionbutton" href="{{url_for('user.ban_user',username=user.username)}}">ban user</a>
{% endif %}
</div>
diff --git a/apioforum/thread.py b/apioforum/thread.py
index fc355ab..9b74347 100644
--- a/apioforum/thread.py
+++ b/apioforum/thread.py
@@ -8,6 +8,7 @@ from flask import (
)
from .db import get_db
from .roles import has_permission
+from .permissions import is_admin
from . import webhooks
from . import forum
from . import wiki
@@ -419,7 +420,7 @@ def view_post(post_id):
abort(404)
if rev['post'] != post_id:
abort(404)
- if post['wiki'] != 1:
+ if post['wiki'] != 1 and not is_admin() and g.user != post['author']:
abort(403)
post = dict(post)
post['content'] = rev['content']