annotate MPIWGFolder.py @ 279:572fcceebde8

add main img.jpg url.
author casties
date Thu, 05 Mar 2015 19:33:31 +0100
parents ee79f6ba8d01
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
2 import logging
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
3 from OFS.Folder import Folder
159
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 10
diff changeset
4
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 10
diff changeset
5 import MPIWGHelper
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
6
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
7
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
8 class MPIWGFolder(Folder):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
9 """special Folder object for MPIWG website """
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
10
10
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
11 meta_type = "MPIWGFolder"
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
12
10
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
13 manage_options = Folder.manage_options + (
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
14 {'label':'Change Weight', 'action':'changeWeightForm'},
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
15 {'label':'Rearrange Weights', 'action':'changeWeightsForm'},
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
16 {'label':'Configure', 'action':'changeForm'},
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
17 )
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
18
159
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 10
diff changeset
19 changeWeightForm = PageTemplateFile('zpt/folder/manage_change_weight', globals())
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 10
diff changeset
20 changeForm = PageTemplateFile('zpt/folder/manage_config', globals())
10
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
21 changeWeightsForm = PageTemplateFile('zpt/folder/manage_change_weights', globals())
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
22
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
23 def __init__(self, id, title=None, weight=0, canonicalName=None):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
24 self.id = str(id)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
25 self.weight = weight
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
26 if title is None:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
27 self.title = id
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
28 else:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
29 self.title = title
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
30
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
31 if canonicalName is None:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
32 self.canonicalName = self.id
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
33 else:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
34 self.canonicalName = canonicalName
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
35
10
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
36 def getNavItems(self):
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
37 """returns sorted list of sub-items"""
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
38 # get all nav-type items
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
39 items = self.objectItems(self.nav_meta_types)
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
40 # unpack into simple list and omit empty titles
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
41 items = [s[1] for s in items if s[1].title != ""]
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
42 # sort by weight
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
43 items.sort(key=lambda x:int(x.weight))
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
44 return items
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
45
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
46 def changeWeight(self, weight, RESPONSE=None):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
47 """change weight"""
10
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
48 self.weight = weight
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
49 if RESPONSE is not None:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
50 RESPONSE.redirect('manage_main')
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
51
10
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
52 def changeWeightsInFolder(self, REQUEST=None):
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
53 """change all weights of a collection"""
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
54 ret = ""
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
55 form = REQUEST.form
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
56 resources = self.getNavItems()
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
57 for resource in resources:
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
58 try:
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
59 id = resource.getId()
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
60 ret += id + " " + form[id] + "\n"
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
61 resource.changeWeight(form[id])
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
62 except Exception, e:
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
63 ret += "ERROR: %s\n"%e
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
64 return ret
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
65
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
66 def changeMPIWGFolder(self, title=None, weight=None, canonicalName=None, RESPONSE=None):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
67 """change everything"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
68 if title is not None:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
69 self.title = title
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
70 if weight is not None:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
71 self.weight = weight
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
72 if canonicalName is not None:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
73 self.canonicalName = canonicalName
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
74 if RESPONSE is not None:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
75 RESPONSE.redirect('manage_main')
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
76
159
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 10
diff changeset
77 getBreadcrumbs = MPIWGHelper.getBreadcrumbs
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
78
159
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 10
diff changeset
79 getSection = MPIWGHelper.getSection
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
80
159
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 10
diff changeset
81 getSubSection = MPIWGHelper.getSubSection
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
82
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
83
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
84 def manage_addMPIWGFolderForm(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
85 """Form for adding"""
159
ee79f6ba8d01 clean up staff editing and some zpt forms.
casties
parents: 10
diff changeset
86 pt = PageTemplateFile('zpt/folder/manage_add_MPIWGFolder', globals()).__of__(self)
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
87 return pt()
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
88
10
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
89 def manage_addMPIWGFolder(self, id, title=None, weight=0, RESPONSE=None):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
90 "Add a MPIWG Folder."
10
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
91 newObj = MPIWGFolder(id, title, weight)
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 0
diff changeset
92 self.Destination()._setObject(id, newObj)
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
93 if RESPONSE is not None:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
94 RESPONSE.redirect('manage_main')
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
95