fix template, fix notes bug on admin page
This commit is contained in:
parent
651ef0b0d2
commit
901b9ee933
301
web/app.py
301
web/app.py
@ -47,58 +47,61 @@ from gen_script_template import gen_script
|
|||||||
import os, ast
|
import os, ast
|
||||||
##import hb_config
|
##import hb_config
|
||||||
|
|
||||||
|
from hws.misc_functions import *
|
||||||
|
from hws.views import *
|
||||||
|
|
||||||
script_links = {}
|
script_links = {}
|
||||||
active_tgs = {}
|
active_tgs = {}
|
||||||
ping_list = {}
|
ping_list = {}
|
||||||
peer_locations = {}
|
peer_locations = {}
|
||||||
|
|
||||||
# Query radioid.net for list of IDs
|
### Query radioid.net for list of IDs
|
||||||
def get_ids(callsign):
|
##def get_ids(callsign):
|
||||||
try:
|
## try:
|
||||||
url = "https://www.radioid.net"
|
## url = "https://www.radioid.net"
|
||||||
response = requests.get(url+"/api/dmr/user/?callsign=" + callsign)
|
## response = requests.get(url+"/api/dmr/user/?callsign=" + callsign)
|
||||||
result = response.json()
|
## result = response.json()
|
||||||
## print(result)
|
#### print(result)
|
||||||
# id_list = []
|
## # id_list = []
|
||||||
id_list = {}
|
## id_list = {}
|
||||||
f_name = result['results'][0]['fname']
|
## f_name = result['results'][0]['fname']
|
||||||
l_name = result['results'][0]['surname']
|
## l_name = result['results'][0]['surname']
|
||||||
try:
|
## try:
|
||||||
city = str(result['results'][0]['city'] + ', ' + result['results'][0]['state'] + ', ' + result['results'][0]['country'])
|
## city = str(result['results'][0]['city'] + ', ' + result['results'][0]['state'] + ', ' + result['results'][0]['country'])
|
||||||
except:
|
## except:
|
||||||
city = result['results'][0]['country']
|
## city = result['results'][0]['country']
|
||||||
for i in result['results']:
|
## for i in result['results']:
|
||||||
id_list[i['id']] = 0
|
## id_list[i['id']] = 0
|
||||||
return str([id_list, f_name, l_name, city])
|
## return str([id_list, f_name, l_name, city])
|
||||||
except:
|
## except:
|
||||||
return str([{}, '', '', ''])
|
## return str([{}, '', '', ''])
|
||||||
|
##
|
||||||
|
##
|
||||||
# Return string in NATO phonetics
|
### Return string in NATO phonetics
|
||||||
def convert_nato(string):
|
##def convert_nato(string):
|
||||||
d_nato = { 'A': 'ALPHA', 'B': 'BRAVO', 'C': 'CHARLIE', 'D': 'DELTA',
|
## d_nato = { 'A': 'ALPHA', 'B': 'BRAVO', 'C': 'CHARLIE', 'D': 'DELTA',
|
||||||
'E': 'ECHO', 'F': 'FOXTROT', 'G': 'GOLF', 'H': 'HOTEL',
|
## 'E': 'ECHO', 'F': 'FOXTROT', 'G': 'GOLF', 'H': 'HOTEL',
|
||||||
'I': 'INDIA', 'J': 'JULIETT','K': 'KILO', 'L': 'LIMA',
|
## 'I': 'INDIA', 'J': 'JULIETT','K': 'KILO', 'L': 'LIMA',
|
||||||
'M': 'MIKE', 'N': 'NOVEMBER','O': 'OSCAR', 'P': 'PAPA',
|
## 'M': 'MIKE', 'N': 'NOVEMBER','O': 'OSCAR', 'P': 'PAPA',
|
||||||
'Q': 'QUEBEC', 'R': 'ROMEO', 'S': 'SIERRA', 'T': 'TANGO',
|
## 'Q': 'QUEBEC', 'R': 'ROMEO', 'S': 'SIERRA', 'T': 'TANGO',
|
||||||
'U': 'UNIFORM', 'V': 'VICTOR', 'W': 'WHISKEY', 'X': 'X-RAY',
|
## 'U': 'UNIFORM', 'V': 'VICTOR', 'W': 'WHISKEY', 'X': 'X-RAY',
|
||||||
'Y': 'YANKEE', 'Z': 'ZULU', '0': 'zero(0)', '1': 'one(1)',
|
## 'Y': 'YANKEE', 'Z': 'ZULU', '0': 'zero(0)', '1': 'one(1)',
|
||||||
'2': 'two(2)', '3': 'three(3)', '4': 'four(4)', '5': 'five(5)',
|
## '2': 'two(2)', '3': 'three(3)', '4': 'four(4)', '5': 'five(5)',
|
||||||
'6': 'six(6)', '7': 'seven(7)', '8': 'eight(8)', '9': 'nine(9)',
|
## '6': 'six(6)', '7': 'seven(7)', '8': 'eight(8)', '9': 'nine(9)',
|
||||||
'a': 'alpha', 'b': 'bravo', 'c': 'charlie', 'd': 'delta',
|
## 'a': 'alpha', 'b': 'bravo', 'c': 'charlie', 'd': 'delta',
|
||||||
'e': 'echo', 'f': 'foxtrot', 'g': 'golf', 'h': 'hotel',
|
## 'e': 'echo', 'f': 'foxtrot', 'g': 'golf', 'h': 'hotel',
|
||||||
'i': 'india', 'j': 'juliett','k': 'kilo', 'l': 'lima',
|
## 'i': 'india', 'j': 'juliett','k': 'kilo', 'l': 'lima',
|
||||||
'm': 'mike', 'n': 'november','o': 'oscar', 'p': 'papa',
|
## 'm': 'mike', 'n': 'november','o': 'oscar', 'p': 'papa',
|
||||||
'q': 'quebec', 'r': 'romeo', 's': 'sierra', 't': 'tango',
|
## 'q': 'quebec', 'r': 'romeo', 's': 'sierra', 't': 'tango',
|
||||||
'u': 'uniform', 'v': 'victor', 'w': 'whiskey', 'x': 'x-ray',
|
## 'u': 'uniform', 'v': 'victor', 'w': 'whiskey', 'x': 'x-ray',
|
||||||
'y': 'yankee', 'z': 'Zulu'}
|
## 'y': 'yankee', 'z': 'Zulu'}
|
||||||
ns = ''
|
## ns = ''
|
||||||
for c in string:
|
## for c in string:
|
||||||
try:
|
## try:
|
||||||
ns = ns + d_nato[c] + ' '
|
## ns = ns + d_nato[c] + ' '
|
||||||
except:
|
## except:
|
||||||
ns = ns + c + ' '
|
## ns = ns + c + ' '
|
||||||
return ns
|
## return ns
|
||||||
|
|
||||||
# Class-based application configuration
|
# Class-based application configuration
|
||||||
class ConfigClass(object):
|
class ConfigClass(object):
|
||||||
@ -662,108 +665,108 @@ def create_app():
|
|||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
# The Home page is accessible to anyone
|
## # The Home page is accessible to anyone
|
||||||
@app.route('/')
|
## @app.route('/')
|
||||||
def home_page():
|
## def home_page():
|
||||||
home_text = Misc.query.filter_by(field_1='home_page').first()
|
## home_text = Misc.query.filter_by(field_1='home_page').first()
|
||||||
#content = Markup('<strong>Index</strong>')
|
## #content = Markup('<strong>Index</strong>')
|
||||||
try:
|
## try:
|
||||||
l_news = News.query.order_by(News.time.desc()).first()
|
## l_news = News.query.order_by(News.time.desc()).first()
|
||||||
content = '''
|
## content = '''
|
||||||
|
##
|
||||||
<div class="well well-sm" style="text-align: center;"><h3>''' + l_news.subject + '''</h3>
|
##<div class="well well-sm" style="text-align: center;"><h3>''' + l_news.subject + '''</h3>
|
||||||
<hr />
|
##<hr />
|
||||||
<p> </p>
|
##<p> </p>
|
||||||
<strong>''' + l_news.date + '''</strong> - <a href="/news/''' + str(l_news.id) + '''"><button type="button" class="btn btn-primary">Link</button></a>
|
##<strong>''' + l_news.date + '''</strong> - <a href="/news/''' + str(l_news.id) + '''"><button type="button" class="btn btn-primary">Link</button></a>
|
||||||
<p> </p>
|
##<p> </p>
|
||||||
|
##
|
||||||
<hr />
|
##<hr />
|
||||||
<div class="well well-sm" style="max-width:900px; word-wrap:break-word;">
|
##<div class="well well-sm" style="max-width:900px; word-wrap:break-word;">
|
||||||
''' + l_news.text + '''
|
##''' + l_news.text + '''
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
'''
|
|
||||||
except:
|
|
||||||
content = ''
|
|
||||||
return render_template('index.html', news = Markup(content), content_block = Markup(home_text.field_2))
|
|
||||||
|
|
||||||
@app.route('/tos')
|
|
||||||
def tos_page():
|
|
||||||
tos_text = Misc.query.filter_by(field_1='terms_of_service').first()
|
|
||||||
content = tos_text.field_2
|
|
||||||
|
|
||||||
return render_template('flask_user_layout.html', markup_content = Markup(content))
|
|
||||||
|
|
||||||
@app.route('/map')
|
|
||||||
@login_required
|
|
||||||
def map_page():
|
|
||||||
print(peer_locations)
|
|
||||||
f_map = folium.Map(location=center_map, zoom_start=map_zoom)
|
|
||||||
for l in peer_locations.items():
|
|
||||||
## folium.Marker([float(l[1][1]), float(l[1][2])], popup='''
|
|
||||||
##<div class="panel panel-default">
|
|
||||||
## <div class="panel-heading" style="text-align: center;"><h4>''' + l[1][0] + '''</h4></div>
|
|
||||||
## <div class="panel-body">
|
|
||||||
## ''' + l[1][5] + '''
|
|
||||||
## <hr />
|
|
||||||
## ''' + l[1][1] + ''', ''' + l[1][2] + '''
|
|
||||||
## <hr />
|
|
||||||
## ''' + l[1][3] + '''
|
|
||||||
## <hr />
|
|
||||||
## ''' + l[1][4] + '''
|
|
||||||
## <hr />
|
|
||||||
## ''' + l[1][6] + '''
|
|
||||||
## </div>
|
|
||||||
##</div>
|
##</div>
|
||||||
|
##</div>
|
||||||
|
##
|
||||||
|
## </div>
|
||||||
|
## '''
|
||||||
|
## except:
|
||||||
|
## content = ''
|
||||||
|
## return render_template('index.html', news = Markup(content), content_block = Markup(home_text.field_2))
|
||||||
|
##
|
||||||
|
## @app.route('/tos')
|
||||||
|
## def tos_page():
|
||||||
|
## tos_text = Misc.query.filter_by(field_1='terms_of_service').first()
|
||||||
|
## content = tos_text.field_2
|
||||||
|
##
|
||||||
|
## return render_template('flask_user_layout.html', markup_content = Markup(content))
|
||||||
|
##
|
||||||
|
## @app.route('/map')
|
||||||
|
## @login_required
|
||||||
|
## def map_page():
|
||||||
|
## print(peer_locations)
|
||||||
|
## f_map = folium.Map(location=center_map, zoom_start=map_zoom)
|
||||||
|
## for l in peer_locations.items():
|
||||||
|
#### folium.Marker([float(l[1][1]), float(l[1][2])], popup='''
|
||||||
|
####<div class="panel panel-default">
|
||||||
|
#### <div class="panel-heading" style="text-align: center;"><h4>''' + l[1][0] + '''</h4></div>
|
||||||
|
#### <div class="panel-body">
|
||||||
|
#### ''' + l[1][5] + '''
|
||||||
|
#### <hr />
|
||||||
|
#### ''' + l[1][1] + ''', ''' + l[1][2] + '''
|
||||||
|
#### <hr />
|
||||||
|
#### ''' + l[1][3] + '''
|
||||||
|
#### <hr />
|
||||||
|
#### ''' + l[1][4] + '''
|
||||||
|
#### <hr />
|
||||||
|
#### ''' + l[1][6] + '''
|
||||||
|
#### </div>
|
||||||
|
####</div>
|
||||||
|
#### ''', icon=folium.Icon(color="red", icon="record"), tooltip='<strong>' + l[1][0] + '</strong>').add_to(f_map)
|
||||||
|
##
|
||||||
|
## folium.Marker([float(l[1][1]), float(l[1][2])], popup='''
|
||||||
|
##<table border="1">
|
||||||
|
##<tbody>
|
||||||
|
##<tr>
|
||||||
|
##<td> <strong><h4>''' + l[1][0] + '''</strong></h4> </td>
|
||||||
|
##</tr>
|
||||||
|
##</tbody>
|
||||||
|
##</table>
|
||||||
|
##<table border="1">
|
||||||
|
##<tbody>
|
||||||
|
##<tr>
|
||||||
|
##<td style="width: 64.4667px;"><strong>DMR ID:</strong></td>
|
||||||
|
##<td> ''' + str(l[0]) + ''' </td>
|
||||||
|
##</tr>
|
||||||
|
##<tr>
|
||||||
|
##<td style="width: 64.4667px;"><strong>Location:</strong></td>
|
||||||
|
##<td> ''' + l[1][5] + ''' </td>
|
||||||
|
##</tr>
|
||||||
|
##<tr>
|
||||||
|
##<td style="width: 64.4667px;"><strong>Lat, Lon:</strong></td>
|
||||||
|
##<td> ''' + l[1][1] + ''', ''' + l[1][2] + ''' </td>
|
||||||
|
##</tr>
|
||||||
|
##<tr>
|
||||||
|
##<td style="width: 64.4667px;"><strong>Description:</strong></td>
|
||||||
|
##<td> ''' + l[1][4] + ''' </td>
|
||||||
|
##</tr>
|
||||||
|
##<tr>
|
||||||
|
##<td style="width: 64.4667px;"><p><strong>URL:</strong></p>
|
||||||
|
##</td>
|
||||||
|
##<td><a href="''' + l[1][3] + '''"> ''' + l[1][3] + ''' </a></td>
|
||||||
|
##</tr>
|
||||||
|
##<tr>
|
||||||
|
##<td style="width: 64.4667px;"><strong>Device:</strong></td>
|
||||||
|
##<td> ''' + l[1][6] + ''' </td>
|
||||||
|
##</tr>
|
||||||
|
##</tbody>
|
||||||
|
##</table>
|
||||||
## ''', icon=folium.Icon(color="red", icon="record"), tooltip='<strong>' + l[1][0] + '</strong>').add_to(f_map)
|
## ''', icon=folium.Icon(color="red", icon="record"), tooltip='<strong>' + l[1][0] + '</strong>').add_to(f_map)
|
||||||
|
## content = f_map._repr_html_()
|
||||||
folium.Marker([float(l[1][1]), float(l[1][2])], popup='''
|
##
|
||||||
<table border="1">
|
## return render_template('map.html', markup_content = Markup(content))
|
||||||
<tbody>
|
##
|
||||||
<tr>
|
## @app.route('/help')
|
||||||
<td> <strong><h4>''' + l[1][0] + '''</strong></h4> </td>
|
## def help_page():
|
||||||
</tr>
|
## return render_template('help.html')
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<table border="1">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td style="width: 64.4667px;"><strong>DMR ID:</strong></td>
|
|
||||||
<td> ''' + str(l[0]) + ''' </td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td style="width: 64.4667px;"><strong>Location:</strong></td>
|
|
||||||
<td> ''' + l[1][5] + ''' </td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td style="width: 64.4667px;"><strong>Lat, Lon:</strong></td>
|
|
||||||
<td> ''' + l[1][1] + ''', ''' + l[1][2] + ''' </td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td style="width: 64.4667px;"><strong>Description:</strong></td>
|
|
||||||
<td> ''' + l[1][4] + ''' </td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td style="width: 64.4667px;"><p><strong>URL:</strong></p>
|
|
||||||
</td>
|
|
||||||
<td><a href="''' + l[1][3] + '''"> ''' + l[1][3] + ''' </a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td style="width: 64.4667px;"><strong>Device:</strong></td>
|
|
||||||
<td> ''' + l[1][6] + ''' </td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
''', icon=folium.Icon(color="red", icon="record"), tooltip='<strong>' + l[1][0] + '</strong>').add_to(f_map)
|
|
||||||
content = f_map._repr_html_()
|
|
||||||
|
|
||||||
return render_template('map.html', markup_content = Markup(content))
|
|
||||||
|
|
||||||
@app.route('/help')
|
|
||||||
def help_page():
|
|
||||||
return render_template('help.html')
|
|
||||||
|
|
||||||
@app.route('/generate_passphrase/pi-star', methods = ['GET'])
|
@app.route('/generate_passphrase/pi-star', methods = ['GET'])
|
||||||
@login_required
|
@login_required
|
||||||
@ -1150,6 +1153,8 @@ def create_app():
|
|||||||
if request.form.get('callsign'):
|
if request.form.get('callsign'):
|
||||||
callsign = request.form.get('callsign')
|
callsign = request.form.get('callsign')
|
||||||
u = User.query.filter_by(username=callsign).first()
|
u = User.query.filter_by(username=callsign).first()
|
||||||
|
if u.notes = None:
|
||||||
|
user_notes = ''
|
||||||
confirm_link = ''
|
confirm_link = ''
|
||||||
if u.email_confirmed_at == None:
|
if u.email_confirmed_at == None:
|
||||||
confirm_link = '''<p style="text-align: center;"><a href="''' + url + '/edit_user?email_verified=true&callsign=' + str(u.username) + '''"><strong>Verify email - <strong>''' + str(u.username) + '''</strong></strong></a></p>\n'''
|
confirm_link = '''<p style="text-align: center;"><a href="''' + url + '/edit_user?email_verified=true&callsign=' + str(u.username) + '''"><strong>Verify email - <strong>''' + str(u.username) + '''</strong></strong></a></p>\n'''
|
||||||
@ -1281,7 +1286,7 @@ def create_app():
|
|||||||
|
|
||||||
<tr style="height: 51.1667px;">
|
<tr style="height: 51.1667px;">
|
||||||
<td style="height: 51.1667px; text-align: center;">
|
<td style="height: 51.1667px; text-align: center;">
|
||||||
<label for="message">Notes<br /></label></strong><br /><textarea cols="40" name="notes" rows="5" >''' + str(u.notes) + '''</textarea><br /><br />
|
<label for="message">Notes<br /></label></strong><br /><textarea cols="40" name="notes" rows="5" >''' + str(user_notes) + '''</textarea><br /><br />
|
||||||
</td></tr>
|
</td></tr>
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,28 +28,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<table id="table_id" class="display">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Column 1</th>
|
|
||||||
<th>Column 2</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>Row 1 Data 1</td>
|
|
||||||
<td>Row 1 Data 2</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Row 2 Data 1</td>
|
|
||||||
<td>Row 2 Data 2</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<p> </p>
|
<p> </p>
|
||||||
<script type = "text/javascript">
|
<script type = "text/javascript">
|
||||||
$(document).ready( function () {
|
$(document).ready( function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user