diff --git a/modules/websubmit/web/admin/referees.py b/modules/websubmit/web/admin/referees.py index 97f861ab3..99fa538ca 100644 --- a/modules/websubmit/web/admin/referees.py +++ b/modules/websubmit/web/admin/referees.py @@ -1,228 +1,231 @@ ## $Id$ ## This file is part of the CERN Document Server Software (CDSware). ## Copyright (C) 2002 CERN. ## ## The CDSware is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## The CDSware is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with CDSware; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. ## read config variables: #include "config.wml" #include "configbis.wml" pylibdir = "/python" ## $Id$ ## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES. ## import interesting modules: import string import os import sys import time import types import re import MySQLdb import shutil sys.path.append('%s' % pylibdir) from cdsware.config import * from cdsware.dbquery import run_sql from cdsware.access_control_engine import acc_authorize_action from cdsware.access_control_admin import * from cdsware.webpage import page, create_error_box from cdsware.webuser import getUid, get_email, list_registered_users from cdsware.messages import * from cdsware.websubmit_config import * def index(req,c=cdsname,ln=cdslang,todo="",id="",doctype="",categ="",addusers="",warningText="",role=""): ln = wash_language(ln) # get user ID: try: uid = getUid(req) uid_email = get_email(uid) except MySQLdb.Error, e: return errorMsg(e.value,req) if not acc_authorize_action(uid, "cfgwebsubmit",verbose=0): return errorMsg("You are not authorized to use websubmit admin",req) # request for deleting a user if todo == "deleteuser": acc_deleteUserRole(id,name_role=role) # request for adding user(s) if todo == "adduser": role = "referee_%s_%s" % (doctype,categ[1]) roleId = acc_getRoleId(role) # if the role does not exists, we create it if roleId == 0: if acc_addRole(role,"referees for document type %s category %s" % (doctype,categ[1])) == 0: return errorMsg("Cannot create referee role",req) else: roleId = acc_getRoleId(role) # if the action does not exist, we create it actionId = acc_getActionId("referee") if actionId == 0: if acc_addAction("referee","","no",("doctype","categ")) == 0: return errorMsg("Cannot create action 'referee'",req) else: actionId = acc_getActionId("referee") #create arguments arg1Id = acc_addArgument("doctype",doctype) arg2Id = acc_addArgument("categ",categ[1]) # then link the role with the action if acc_addRoleActionArguments(roleId,actionId,-1,0,0,[arg1Id,arg2Id]) == 0: return errorMsg("Cannot link role with action",req) roleId = acc_getRoleId(role) # For each id in the array if isinstance(addusers,types.ListType): for adduser in addusers: # First check whether this id is not already associated with this rule myRoles = acc_getUserRoles(adduser) if not roleId in myRoles: # Actually add the role to the user acc_addUserRole(adduser,roleId) else: warningText = "Sorry... This user is already a referee for this category." else: # First check whether this id is not already associated with this rule myRoles = acc_getUserRoles(addusers) if not roleId in myRoles: # Actually add the role to the user acc_addUserRole(addusers,roleId) else: warningText = "Sorry... This user is already a referee for this category." return page(title="websubmit admin - referee selection", body=displayRefereesPage(doctype,warningText), description="", keywords="", uid=uid, language=ln, urlargs=req.args) def displayRefereesPage(doctype,warningText): t="" if doctype == "*": docname = "all catalogues" else: res = run_sql("SELECT * FROM sbmDOCTYPE WHERE sdocname=%s", (doctype,)) docname = res[0][0] t+=warningText t+="""
""" %doctype # call the function to display the table containing the list of associated emails t+=displayUserTable(doctype) t+=""" """ # call the function to display the form allowing the manager to add new users t+=displayAddUser(doctype) t+= """
- +
""" return t def displayUserTable(doctype): t="" # start displaying the table which will contain the list of email addresses. t+= """ - - """ - +
Referees
+ + + """ roles = acc_getAllRoles() referees = {} for role in roles: role_name = role[1] role_id = role[0] if re.match("^referee_%s_" % doctype,role_name): # Try to retrieve the referee's email from the referee's database if acc_getRoleUsers(role_id) != None: referees[role_name] = acc_getRoleUsers(role_id) if len(referees) == 0: t+= "" % images i=0 for role in referees.keys(): categ = re.match("referee_%s_(.*)" % doctype,role).group(1) res = run_sql("SELECT lname FROM sbmCATEGORIES WHERE sname=%s and doctype=%s", (categ,doctype,)) if len(res) > 0: categname = "Referee(s) for category: %s" % res[0][0] else: categname = "General Referee(s)" t+= "" % categname for referee in referees[role]: if int(i/2) == i/2: bgcolor="#eeeeee" else: bgcolor="#dddddd" t+= "" % bgcolor t+= "" t+= ""; t+= ""; i+=1 # close table t+="" return t def displayAddUser(doctype): t="" # start displaying the table which will contain the add form t+= """ - -
-
Add
-
+ + + + + + " return t def errorMsg(title,req,c=cdsname,ln=cdslang): return page(title="error", body = create_error_box(req, title=title,verbose=0, ln=ln), description="%s - Internal Error" % c, keywords="%s, CDSware, Internal Error" % c, language=ln, urlargs=req.args) diff --git a/modules/websubmit/web/admin/referees.py.wml b/modules/websubmit/web/admin/referees.py.wml index 97f861ab3..99fa538ca 100644 --- a/modules/websubmit/web/admin/referees.py.wml +++ b/modules/websubmit/web/admin/referees.py.wml @@ -1,228 +1,231 @@ ## $Id$ ## This file is part of the CERN Document Server Software (CDSware). ## Copyright (C) 2002 CERN. ## ## The CDSware is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## The CDSware is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with CDSware; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. ## read config variables: #include "config.wml" #include "configbis.wml" pylibdir = "/python" ## $Id$ ## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES. ## import interesting modules: import string import os import sys import time import types import re import MySQLdb import shutil sys.path.append('%s' % pylibdir) from cdsware.config import * from cdsware.dbquery import run_sql from cdsware.access_control_engine import acc_authorize_action from cdsware.access_control_admin import * from cdsware.webpage import page, create_error_box from cdsware.webuser import getUid, get_email, list_registered_users from cdsware.messages import * from cdsware.websubmit_config import * def index(req,c=cdsname,ln=cdslang,todo="",id="",doctype="",categ="",addusers="",warningText="",role=""): ln = wash_language(ln) # get user ID: try: uid = getUid(req) uid_email = get_email(uid) except MySQLdb.Error, e: return errorMsg(e.value,req) if not acc_authorize_action(uid, "cfgwebsubmit",verbose=0): return errorMsg("You are not authorized to use websubmit admin",req) # request for deleting a user if todo == "deleteuser": acc_deleteUserRole(id,name_role=role) # request for adding user(s) if todo == "adduser": role = "referee_%s_%s" % (doctype,categ[1]) roleId = acc_getRoleId(role) # if the role does not exists, we create it if roleId == 0: if acc_addRole(role,"referees for document type %s category %s" % (doctype,categ[1])) == 0: return errorMsg("Cannot create referee role",req) else: roleId = acc_getRoleId(role) # if the action does not exist, we create it actionId = acc_getActionId("referee") if actionId == 0: if acc_addAction("referee","","no",("doctype","categ")) == 0: return errorMsg("Cannot create action 'referee'",req) else: actionId = acc_getActionId("referee") #create arguments arg1Id = acc_addArgument("doctype",doctype) arg2Id = acc_addArgument("categ",categ[1]) # then link the role with the action if acc_addRoleActionArguments(roleId,actionId,-1,0,0,[arg1Id,arg2Id]) == 0: return errorMsg("Cannot link role with action",req) roleId = acc_getRoleId(role) # For each id in the array if isinstance(addusers,types.ListType): for adduser in addusers: # First check whether this id is not already associated with this rule myRoles = acc_getUserRoles(adduser) if not roleId in myRoles: # Actually add the role to the user acc_addUserRole(adduser,roleId) else: warningText = "Sorry... This user is already a referee for this category." else: # First check whether this id is not already associated with this rule myRoles = acc_getUserRoles(addusers) if not roleId in myRoles: # Actually add the role to the user acc_addUserRole(addusers,roleId) else: warningText = "Sorry... This user is already a referee for this category." return page(title="websubmit admin - referee selection", body=displayRefereesPage(doctype,warningText), description="", keywords="", uid=uid, language=ln, urlargs=req.args) def displayRefereesPage(doctype,warningText): t="" if doctype == "*": docname = "all catalogues" else: res = run_sql("SELECT * FROM sbmDOCTYPE WHERE sdocname=%s", (doctype,)) docname = res[0][0] t+=warningText t+="""
""" %doctype # call the function to display the table containing the list of associated emails t+=displayUserTable(doctype) t+=""" """ # call the function to display the form allowing the manager to add new users t+=displayAddUser(doctype) t+= """
- +
""" return t def displayUserTable(doctype): t="" # start displaying the table which will contain the list of email addresses. t+= """ - - """ - +
Referees
+ + + """ roles = acc_getAllRoles() referees = {} for role in roles: role_name = role[1] role_id = role[0] if re.match("^referee_%s_" % doctype,role_name): # Try to retrieve the referee's email from the referee's database if acc_getRoleUsers(role_id) != None: referees[role_name] = acc_getRoleUsers(role_id) if len(referees) == 0: t+= "" % images i=0 for role in referees.keys(): categ = re.match("referee_%s_(.*)" % doctype,role).group(1) res = run_sql("SELECT lname FROM sbmCATEGORIES WHERE sname=%s and doctype=%s", (categ,doctype,)) if len(res) > 0: categname = "Referee(s) for category: %s" % res[0][0] else: categname = "General Referee(s)" t+= "" % categname for referee in referees[role]: if int(i/2) == i/2: bgcolor="#eeeeee" else: bgcolor="#dddddd" t+= "" % bgcolor t+= "" t+= ""; t+= ""; i+=1 # close table t+="" return t def displayAddUser(doctype): t="" # start displaying the table which will contain the add form t+= """ - -
-
Add
-
+ + + + + + " return t def errorMsg(title,req,c=cdsname,ln=cdslang): return page(title="error", body = create_error_box(req, title=title,verbose=0, ln=ln), description="%s - Internal Error" % c, keywords="%s, CDSware, Internal Error" % c, language=ln, urlargs=req.args)