Пример #1
0
    def get_newMessagesCount():

        notifications = 0
        if auth_module.get_userobject()[0].notification_lastread is None:
            notifications = notifications_messages.query.filter_by(user_id=auth_module.get_userobject()[0].id).count()
        else:
            notifications = notifications_messages.query.filter_by(user_id=auth_module.get_userobject()[0].id). \
                filter(
                notifications_messages.date_created >= auth_module.get_userobject()[0].notification_lastread).count()

        return jsonify([{'message_count': notifications}])
Пример #2
0
    def get_lastread():
        # Add current time as lastread time in the user Profile
        current_user = User.query.filter_by(id=auth_module.get_userobject()[0].id).first()
        current_user.notification_lastread = datetime.datetime.now()
        db.session.commit()

        return "OK"
Пример #3
0
def uebersicht():
    # Query for AS Statistics overview
    result = db.engine.execute(
        "SELECT Firefighter.grad AS Firefighter_grad,"
        "Firefighter.vorname AS vorname,"
        "Firefighter.name AS name,"
        "FF_Zug.name AS zug,"
        "(SELECT sum(AS_Entry.time) AS sum_1 FROM AS_Entry "
        "WHERE AS_Entry.member_id = Firefighter.id AND AS_Entry.datum > date('now','start of year')) AS time "
        "FROM Firefighter, FF_Zugmapping AS FF_Zugmapping_1, FF_Zug, alarmgroups "
        "WHERE FF_Zugmapping_1.ff_zug_id == FF_Zug.id AND FF_Zugmapping_1.firefighter_id == Firefighter.id "
        "AND alarmgroups.firefighter_id = Firefighter.id AND "
        "alarmgroups.alarmgroup_id = (SELECT ID From AlarmGroup WHERE Name = 'Atemschutz') "
        "AND Firefighter.is_deleted = 0 "
        "ORDER BY grad_sort")

    as_statistics = result.fetchall()
    result.close()

    date_lastYear = datetime.now().date() - relativedelta(months=13)
    return render_template(
        "mod_atemschutz/index.html",
        user=auth_module.get_userobject(),
        statistics=as_statistics,
        entries=Entry.query.filter(
            func.DATE(Entry.datum) > date_lastYear).all(),
        categories=Category.query.all(),
        firefighters=Firefighter.query.filter_by(is_deleted=False).all())
Пример #4
0
    def get_Messages(count):
        notifications = notifications_messages.query.filter_by(user_id=auth_module.get_userobject()[0].id).order_by(
            db.desc(notifications_messages.date_created)).limit(count).all()

        json_array = []
        for message in notifications:
            json_array.append(message.to_dict())
        return json.dumps(json_array)
Пример #5
0
def get_gvzUpdate():

    return render_template("mod_alarm/gvzStatus.html",
                           user=auth_module.get_userobject(),
                           firefighters=Firefighter.query.all(),
                           settings=db.session.query(GVZupdate).order_by(
                               GVZupdate.id.desc()).first(),
                           entries=db.session.query(GVZnotAvailable).all())
Пример #6
0
def get_notifications():
    current_user = auth_module.get_userobject()

    notifications = Notifications_messages.query.filter(
        Notifications_messages.timestamp > current_user.notification_lastread).order_by(
        Notifications_messages.timestamp.asc())
    return jsonify([{
        'name': n.name,
        'data': n.get_data(),
        'timestamp': n.timestamp,
        'url': n.url
    } for n in notifications])
