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 | ||||
| from user_service import userService | ||||
| from account_service import accountService | ||||
| from admin_service import adminService | ||||
| from admin_service import adminService, ADMIN_NAME | ||||
| app = Flask(__name__) | ||||
| app.secret_key = 'lunch.time!' | ||||
| 
 | ||||
|  | @ -98,8 +98,13 @@ def mainpage(): | |||
|         d = load_freq_history(path_prefix + 'static/frequency/frequency.p') | ||||
|         d_len = len(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, | ||||
|                                d_len=d_len, lst=lst, yml=Yaml.yml) | ||||
|         return render_template('mainpage_get.html',  | ||||
|                                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__': | ||||
|  |  | |||
|  | @ -23,12 +23,15 @@ | |||
|     <div class="container-fluid"> | ||||
|         <p><b><font size="+3" color="red">English Pal - Learn English smartly!</font></b></p> | ||||
|         {% 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 %} | ||||
|             <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> | ||||
|         {% 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> | ||||
|         <form method="post" action="/"> | ||||
|             <textarea name="content" rows="10" cols="120"></textarea><br/> | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue