Page MenuHomec4science

personal.py.wml
No OneTemporary

File Metadata

Created
Sat, Jun 29, 21:33

personal.py.wml

## $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 = "<LIBDIR>/python"
<protect>
## $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
import operator
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 *
from cdsware.search_engine import search_pattern
def index(req,c=cdsname,ln=cdslang,order="",doctype="",deletedId="",deletedAction="",deletedDoctype=""):
global uid
ln = wash_language(ln)
t=""
# get user ID:
try:
uid = getUid(req)
u_email = get_email(uid)
except MySQLdb.Error, e:
return errorMsg(e.value,req)
if deletedId != "":
t+=deleteSubmission(deletedId,deletedAction,deletedDoctype,u_email)
t+="""
<BR>
<SMALL>
<form>
<input type=hidden value='%s' name=order>
<input type=hidden name=deletedId>
<input type=hidden name=deletedDoctype>
<input type=hidden name=deletedAction>
<STRONG class=headline>Notice:</STRONG><BR>
You will find here the list of all the actions you made through CDS Submit.""" % order
t+="<select name=doctype onchange=\"document.forms[0].submit();\"><option value=\"\">all types of document"
res = run_sql("select ldocname,sdocname from sbmDOCTYPE order by ldocname")
for row in res:
if doctype==row[1]:
t+="<option value=%s selected>%s" % (row[1],row[0])
else:
t+="<option value=%s>%s" % (row[1],row[0])
t+="</select></small></form>\n"
t+="<table><tr><td></td></tr>"
# request order default value
reqorder = "sbmSUBMISSIONS.md DESC, lactname"
# requested value
if order == "actiondown":
reqorder = "lactname ASC, sbmSUBMISSIONS.md DESC"
elif order == "actionup":
reqorder = "lactname DESC, sbmSUBMISSIONS.md DESC"
elif order == "refdown":
reqorder = "reference ASC, sbmSUBMISSIONS.md DESC, lactname DESC"
elif order == "refup":
reqorder = "reference DESC, sbmSUBMISSIONS.md DESC, lactname DESC"
elif order == "cddown":
reqorder = "sbmSUBMISSIONS.cd DESC, lactname"
elif order == "cdup":
reqorder = "sbmSUBMISSIONS.cd ASC, lactname"
elif order == "mddown":
reqorder = "sbmSUBMISSIONS.md DESC, lactname"
elif order == "mdup":
reqorder = "sbmSUBMISSIONS.md ASC, lactname"
elif order == "statusdown":
reqorder = "sbmSUBMISSIONS.status DESC, lactname"
elif order == "statusup":
reqorder = "sbmSUBMISSIONS.status ASC, lactname"
if doctype != "":
docselect = " and doctype='%s' " % doctype
else:
docselect = ""
if u_email == "guest" or u_email == "":
return warningMsg("<font color=red size=+1>You first have to login before using this feature. Use the left menu to log in.</font>",req)
else:
res = run_sql("SELECT sbmSUBMISSIONS.* FROM sbmSUBMISSIONS,sbmACTION WHERE sactname=action and email=%s and id!='' "+docselect+" ORDER BY doctype,"+reqorder,(u_email,))
currentdoctype = ""
currentaction = ""
currentstatus = ""
num = 0
for row in res:
if currentdoctype != row[1]:
currentdoctype = row[1]
currentaction = ""
currentstatus = ""
res2 = run_sql("SELECT ldocname FROM sbmDOCTYPE WHERE sdocname=%s",(currentdoctype,))
ldocname = res2[0][0]
t+= "</table>\n&nbsp;<br>\n"
t+="<b>%s</b><br>\n" % ldocname
t+="<table border=\"0\" class=\"searchbox\" align=\"left\" width=\"100%\">\n"
t+="<tr><th class=headerselected>Action&nbsp;&nbsp;"
t+="<a href='' onClick='document.forms[0].order.value=\"actiondown\";document.forms[0].submit();return false;'><img src=%s/smalldown.gif border=0></a>&nbsp;" % images
t+="<a href='' onClick='document.forms[0].order.value=\"actionup\";document.forms[0].submit();return false;'><img src=%s/smallup.gif border=0></a></th>" % images
t+="\n<th class=headerselected>Status&nbsp;&nbsp;"
t+="<a href='' onClick='document.forms[0].order.value=\"statusdown\";document.forms[0].submit();return false;'><img src=%s/smalldown.gif border=0></a>&nbsp;" % images
t+="<a href='' onClick='document.forms[0].order.value=\"statusup\";document.forms[0].submit();return false;'><img src=%s/smallup.gif border=0></a></th>" % images
t+="\n<th class=headerselected>id</th><th class=headerselected>reference&nbsp;&nbsp;"
t+="<a href='' onClick='document.forms[0].order.value=\"refdown\";document.forms[0].submit();return false;'><img src=%s/smalldown.gif border=0></a>&nbsp;" % images
t+="<a href='' onClick='document.forms[0].order.value=\"refup\";document.forms[0].submit();return false;'><img src=%s/smallup.gif border=0></a></th>" % images
t+="\n<th class=headerselected>first access&nbsp;&nbsp;"
t+="<a href='' onClick='document.forms[0].order.value=\"cddown\";document.forms[0].submit();return false;'><img src=%s/smalldown.gif border=0></a>&nbsp;" % images
t+="<a href='' onClick='document.forms[0].order.value=\"cdup\";document.forms[0].submit();return false;'><img src=%s/smallup.gif border=0></a></th>" % images
t+="\n<th class=headerselected>last access&nbsp;&nbsp;"
t+="<a href='' onClick='document.forms[0].order.value=\"mddown\";document.forms[0].submit();return false;'><img src=%s/smalldown.gif border=0></a>&nbsp;" % images
t+="<a href='' onClick='document.forms[0].order.value=\"mdup\";document.forms[0].submit();return false;'><img src=%s/smallup.gif border=0></a></th></tr>\n" % images
if currentaction != row[2]:
currentaction = row[2]
res2 = run_sql("SELECT lactname FROM sbmACTION WHERE sactname=%s",(currentaction,))
lactname = res2[0][0]
else:
lactname = "\""
cdate = str(row[6]).replace(" ","&nbsp;")
mdate= str(row[7]).replace(" ","&nbsp;")
if currentstatus != row[3]:
currentstatus = row[3]
status=row[3]
else:
status = "\""
if row[3] == "pending":
idtext = "<a href=\"sub.py?access=%s@%s%s\">%s</a>" % (row[4],currentaction,currentdoctype,row[4])
idtext+= "&nbsp;<a onClick='if (confirm(\"Are you sure you want to delete this submission?\")){document.forms[0].deletedId.value=\"%s\";document.forms[0].deletedDoctype.value=\"%s\";document.forms[0].deletedAction.value=\"%s\";document.forms[0].submit();return true;}else{return false;}' href=''><img src=%s/smallbin.gif border=0 alt='delete submission %s in %s'></a>" % (row[4],currentdoctype,currentaction,images,row[4],ldocname)
else:
idtext = row[4]
if row[5] == "":
reference = "<font color=red>not yet given</font>"
else:
reference = row[5]
if operator.mod(num,2) == 0:
t+= "<tr bgcolor=\"#e0e0e0\">\n"
else:
t+= "<tr bgcolor=\"#eeeeee\">\n"
t+="<td align=center><small>%s</small></td>\n<td align=center><small>%s</small></td>\n<td><small>" % (lactname,status)
t+="%s</small></td>\n<td><small>&nbsp;%s" % (idtext,reference)
t+="</small></td>\n<td><small>%s</small></td>\n<td><small>" % cdate
t+="%s</small></td>\n</tr>\n" % mdate
num+=1
t+="</table>"
return page(title="personal page",
body=t,
description="",
keywords="",
uid=uid,
language=ln,
urlargs=req.args)
def deleteSubmission(id, action, doctype, u_email):
global storage
run_sql("delete from sbmSUBMISSIONS WHERE doctype=%s and action=%s and email=%s and status='pending' and id=%s",(doctype,action,u_email,id,))
res = run_sql("select dir from sbmACTION where sactname=%s",(action,))
dir = res[0][0]
if re.search("\.\.",doctype) == None and re.search("\.\.",id) == None and id != "":
if os.path.exists("%s/%s/%s/%s" % (storage,dir,doctype,id)):
os.rmdir("%s/%s/%s/%s" % (storage,dir,doctype,id))
return ""
def warningMsg(title,req,c=cdsname,ln=cdslang):
return page(title="warning",
body = title,
description="%s - Internal Error" % c,
keywords="%s, CDSware, Internal Error" % c,
language=ln,
urlargs=req.args)
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)
</protect>

Event Timeline