Пример #7
0
def auswertung():
    result = db.engine.execute(
        "SELECT Firefighter.grad_sort as grad_sort, Firefighter.id as id,"
        "Firefighter.vorname AS vorname,"
        "Firefighter.name AS name,"
        "Firefighter.eintritt AS eintritt,"
        "IFNULL((SELECT SUM(Sub1.time) FROM AS_Entry AS Sub1 "
        "WHERE Sub1.datum BETWEEN strftime('%Y-01-01','now','-1 year') AND strftime('%Y-12-31','now','-1 year') "
        "AND Sub1.member_id = Firefighter.id),0) AS 'one_year', "
        "IFNULL((SELECT SUM(Sub1.time) FROM AS_Entry AS Sub1 LEFT JOIN AS_Category As Sub2 ON (Sub1.category_id = Sub2.id) "
        "WHERE Sub1.datum BETWEEN strftime('%Y-01-01','now','-1 year') AND strftime('%Y-12-31','now','-1 year') "
        "AND Sub2.training = 1 "
        "AND Sub1.member_id = Firefighter.id),0) AS 'one_year_training', "
        "IFNULL((SELECT SUM(Sub1.time) FROM AS_Entry AS Sub1  "
        "WHERE Sub1.datum BETWEEN strftime('%Y-01-01','now','-2 year') AND strftime('%Y-12-31','now','-2 year') "
        "AND Sub1.member_id = Firefighter.id),0) AS 'two_year', "
        "IFNULL((SELECT SUM(Sub1.time) FROM AS_Entry AS Sub1 LEFT JOIN AS_Category As Sub2 ON (Sub1.category_id = Sub2.id) "
        "WHERE Sub1.datum BETWEEN strftime('%Y-01-01','now','-2 year') AND strftime('%Y-12-31','now','-2 year') "
        "AND Sub2.training = 1 "
        "AND Sub1.member_id = Firefighter.id),0) AS 'two_year_training', "
        "IFNULL((SELECT SUM(Sub1.time) FROM AS_Entry AS Sub1 "
        "WHERE Sub1.datum BETWEEN strftime('%Y-01-01','now','-3 year') AND strftime('%Y-12-31','now','-3 year') "
        "AND Sub1.member_id = Firefighter.id),0) AS 'three_year', "
        "IFNULL((SELECT SUM(Sub1.time) FROM AS_Entry AS Sub1 LEFT JOIN AS_Category As Sub2 ON (Sub1.category_id = Sub2.id) "
        "WHERE Sub1.datum BETWEEN strftime('%Y-01-01','now','-3 year') AND strftime('%Y-12-31','now','-3 year') "
        "AND Sub2.training = 1 "
        "AND Sub1.member_id = Firefighter.id),0) AS 'three_year_training', "
        "IFNULL((SELECT SUM(Sub1.time) FROM AS_Entry AS Sub1 "
        "WHERE Sub1.datum BETWEEN strftime('%Y-01-01','now','-4 year') AND strftime('%Y-12-31','now','-4 year') "
        "AND Sub1.member_id = Firefighter.id),0) AS 'four_year', "
        "IFNULL((SELECT SUM(Sub1.time) FROM AS_Entry AS Sub1 LEFT JOIN AS_Category As Sub2 ON (Sub1.category_id = Sub2.id) "
        "WHERE Sub1.datum BETWEEN strftime('%Y-01-01','now','-4 year') AND strftime('%Y-12-31','now','-4 year') "
        "AND Sub2.training = 1 "
        "AND Sub1.member_id = Firefighter.id),0) AS 'four_year_training', "
        "strftime('%Y','now','-1 year') AS 'one_year_name', "
        "strftime('%Y','now','-2 year') AS 'two_year_name', "
        "strftime('%Y','now','-3 year') AS 'three_year_name', "
        "strftime('%Y','now','-4 year') AS 'four_year_name' "
        "FROM Firefighter, alarmgroups "
        "WHERE alarmgroups.firefighter_id = Firefighter.id "
        "AND alarmgroups.alarmgroup_id = (SELECT ID From AlarmGroup WHERE Name = 'Atemschutz') "
        "AND Firefighter.is_deleted = 0 "
        "GROUP BY Firefighter.id ORDER BY Firefighter.grad_sort, Firefighter.name"
    )
    year_statistics = result.fetchall()
    result.close()

    return render_template("mod_atemschutz/auswertung.html",
                           user=auth_module.get_userobject(),
                           statistics=year_statistics,
                           entries=Entry.query.all(),
                           categories=Category.query.all(),
                           firefighters=Firefighter.query.all())
Пример #8
0
def post_statusUpdateEntry():
    try:

        isDriver = Firefighter.query.filter(Firefighter.id.is_(request.form.get('firefighters')))\
            .join(Firefighter.alarmgroups, aliased=True)\
            .filter_by(name='Grossfahrzeuge').scalar() is not None #Check if Firefighter is Driver
        isKader = Firefighter.query.filter(db.and_(Firefighter.id.is_(request.form.get('firefighters')),\
            Firefighter.grad_sort<6)).scalar() is not None

        if isDriver == True:
            isDriver = 1
        else:
            isDriver = 0

        if isKader == True:
            isKader = 1
        else:
            isKader = 0

        print()
        if request.form.get('entry_id') == "":
            db.session.add(
                GVZnotAvailable(
                    request.form.get('firefighters'),
                    datetime.strptime(request.form.get('datumvon'),
                                      '%d.%m.%Y'),
                    datetime.strptime(request.form.get('datumbis'),
                                      '%d.%m.%Y'),
                    request.form.get('art'),
                    isDriver,
                    isKader,
                    auth_module.get_userobject()[0].username  #reportedby
                ))
        else:
            entry = GVZnotAvailable.query.get(request.form.get('entry_id'))
            entry.id = request.form.get('entry_id')
            entry.datumvon = datetime.strptime(request.form.get('datumvon'),
                                               '%d.%m.%Y')
            entry.datumbis = datetime.strptime(request.form.get('datumbis'),
                                               '%d.%m.%Y')
            entry.member_id = request.form.get('firefighters')
            entry.art = request.form.get('art')
            entry.isDriver = isDriver
            entry.isKader = isKader
            #entry.reportedby = str(auth_module.get_userobject()[0].username)

        db.session.commit()
        return make_response(jsonify(message='OK'), 200)
    #except exc.IntegrityError:
    #    return make_response(jsonify(message="Doppelter Eintrag in der Datenbank gefunden."),500)
    except Exception as e:
        return make_response(jsonify(message=str(e)), 500)
Пример #9
0
def get_peers():
    return render_template("mod_peer/peers.html",
                           user=auth_module.get_userobject())
Пример #10
0
def get_konzept():
    return render_template("mod_peer/konzept.html",
                           user=auth_module.get_userobject())
Пример #11
0
def get_settings():
    return render_template("mod_core/settings.html", user=auth_module.get_userobject(),
                           permissions=db.session.query(auth_groups).filter_by(is_deleted=False).all(),
                           permissions_roles=db.session.query(auth_roles).filter_by(is_deleted=False).all(),
                           notifications=db.session.query(notifications_category).filter_by(is_deleted=False).all(),
                           notifications_users=db.session.query(User).all())
Пример #12
0
def settings():
    return render_template(
        "mod_atemschutz/settings.html",
        user=auth_module.get_userobject(),
        categories=db.session.query(Category).all(),
        kurse=db.session.query(Kurs_Definitions).filter_by(is_deleted=0).all())
Пример #13
0
def get_alarmgruppe():

    return render_template("mod_alarm/alarmgruppe.html",
                           user=auth_module.get_userobject(),
                           groups=db.session.query(AlarmGroup).all())