forked from mrlan/EnglishPal
fix: check current user is admin
parent
52025d55bc
commit
bdda754af6
11
app/main.py
11
app/main.py
|
@ -11,7 +11,7 @@ from Article import *
|
||||||
import Yaml
|
import Yaml
|
||||||
from user_service import userService
|
from user_service import userService
|
||||||
from account_service import accountService
|
from account_service import accountService
|
||||||
from admin_service import adminService
|
from admin_service import adminService, ADMIN_NAME
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.secret_key = 'lunch.time!'
|
app.secret_key = 'lunch.time!'
|
||||||
|
|
||||||
|
@ -98,8 +98,13 @@ def mainpage():
|
||||||
d = load_freq_history(path_prefix + 'static/frequency/frequency.p')
|
d = load_freq_history(path_prefix + 'static/frequency/frequency.p')
|
||||||
d_len = len(d)
|
d_len = len(d)
|
||||||
lst = sort_in_descending_order(pickle_idea.dict2lst(d))
|
lst = sort_in_descending_order(pickle_idea.dict2lst(d))
|
||||||
return render_template('mainpage_get.html', random_ads=random_ads, number_of_essays=number_of_essays,
|
return render_template('mainpage_get.html',
|
||||||
d_len=d_len, lst=lst, yml=Yaml.yml)
|
admin_name=ADMIN_NAME,
|
||||||
|
random_ads=random_ads,
|
||||||
|
d_len=d_len,
|
||||||
|
lst=lst,
|
||||||
|
yml=Yaml.yml,
|
||||||
|
number_of_essays=number_of_essays)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -23,12 +23,15 @@
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<p><b><font size="+3" color="red">English Pal - Learn English smartly!</font></b></p>
|
<p><b><font size="+3" color="red">English Pal - Learn English smartly!</font></b></p>
|
||||||
{% if session['logged_in'] %}
|
{% if session['logged_in'] %}
|
||||||
<a href="/{{session['username']}}">{{session['username']}}</a> <a href="/admin">管理</a></p>
|
<a href="/{{ session['username'] }}">{{ session['username'] }}</a>
|
||||||
|
{% if session['username'] == admin_name %}
|
||||||
|
<a href="/admin">管理</a></p>
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<p><a href="/admin">管理</a> <a href="/login">登录</a> <a href="/signup">注册</a> <a href="/static/usr/instructions.html">使用说明</a></p >
|
<p><a href="/admin">管理</a> <a href="/login">登录</a> <a href="/signup">注册</a> <a href="/static/usr/instructions.html">使用说明</a></p >
|
||||||
<p><b>{{random_ads|safe}}</b></p>
|
<p><b>{{random_ads|safe}}</b></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="alert alert-success" role="alert">共有文章 <span class="badge bg-success"> {{number_of_essays}} </span> 篇</div>
|
<div class="alert alert-success" role="alert">共有文章 <span class="badge bg-success"> {{ number_of_essays }} </span> 篇</div>
|
||||||
<p>粘贴1篇文章 (English only)</p>
|
<p>粘贴1篇文章 (English only)</p>
|
||||||
<form method="post" action="/">
|
<form method="post" action="/">
|
||||||
<textarea name="content" rows="10" cols="120"></textarea><br/>
|
<textarea name="content" rows="10" cols="120"></textarea><br/>
|
||||||
|
|
Loading…
Reference in New Issue