source: OpenRLabs-Git/web2py/applications/rlabs/modules/ados/adoDB_ous.py

main
Last change on this file was 42bd667, checked in by David Fuertes <dfuertes@…>, 4 years ago

Historial Limpio

  • Property mode set to 100644
File size: 1.6 KB
Line 
1# -*- coding: utf-8 -*-
2#################################################################################
3# @file    adoDB_ous.py
4# @brief   Module that manage database info about Opengnsys Organitational Untis (OUs).   
5# @warning None
6# @note Use: None     
7# @license GNU GPLv3+
8# @author  David Fuertes, EUPT, University of Zaragoza.
9# @version 1.1.0 - First version
10# @date    2019-15-11
11#################################################################################
12
13##############################################################################
14# Modulo encargado de gestionar info sobre ou en BBDD
15##############################################################################
16
17def get_ou_credentials(db, ou_id):   
18    return (db(db.ous_setup.ou_id == ou_id).select().first())
19
20
21def update_ous_in_table(db, ous):
22   
23    for ou in ous:
24        if db(db.ous_setup.ou_name == ou['name']).count() == 0:
25            db.ous_setup.update_or_insert(db.ous_setup.ou_id == ou['id'],
26                                      ou_id = ou['id'],
27                                      ou_name = ou['name'])
28    db.commit()
29           
30def delete_ous_not_in_ous_server(db, ous):
31    ous_table = db(db.ous_setup.id > 0).select()
32    for ou_table in ous_table:
33        exist = False
34        for ou in ous: 
35                     
36            if  ou['id'] == int(ou_table.ou_id) :
37                exist = True
38                       
39        if exist == False:
40            ou_table.delete_record()
41           
42    db.commit()
43     
44def get_queryOUs(db):
45    return (db.ous_setup.id>0)
46       
Note: See TracBrowser for help on using the repository browser.