mirror of https://github.com/kf7eel/hbnet.git
fix icons, add menu items, initial commit of discussion
This commit is contained in:
parent
354e05c141
commit
8e36d1794a
61
web/app.py
61
web/app.py
|
|
@ -504,6 +504,14 @@ def hbnet_web_service():
|
|||
query_term = db.Column(db.String(100), nullable=False, server_default='', unique=False)
|
||||
time = db.Column(db.DateTime())
|
||||
|
||||
class Disc(db.Model):
|
||||
__tablename__ = 'discussion'
|
||||
id = db.Column(db.Integer(), primary_key=True)
|
||||
poster = db.Column(db.String(200), nullable=False, server_default='')
|
||||
text = db.Column(db.String(5000), nullable=False, server_default='')
|
||||
time = db.Column(db.DateTime())
|
||||
|
||||
|
||||
class Misc(db.Model):
|
||||
__tablename__ = 'misc'
|
||||
id = db.Column(db.Integer(), primary_key=True)
|
||||
|
|
@ -2550,6 +2558,45 @@ TG #: <strong> ''' + str(tg_d.tg) + '''</strong>
|
|||
</tr>'''
|
||||
return render_template('tp_all.html', markup_content = Markup(content))
|
||||
|
||||
|
||||
@app.route('/discussion', methods=['POST', 'GET'])
|
||||
def portal_discussion():
|
||||
## dl = Disc.query.order_by(Disc.time.desc()).limit(30).all()
|
||||
dl = Disc.query.order_by(Disc.time.desc()).all()
|
||||
content = ''' '''
|
||||
show_table = True
|
||||
if request.args.get('post'):
|
||||
## tp_add(u.username, request.form.get('query'), request.form.get('content'))
|
||||
disc_add(current_user.username, request.form.get('message'))
|
||||
show_table = False
|
||||
content = '''<h3 style="text-align: center;">Added post.</h3>
|
||||
<p style="text-align: center;">Redirecting in 1 seconds.</p>
|
||||
<meta http-equiv="refresh" content="1; URL=/discussion" /> '''
|
||||
elif request.args.get('delete'):
|
||||
## tp_add(u.username, request.form.get('query'), request.form.get('content'))
|
||||
disc_del(request.args.get('delete'))
|
||||
show_table = False
|
||||
content = '''<h3 style="text-align: center;">Deleted post.</h3>
|
||||
<p style="text-align: center;">Redirecting in 1 seconds.</p>
|
||||
<meta http-equiv="refresh" content="1; URL=/discussion" /> '''
|
||||
else:
|
||||
|
||||
for i in dl:
|
||||
try:
|
||||
options_l = ''
|
||||
if str(current_user.username).upper() == str(i.poster).upper():
|
||||
options_l = '''<a href="/discussion?delete=''' + str(i.id) + '''"><button type="button" class="btn btn-danger">Delete</button></a>'''
|
||||
except:
|
||||
options_l = ''
|
||||
content = content + '''
|
||||
<tr>
|
||||
<td><strong>''' + i.poster + '''</strong></td>
|
||||
<td>''' + i.text + '''</td>
|
||||
<td>''' + options_l + '''</td>
|
||||
</tr>'''
|
||||
return render_template('disc.html', markup_content = Markup(content), table = show_table)
|
||||
|
||||
|
||||
@app.route('/add_tp', methods=['POST', 'GET'])
|
||||
@login_required
|
||||
def new_tp():
|
||||
|
|
@ -2993,6 +3040,15 @@ Name: <strong>''' + p.name + '''</strong> - Port: <strong>''' + str(
|
|||
db.session.add(add_loc)
|
||||
db.session.commit()
|
||||
|
||||
def disc_add(_poster, _text):
|
||||
add_d = Disc(
|
||||
poster = _poster,
|
||||
text = _text,
|
||||
time = datetime.datetime.utcnow(),
|
||||
)
|
||||
db.session.add(add_d)
|
||||
db.session.commit()
|
||||
|
||||
def tp_add(_author, _query_term, _content):
|
||||
add_tp = TinyPage(
|
||||
author = _author,
|
||||
|
|
@ -3046,6 +3102,11 @@ Name: <strong>''' + p.name + '''</strong> - Port: <strong>''' + str(
|
|||
db.session.delete(tpd)
|
||||
db.session.commit()
|
||||
|
||||
def disc_del(_id):
|
||||
dd = Disc.query.filter_by(id=_id).first()
|
||||
db.session.delete(dd)
|
||||
db.session.commit()
|
||||
|
||||
def sms_log_add(_snd_call, _rcv_call, _msg, _snd_id, _rcv_id, _server, _system_name):
|
||||
add_sms = SMSLog(
|
||||
snd_callsign = _snd_call,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
{% extends 'flask_user/_public_base.html' %}
|
||||
{% block content %}
|
||||
|
||||
<h1 style="text-align: center;">Discussion</h1>
|
||||
|
||||
|
||||
<div id="post" class="collapse">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">Post to the discussion</div>
|
||||
<div class="card-body">
|
||||
|
||||
<form action="discussion?post=true" method="post">
|
||||
|
||||
<div class="input-group">
|
||||
<span class="input-group-text">Message</span>
|
||||
<textarea id="message" name="message" class="form-control" aria-label="Message"></textarea>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<p style="text-align: center;"><input class="btn btn-primary" type="submit" value="Post" /></form></p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{% if table %}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
{% if call_or_get(current_user.is_authenticated) %}
|
||||
<p style="text-align: right;"><button data-bs-toggle="collapse" data-bs-target="#post" class="btn btn-primary">Add Post</button></p>
|
||||
{% endif %}
|
||||
<table data-toggle="table" data-pagination="true" data-search="true" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Author</th>
|
||||
<th>Post</th>
|
||||
<th>Options</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% endif %}
|
||||
|
||||
{{markup_content}}
|
||||
{% if table %}
|
||||
|
||||
</tbody></table>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
|
||||
<p> </p>
|
||||
{% endblock %}
|
||||
|
|
@ -111,16 +111,43 @@
|
|||
</ul>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
<!--
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{url}}/mail/{{ current_user.username or current_user.email }}"><i class="bi bi-mailbox"></i> Mailbox </a>
|
||||
</li>
|
||||
-->
|
||||
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="features_menu" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="bi bi-arrow-down-square"></i> Features
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="features_menu">
|
||||
<li><a class="dropdown-item" href="{{url}}/mail/{{ current_user.username or current_user.email }}"><i class="bi bi-mailbox"></i> Mailbox </a></li>
|
||||
<li><a class="dropdown-item" href="{{url}}/discussion"><i class="bi bi-chat-right-quote"></i> Discussion </a></li>
|
||||
<li><a class="dropdown-item" href="{{url}}/generate_passphrase"><i class="bi bi-info-square"></i> Passphrase(s) </a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="settings_menu" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="bi bi-toggles"></i> Settings
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="settings_menu">
|
||||
|
||||
<li><a class="dropdown-item" href="{{ url_for('user.edit_user_profile') }}"><i class="bi bi-file-person"></i> Change {{ current_user.username or current_user.email }} </a></li>
|
||||
<li><a class="dropdown-item" href="{{url}}/aprs_settings"><i class="bi bi-geo"></i> APRS Configuration </a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<!--
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{url}}/generate_passphrase"><i class="bi bi-info-square"></i> Passphrase(s) </a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('user.edit_user_profile') }}"><i class="bi bi-file-person"></i> Change {{ current_user.username or current_user.email }} </a>
|
||||
</li>
|
||||
-->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('user.logout') }}"><i class="bi bi-door-closed"></i> Sign Out </a>
|
||||
</li>
|
||||
|
|
|
|||
Loading…
Reference in New Issue