1
Fork 0
mirror of https://github.com/Steffo99/estus.git synced 2024-11-25 17:14:19 +00:00

Fix bugs in Dispositivo

This commit is contained in:
Lorenzo 2017-09-11 15:00:04 +02:00
parent ac74f31b67
commit 055cbf207b
4 changed files with 50 additions and 9 deletions

View file

@ -1,6 +1,7 @@
from flask import Flask, session, url_for, redirect, request, render_template, abort from flask import Flask, session, url_for, redirect, request, render_template, abort
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
import bcrypt import bcrypt
import os
app = Flask(__name__) app = Flask(__name__)
app.secret_key = "pepsecret" app.secret_key = "pepsecret"
@ -106,6 +107,16 @@ class Accesso(db.Model):
return "<Accesso {} su {}>".format(self.iid, self.did) return "<Accesso {} su {}>".format(self.iid, self.did)
class FakeAccesso:
def __init__(self, dispositivo):
self.did = dispositivo.did
self.iid = None
self.dispositivo = dispositivo
def __getitem__(self, key):
if key == 0:
return self.dispositivo
# Funzioni del sito # Funzioni del sito
def login(username, password): def login(username, password):
user = User.query.filter_by(username=username).first() user = User.query.filter_by(username=username).first()
@ -246,6 +257,15 @@ def page_serv_list():
return render_template("servizio/list.htm", css=css, serv=serv, type="serv", user=session["username"]) return render_template("servizio/list.htm", css=css, serv=serv, type="serv", user=session["username"])
@app.route('/serv_list/<int:eid>')
def page_serv_list_plus(eid):
if 'username' not in session:
return redirect(url_for('page_login'))
serv = Servizio.query.join(Ente).filter_by(eid=eid).all()
css = url_for("static", filename="style.css")
return render_template("servizio/list.htm", css=css, serv=serv, type="serv", user=session["username"])
@app.route('/serv_show/<int:sid>', methods=['GET', 'POST']) @app.route('/serv_show/<int:sid>', methods=['GET', 'POST'])
def page_serv_show(sid): def page_serv_show(sid):
if 'username' not in session: if 'username' not in session:
@ -377,14 +397,21 @@ def page_disp_list():
dispositivi = Dispositivo.query.all() dispositivi = Dispositivo.query.all()
for dispositivo in dispositivi: for dispositivo in dispositivi:
accesso = Accesso.query.join(Dispositivo).filter_by(did=dispositivo.did).join(Impiegato).all() accesso = Accesso.query.join(Dispositivo).filter_by(did=dispositivo.did).join(Impiegato).all()
if not accesso:
accessi.append([FakeAccesso(dispositivo)])
else:
accessi.append(accesso) accessi.append(accesso)
css = url_for("static", filename="style.css") css = url_for("static", filename="style.css")
return render_template("dispositivo/list.htm", css=css, accessi=accessi, type="disp", user=session["username"]) return render_template("dispositivo/list.htm", css=css, accessi=accessi, type="disp", user=session["username"])
@app.route('/disp_details') @app.route('/disp_details/<int:did>')
def page_details_host(): def page_details_host(did):
raise NotImplementedError() if 'username' not in session:
return redirect(url_for('page_login'))
disp = Dispositivo.query.get(did)
css = url_for("static", filename="style.css")
return render_template("dispositivo/details.htm", css=css, disp=disp, type="disp", user=session["username"])
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -0,0 +1,15 @@
{% extends "base.htm" %}
{% block content %}
<ul class="list-group">
{% for ente in conteggioservizi %}
<li class="list-group-item">
<div class="list-group-item-heading">
Sassi
</div>
<div class="list-group-item-text">
10
</div>
</li>
{% endfor %}
</ul>
{% endblock %}

View file

@ -1,5 +1,4 @@
{% extends "base.htm" %} {% extends "base.htm" %}
{% block title %}Elenco dispositivi{% endblock %}
{% block content %} {% block content %}
<h1> <h1>
Dispositivi esistenti Dispositivi esistenti
@ -27,8 +26,8 @@
<td>{{ d[0].dispositivo.marca }}</td> <td>{{ d[0].dispositivo.marca }}</td>
<td>{{ d[0].dispositivo.modello }}</td> <td>{{ d[0].dispositivo.modello }}</td>
<td>{{ d[0].dispositivo.fornitore }}</td> <td>{{ d[0].dispositivo.fornitore }}</td>
<td><a href="/disp_details/{{ d.did }}"><span class="glyphicon glyphicon-list-alt"></span></a></td> <td><a href="/disp_details/{{ d[0].did }}"><span class="glyphicon glyphicon-list-alt"></span></a></td>
<td><a href="/disp_del/{{ d.did }}"><span class="glyphicon glyphicon-remove"></span></a></td> <td><a href="/disp_del/{{ d[0].did }}"><span class="glyphicon glyphicon-remove"></span></a></td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>

View file

@ -21,8 +21,8 @@
<td>{{ imp.servizio.ente.nomeente }}</td> <td>{{ imp.servizio.ente.nomeente }}</td>
<td>{{ imp.servizio.nomeservizio }} <td>{{ imp.servizio.nomeservizio }}
<td>{{ imp.nomeimpiegato }}</td> <td>{{ imp.nomeimpiegato }}</td>
<td><span class="monospace">{{ imp.username }}</span></td> <td><code>{{ imp.username }}</code></td>
<td><span class="monospace">{{ imp.passwd }}</span></td> <td><code>{{ imp.passwd }}</code></td>
<td><a href="/imp_show/{{ imp.iid }}"><span class="glyphicon glyphicon-pencil"></span></a></td> <td><a href="/imp_show/{{ imp.iid }}"><span class="glyphicon glyphicon-pencil"></span></a></td>
<td><a href="/imp_del/{{ imp.iid }}"><span class="glyphicon glyphicon-remove"></span></a></td> <td><a href="/imp_del/{{ imp.iid }}"><span class="glyphicon glyphicon-remove"></span></a></td>
</tr> </tr>