This repository has been archived by the owner on Apr 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Patrick Bernard
committed
Jan 4, 2007
1 parent
7b68780
commit bd6a70c
Showing
2 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
web/ryzom_com/Aniki_trackingManager/skins/Aniki/generateSurveillants.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
59 changes: 59 additions & 0 deletions
59
web/ryzom_com/Aniki_trackingManager/skins/Aniki/sortSurveillants.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |