From bd6a70c39e3642193ca417ce8c3497e7214586e2 Mon Sep 17 00:00:00 2001 From: Patrick Bernard Date: Thu, 4 Jan 2007 17:16:31 +0100 Subject: [PATCH] *** empty log message *** --- .../skins/Aniki/generateSurveillants.py | 46 +++++++++++++++ .../skins/Aniki/sortSurveillants.py | 59 +++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100755 web/ryzom_com/Aniki_trackingManager/skins/Aniki/generateSurveillants.py create mode 100755 web/ryzom_com/Aniki_trackingManager/skins/Aniki/sortSurveillants.py diff --git a/web/ryzom_com/Aniki_trackingManager/skins/Aniki/generateSurveillants.py b/web/ryzom_com/Aniki_trackingManager/skins/Aniki/generateSurveillants.py new file mode 100755 index 000000000..e718d60ea --- /dev/null +++ b/web/ryzom_com/Aniki_trackingManager/skins/Aniki/generateSurveillants.py @@ -0,0 +1,46 @@ +## Script (Python) "newPatchNote" +##bind container=container +##bind context=context +##bind namespace= +##bind script=script +##bind subpath=traverse_subpath +##parameters=nb, lang=None,type=None,format=None,url, desc=None +##title= +## + +format = (format,) +type = (type,) +lang = (lang,) +path = '/'.join(context.getPhysicalPath()) +result = context.portal_catalog( + meta_type=['Surveillant',], + path={'query':path, 'level': 0}, + sort_on='Date', + sort_order='reverse', + ) +lastId = result[0].getId + +#creation en boucle a partir de lastId+1 jusqu'a lastId+nb + +r = range(int(lastId)+1,int(lastId)+int(nb)+1) +for i in r: + newid = str(i) + if len(newid) <3: + newid = '00'+newid + elif len(newid) <2: + newid = '0'+newid + print newid + context.invokeFactory(id=newid, type_name='Surveillant', title=newid, langs = lang, types = type, formats = format,description=desc, urlRedirection=url) + new_obj = getattr(context, newid) + new_obj.setTitle(newid) + new_obj.setLangs(lang) + new_obj.setFormats(format) + new_obj.setTypes(type) + new_obj.setUrlRedirection(url) + +#publication +#plustard + +#container.REQUEST.RESPONSE.redirect(context.absolute_url()) + +return printed diff --git a/web/ryzom_com/Aniki_trackingManager/skins/Aniki/sortSurveillants.py b/web/ryzom_com/Aniki_trackingManager/skins/Aniki/sortSurveillants.py new file mode 100755 index 000000000..f4fd01676 --- /dev/null +++ b/web/ryzom_com/Aniki_trackingManager/skins/Aniki/sortSurveillants.py @@ -0,0 +1,59 @@ +## Script (Python) "sortSurveillants" +##bind container=container +##bind context=context +##bind namespace= +##bind script=script +##bind subpath=traverse_subpath +##parameters=capoZ,lang=None,format=None,type=None,text=None +##title= +## + +def FindTextInDesc(text,capo): + text = text.split(';') + result = [] + for brain in capo: + for i in text: + if i.upper() in str(brain.getObject().getDescription()).upper(): + result.append(brain) + return result + +def FilterByLang(lang,capo): + lang = [lang] + if 'all' in lang: + return capo + result = [] + for brain in capo + if lang in brain.getObject().getLangs(): + result.append(brain) + return result + +def FilterByFormat(format,capo): + format = [format] + if 'all' in format: + return capo + result = [] + for brain in capo + if format in brain.getObject().getformats(): + result.append(brain) + return result + +def FilterByType(type,capo): + type = [type] + if 'all' in type: + return capo + result = [] + for brain in capo + if type in brain.getObject().gettypes(): + result.append(brain) + return result + + +if text: + capoZ = FindTextInDesc(text,capoZ) +if lang: + capoZ = FilterByLang(lang,capoZ) +if format: + capoZ = FilterByFormat(format,capoZ) +if type: + capoZ = FilterByType(type,capoZ) +return capoZ