def post(self):
        '''post settings to server'''

        connection = get_connection("database_server.db")
        cursor = connection.cursor()

        if not is_admin(cursor):
            connection.close()
            return {}, 401

        file = open('settings.json', 'w')
        file.write(json.dumps(api.payload))
        file.close()

        sync_settings()

        # todo: prüfen, ob erfolgreich synchronisiert, ggf. neu synchronisieren

        return {}
示例#2
0
    def post(self):
        '''add RFID Tags to DB'''
        connection = get_connection("database_server.db")
        cursor = connection.cursor()

        payload = api.payload

        if not is_admin(cursor):
            return {}, 401

        cursor.execute(
            'INSERT INTO RFID_Ausweis (RFID_Code, Synced) VALUES (?, FALSE)', [int(payload['rfid'], 16)]
        )

        connection.commit()
        connection.close()

        sync_rfids()

        return {}
    def get(self):
        '''assigned RFID tags'''
        connection = get_connection("database_server.db")
        cursor = connection.cursor()

        if not is_admin(cursor):
            return {}, 401

        return_dict = {'rfid_list': []}

        for row in cursor.execute(
                'SELECT PilotID, RFID_Code, Vorname, Nachname '
                'FROM Pilot WHERE RFID_CODE IS NOT NULL'):
            list_item = {
                'pilot_id': row[0],
                'pilot_name': row[2] + ' ' + row[3],
                'rfid': hex(row[1])
            }
            return_dict['rfid_list'].append(list_item)
        connection.close()
        return return_dict