Revisión 366
Añadido por Manu Mora Gordillo hace casi 13 años
controlies/trunk/applications/controlies/controllers/laptops.py | ||
---|---|---|
@auth.requires_login()
|
||
def modifyHistory():
|
||
my = SQLiteConnection()
|
||
l = LaptopsHistory(my,"",request.vars["id_laptop"],request.vars["id_state"],request.vars["id_user_type"],request.vars["nif"],request.vars["username"],request.vars["name"],request.vars["comment"])
|
||
l = LaptopsHistory(my,request.vars["id_historical"],request.vars["id_laptop"],request.vars["id_state"],request.vars["id_user_type"],request.vars["nif"],request.vars["username"],request.vars["name"],request.vars["comment"])
|
||
response = l.process(request.vars["action"])
|
||
return dict(response = response)
|
||
|
controlies/trunk/applications/controlies/modules/Users.py | ||
---|---|---|
|
||
# type of user (Teacher/Student)
|
||
try:
|
||
searchType = args['type']
|
||
searchType = str(args['type'])
|
||
except LookupError:
|
||
searchType = "none"
|
||
searchType = "None"
|
||
|
||
rows = []
|
||
for i in search:
|
||
|
||
typeRow="Alumno"
|
||
userdata=i[0][1]
|
||
if userdata["homeDirectory"][0][0:14]=="/home/profesor":
|
||
typeRow="Profesor"
|
||
|
||
if not "employeeNumber" in userdata: userdata["employeeNumber"]=["0"]
|
||
if searchType == typeRow or searchType=="none":
|
||
|
||
if searchType == typeRow or searchType=="None":
|
||
row = {
|
||
"id":userdata["uid"][0],
|
||
"cell":[typeRow, userdata["cn"][0], userdata["uid"][0], userdata["uidNumber"][0], userdata["gidNumber"][0], userdata["employeeNumber"][0]],
|
||
"id":str(userdata["uid"][0]),
|
||
"cell":[typeRow, str(userdata["cn"][0]), str(userdata["uid"][0]), str(userdata["uidNumber"][0]), str(userdata["gidNumber"][0]), str(userdata["employeeNumber"][0])],
|
||
"type": typeRow,
|
||
"cn":userdata["cn"][0],
|
||
"uidNumber":userdata["uidNumber"][0],
|
||
"gidNumber":userdata["gidNumber"][0],
|
||
"employeeNumber":userdata["employeeNumber"][0]
|
||
"cn":str(userdata["cn"][0]),
|
||
"uidNumber":str(userdata["uidNumber"][0]),
|
||
"gidNumber":str(userdata["gidNumber"][0]),
|
||
"employeeNumber":str(userdata["employeeNumber"][0])
|
||
}
|
||
rows.append(row)
|
||
|
||
|
||
# grid parameters
|
||
if len(rows) > 0:
|
||
totalPages = floor( len(rows) / int(limit) )
|
||
... | ... | |
return searching
|
||
|
||
def getUserGroups(self):
|
||
result = self.ldap.search("ou=Group","(&(memberUid="+self.user+")(|(groupType=school_department)(groupType=school_class)))",["cn","groupType"])
|
||
result = self.ldap.search("ou=Group","(&(memberUid="+str(self.user)+")(|(groupType=school_department)(groupType=school_class)))",["cn","groupType"])
|
||
|
||
departments = []
|
||
classrooms = []
|
||
... | ... | |
|
||
def getUserData(self):
|
||
self.getUserGroups()
|
||
result = self.ldap.search("ou=People","uid="+self.user,["uid","cn","sn","employeenumber","homedirectory","uidnumber","gidnumber","jpegPhoto"])
|
||
result = self.ldap.search("ou=People","uid="+str(self.user),["uid","cn","sn","employeenumber","homedirectory","uidnumber","gidnumber","jpegPhoto"])
|
||
|
||
if len(result) == 0:
|
||
return { "user":"", "name":"", "surname":"", "nif":"", "photo":"", "type":"","uidnumber":"","gidnumber":"", "groups":[] }
|
controlies/trunk/applications/controlies/modules/LaptopsHistory.py | ||
---|---|---|
|
||
def __init__(self,SQLite,id_historical,id_laptop,id_state,id_user_type,nif,username,name,comment):
|
||
self.SQLite = SQLite
|
||
self.id_historical = id_historical
|
||
self.id_laptop = id_laptop
|
||
self.id_state = id_state
|
||
self.id_user_type = id_user_type
|
||
self.nif = nif
|
||
self.username = username
|
||
self.name = name
|
||
self.comment = comment
|
||
self.id_historical = str(id_historical)
|
||
self.id_laptop = str(id_laptop)
|
||
self.id_state = str(id_state)
|
||
self.id_user_type = str(id_user_type)
|
||
self.nif = str(nif)
|
||
self.username = str(username)
|
||
self.name = str(name)
|
||
self.comment = str(comment)
|
||
|
||
def validation(self,action):
|
||
|
||
... | ... | |
|
||
|
||
def modify(self):
|
||
sql = "UPDATE laptops SET serial_number='"+self.serial_number+"', id_trademark='"+self.id_trademark+"' "
|
||
sql = sql + "WHERE id_laptop='"+str(self.id_laptop)+"'"
|
||
|
||
sql = "UPDATE laptops_historical SET username='"+self.username+"', name='"+self.name+"', id_user_type='"+self.id_user_type+"', nif='"+self.nif+"', comment='"+self.comment+"', id_state='"+self.id_state+"' "
|
||
sql = sql + "WHERE id_historical='"+str(self.id_historical)+"'"
|
||
db = self.SQLite.getDB()
|
||
result = db.executesql(sql)
|
||
|
||
... | ... | |
"id_state":str(result[0][1])
|
||
}
|
||
|
||
return data
|
||
return data
|
||
|
||
def userAssignment(self):
|
||
sql="SELECT lh.id_laptop, lh.username FROM laptops l, laptops_historical lh"
|
||
sql=sql+" WHERE l.id_laptop=lh.id_laptop"
|
||
sql=sql+" GROUP BY l.id_laptop ORDER BY lh.datetime desc"
|
||
db = self.SQLite.getDB()
|
||
result = db.executesql(sql)
|
||
|
||
for r in result:
|
||
if str(r[1])==self.username:
|
||
return str(r[0])
|
||
|
||
return False
|
controlies/trunk/applications/controlies/modules/Utils/LdapUtils.py | ||
---|---|---|
|
||
return { "departments":departments, "classrooms":classrooms }
|
||
|
||
def getClassroomGroups(ldap):
|
||
result = ldap.search("ou=Group","(|(groupType=school_class))",["cn","groupType"])
|
||
|
||
classrooms = []
|
||
for g in result:
|
||
classrooms.append(g[0][1]["cn"][0])
|
||
|
||
classrooms.sort()
|
||
|
||
return { "classrooms":classrooms }
|
||
|
||
def getAllRanges(ldap):
|
||
myRange = []
|
||
mySubRange = []
|
controlies/trunk/applications/controlies/modules/Groups.py | ||
---|---|---|
return response
|
||
|
||
def list(self,args):
|
||
|
||
filter = self.buildFilter(args)
|
||
search = self.ldap.search("ou=Group",filter,["cn","gidNumber","groupType","memberUid"])
|
||
|
||
... | ... | |
|
||
# type of group (Classroom/Department)
|
||
try:
|
||
searchType = args['type']
|
||
searchType = str(args['type'])
|
||
except LookupError:
|
||
searchType = "none"
|
||
searchType = "None"
|
||
|
||
rows = []
|
||
for i in search:
|
||
|
||
typeRow="Aula"
|
||
if i[0][1]["groupType"][0]=="school_department":
|
||
if str(i[0][1]["groupType"][0])=="school_department":
|
||
typeRow="Departamento"
|
||
|
||
if searchType == typeRow or searchType=="none":
|
||
|
||
|
||
if searchType == typeRow or searchType=="None":
|
||
try:
|
||
usersNumber = len(i[0][1]["memberUid"])
|
||
except:
|
||
... | ... | |
|
||
def listUsers(self,args):
|
||
from applications.controlies.modules.Users import Users
|
||
|
||
# grid parameters
|
||
limit = int(args['rows'])
|
||
page = int(args['page'])
|
||
... | ... | |
|
||
rows = []
|
||
for i in groupData["memberuid"]:
|
||
|
||
u = Users(self.ldap,"","","","",i,"","","","")
|
||
userData = u.getUserData()
|
||
|
||
row = {
|
||
"id":userData["user"],
|
||
"cell":[userData["name"],userData["user"],userData["nif"]],
|
||
... | ... | |
"employeeNumber": userData["nif"]
|
||
}
|
||
rows.append(row)
|
||
|
||
|
||
if len(rows) > 0:
|
||
totalPages = floor( len(rows) / int(limit) )
|
||
... | ... | |
|
||
# sort rows
|
||
result = sorted(rows, key=itemgetter(sortBy), reverse=reverseSort)
|
||
|
||
return { "page":page, "total":totalPages, "records":len(groupData["memberuid"]), "rows":result[start:finish] }
|
||
|
||
|
||
|
||
def buildFilter(self, args):
|
||
filter = "(&(cn=*)(|(groupType=school_class)(groupType=school_department))"
|
||
|
||
try:
|
||
filter = filter + "(cn=*" + args['cn'] + "*)"
|
||
except LookupError:
|
||
pass
|
||
|
||
if self.type=="":
|
||
filter = "(&(cn=*)(|(groupType=school_class)(groupType=school_department))"
|
||
else:
|
||
filter = "(&(cn=*)(|(groupType="+str(self.type)+"))"
|
||
|
||
try:
|
||
filter = filter + "(gidNumber=" + args['gidNumber'] + ")"
|
||
except LookupError:
|
||
pass
|
||
try:
|
||
if str(args['cn'])!="None":
|
||
filter = filter + "(cn=*" + str(args['cn']) + "*)"
|
||
except LookupError:
|
||
pass
|
||
|
||
filter = filter + ")"
|
||
return filter
|
||
try:
|
||
if str(args['gidNumber'])!="None":
|
||
filter = filter + "(gidNumber=" + str(args['gidNumber']) + ")"
|
||
except LookupError:
|
||
pass
|
||
|
||
filter = filter + ")"
|
||
return filter
|
||
|
||
|
||
def add(self):
|
controlies/trunk/applications/controlies/modules/Laptops.py | ||
---|---|---|
def add(self):
|
||
sql = "INSERT INTO laptops (id_laptop, serial_number, id_trademark) "
|
||
sql = sql + "VALUES(null,'"+self.serial_number+"','"+self.id_trademark+"')"
|
||
|
||
db = self.SQLite.getDB()
|
||
result = db.executesql(sql)
|
||
|
||
... | ... | |
}
|
||
data.append(dataType)
|
||
return data
|
||
|
||
def getMaxId(self):
|
||
sql="SELECT max(id_laptop) AS max FROM laptops"
|
||
db = self.SQLite.getDB()
|
||
result = db.executesql(sql)
|
||
|
||
return str(result[0][0])
|
controlies/trunk/applications/controlies/models/menu.py | ||
---|---|---|
|
||
response.menu+=[('BD Portátiles', False, None,[
|
||
('Portátiles', False,URL( 'laptops', 'index')),
|
||
('Grupos', False,URL( 'laptops_groups', 'index')),
|
||
('Marcas', False,URL( 'laptops_trademarks', 'index')),
|
||
]
|
||
)]
|
controlies/trunk/applications/controlies/views/laptops/history.html | ||
---|---|---|
|
||
jQuery.post('call/json/getDataHistory',{ id_historical: id }, function(result) {
|
||
|
||
jQuery("#form_data_history #id_historical").val(id);
|
||
jQuery("#form_data_history #id_state").val(result.response['id_state']);
|
||
jQuery("#form_data_history #id_historical").val(result.response['id_historical']);
|
||
jQuery("#form_data_history #id_laptop").val(result.response['id_laptop']);
|
||
jQuery("#form_data_history #username").val(result.response['username']);
|
||
jQuery("#form_data_history #id_user_type").val(result.response['id_user_type']);
|
controlies/trunk/applications/controlies/views/laptops/form_history.html | ||
---|---|---|
<form id="form_data_history" onsubmit="return sendHistory();">
|
||
<input type="hidden" id="action" name="action"/>
|
||
<input type="hidden" id="id_laptop" name="id_laptop"/>
|
||
<input type="hidden" id="id_history" name="id_history"/>
|
||
<input type="hidden" id="id_historical" name="id_historical"/>
|
||
<div>
|
||
<p><span id="id_stateTag">Estado (*)</span><br>
|
||
<select type="text" id="id_state" name="id_state" onchange="javascript:showFields();">
|
Exportar a: Unified diff
Asignacion de portátiles por aula