annotate MPIWGFeature.py @ 17:6d374d94c7e3

nicer add feature form.
author casties
date Fri, 05 Apr 2013 16:06:19 +0200
parents 54f135c1ed65
children 3913a1c5c583
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
9
5db416602e85 new MPIWGDepartment class.
casties
parents: 5
diff changeset
2 from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
16
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
3 from OFS.Folder import Folder
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
4 from AccessControl import ClassSecurityInfo
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
5 from Globals import package_home
16
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
6
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
7 import string
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
8 import re
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
9 import os
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
10 import logging
16
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
11 import datetime
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
12
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
13 from SrvTxtUtils import getMonthName
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
14 from MPIWGHelper import *
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
15
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
16 class MPIWGFeature(Folder):
16
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
17 """special object for feature texts on the MPIWG website.
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
18 Has templates for English and German in Folders /en/ and /de/.
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
19 Feature teaser is /(en|de)/teaser.pt. Full page is /(en|de)/main.pt.
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
20 Full title is the title of /(en|de)/main.pt.
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
21 """
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 meta_type="MPIWGFeature"
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
24
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
25 manage_options=Folder.manage_options+(
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
26 {'label':'Change Weight','action':'changeWeightForm'},
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
27 {'label':'Main Config','action':'changeForm'},
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
28 )
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
29
16
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
30 changeWeightForm = PageTemplateFile('zpt/feature/manage_change_weight', globals())
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
31 changeForm = PageTemplateFile('zpt/feature/manage_config', globals())
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
32
16
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
33 def __init__(self, id, title=None, weight=0, date=None, title_en=None, title_de=None):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
34 self.id = str(id)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
35 self.weight = weight
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
36 if title is None:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
37 self.title = id
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
38 else:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
39 self.title = title
16
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
40
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
41 if date is None:
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
42 self.date = datetime.date.today()
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
43 else:
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
44 self.date = date
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
45
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
46 #
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
47 # add language folder_en and sample templates
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
48 #
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
49 mainid = 'main.pt'
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
50 teaserid = 'teaser.pt'
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
51 # english
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
52 self.manage_addFolder('en')
16
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
53 folder_en = getattr(self, 'en')
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
54 folder_en[teaserid] = ZopePageTemplate(teaserid)
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
55 teaser_en = getattr(folder_en,teaserid)
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
56 teaser_en.pt_edit(open(os.path.join(package_home(globals()),'zpt/feature/default_template_teaser.zpt')).read(),'text/html')
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
57 folder_en[mainid] = ZopePageTemplate(mainid)
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
58 main_en = getattr(folder_en,mainid)
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
59 main_en.pt_edit(open(os.path.join(package_home(globals()),'zpt/feature/default_template_main.zpt')).read(),'text/html')
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
60 if title_en is not None:
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
61 main_en.title = title_en
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
62 # german
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
63 self.manage_addFolder('de')
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
64 folder_de = getattr(self, 'de')
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
65 folder_de[teaserid] = ZopePageTemplate(teaserid)
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
66 teaser_de = getattr(folder_de,teaserid)
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
67 teaser_de.pt_edit(open(os.path.join(package_home(globals()),'zpt/feature/default_template_teaser.zpt')).read(),'text/html')
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
68 folder_de[mainid] = ZopePageTemplate(mainid)
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
69 main_de = getattr(folder_de,mainid)
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
70 main_de.pt_edit(open(os.path.join(package_home(globals()),'zpt/feature/default_template_main.zpt')).read(),'text/html')
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
71 if title_de is not None:
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
72 main_de.title = title_de
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
73
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
74
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
75 def index_html(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
76 """default index page"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
77 return self.getMain()
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
78
16
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
79 def getFullTitle(self, lang=None):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
80 """returns the full title (from main.pt)"""
16
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
81 if lang is None:
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
82 # get Language from MPIWGRoot
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
83 lang = self.getLang()
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
84
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
85 dir = getattr(self, lang, self.en)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
86 pt = getattr(dir, 'main.pt')
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
87 t = pt.title
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
88 if not t:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
89 t = self.title
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
90
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
91 return t
5
9e720c6c5b6c working on start page.
casties
parents: 4
diff changeset
92
16
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
93 def getDate(self):
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
94 """returns the date as a date object"""
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
95 return getattr(self, 'date', None)
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
96
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
97 def getDateString(self, lang=None):
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
98 """returns the date as a string"""
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
99 d = self.getDate()
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
100 if d is None:
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
101 return '???'
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
102
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
103 if lang is None:
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
104 # get Language from MPIWGRoot
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
105 lang = self.getLang()
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
106
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
107 if lang == 'iso':
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
108 return d.isoformat()
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
109 elif lang == 'en':
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
110 return "%s %s, %s"%(getMonthName(d.month, 'en'), d.day, d.year)
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
111 elif lang == 'de':
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
112 return "%s. %s %s"%(d.day, getMonthName(d.month, 'de'), d.year)
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
113
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
114 return None
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
115
5
9e720c6c5b6c working on start page.
casties
parents: 4
diff changeset
116 def getUrl(self, baseUrl=None):
9e720c6c5b6c working on start page.
casties
parents: 4
diff changeset
117 """returns URL to this feature"""
9e720c6c5b6c working on start page.
casties
parents: 4
diff changeset
118 if baseUrl is None:
9e720c6c5b6c working on start page.
casties
parents: 4
diff changeset
119 return self.absolute_url()
9e720c6c5b6c working on start page.
casties
parents: 4
diff changeset
120
9e720c6c5b6c working on start page.
casties
parents: 4
diff changeset
121 return '%s/%s'%(baseUrl, self.getId())
9e720c6c5b6c working on start page.
casties
parents: 4
diff changeset
122
9e720c6c5b6c working on start page.
casties
parents: 4
diff changeset
123 def getPath(self, page, relative=True):
9e720c6c5b6c working on start page.
casties
parents: 4
diff changeset
124 """returns path to template page"""
9e720c6c5b6c working on start page.
casties
parents: 4
diff changeset
125 # get Language from MPIWGRoot
9e720c6c5b6c working on start page.
casties
parents: 4
diff changeset
126 lang = self.getLang()
9e720c6c5b6c working on start page.
casties
parents: 4
diff changeset
127 dir = getattr(self, lang, self.en)
9e720c6c5b6c working on start page.
casties
parents: 4
diff changeset
128 if relative:
9e720c6c5b6c working on start page.
casties
parents: 4
diff changeset
129 return '%s/%s/%s'%(self.getId(), dir.getId(), page)
9e720c6c5b6c working on start page.
casties
parents: 4
diff changeset
130
9e720c6c5b6c working on start page.
casties
parents: 4
diff changeset
131 pt = getattr(dir, page)
9e720c6c5b6c working on start page.
casties
parents: 4
diff changeset
132 return pt.absolute_url_path()
9e720c6c5b6c working on start page.
casties
parents: 4
diff changeset
133
9e720c6c5b6c working on start page.
casties
parents: 4
diff changeset
134 def getTeaserPath(self):
9e720c6c5b6c working on start page.
casties
parents: 4
diff changeset
135 """returns the path to the teaser template"""
9e720c6c5b6c working on start page.
casties
parents: 4
diff changeset
136 return self.getPath('teaser.pt')
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
137
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
138 def getIntro(self, **args):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
139 """returns the intro as PageTemplate"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
140 # get Language from MPIWGRoot
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
141 lang = self.getLang()
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
142 dir = getattr(self, lang, self.en)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
143 pt = getattr(dir, 'intro.pt')
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
144 return pt(**args)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
145
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
146 def getMain(self, **args):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
147 """returns the main part as PageTemplate"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
148 # get Language from MPIWGRoot
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
149 lang = self.getLang()
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
150 dir = getattr(self, lang, self.en)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
151 pt = getattr(dir, 'main.pt')
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
152 return pt(**args)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
153
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
154 def getFrontpageImg(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
155 """returns the image object for the frontpage"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
156 img = getattr(self, 'img-frontpage.jpg')
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
157 return img
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
158
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
159 def getFrontpageImgUrl(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
160 """returns the URL of the image object for the frontpage"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
161 img = getattr(self, 'img-frontpage.jpg')
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
162 return img.absolute_url()
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
163
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
164 def getFrontpageThumb(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
165 """returns the image object for the frontpage thumbnail"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
166 img = getattr(self, 'img-frontthumb.jpg')
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
167 return img
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
168
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
169 def getFrontpageThumbUrl(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
170 """returns the URL of the image object for the frontpage thumbnail"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
171 img = getattr(self, 'img-frontthumb.jpg')
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
172 return img.absolute_url()
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
173
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
174 def getThumbImg(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
175 """returns the image object for the sidebar thumbnail"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
176 img = getattr(self, 'img-thumb.jpg')
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
177 return img
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
178
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
179 def getThumbImgUrl(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
180 """returns the URL of the image object for the sidebar thumbnail"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
181 img = getattr(self, 'img-thumb.jpg')
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
182 return img.absolute_url()
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
183
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
184 def changeWeight(self,weight,RESPONSE=None):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
185 """change weight"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
186 self.weight=weight
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
187 if RESPONSE is not None:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
188 RESPONSE.redirect('manage_main')
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
189
16
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
190 def changeMPIWGFeature(self, title=None, weight=None, date=None, title_en=None, title_de=None, RESPONSE=None):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
191 """change everything"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
192 if title is not None:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
193 self.title = title
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
194 if weight is not None:
16
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
195 self.weight = weight
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
196 if date is not None:
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
197 try:
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
198 self.date = datetime.datetime.strptime(date, '%Y-%m-%d').date()
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
199 except:
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
200 pass
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
201
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
202 folder_en = self.get('en', None)
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
203 if folder_en is not None:
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
204 main_en = folder_en.get('main.pt', None)
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
205 if main_en is not None and title_en is not None:
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
206 main_en.title = title_en
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
207
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
208 folder_de = self.get('de', None)
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
209 if folder_de is not None:
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
210 main_de = folder_de.get('main.pt', None)
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
211 if main_de is not None and title_de is not None:
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
212 main_de.title = title_de
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
213
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
214 if RESPONSE is not None:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
215 RESPONSE.redirect('manage_main')
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
216
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
217 def getBreadcrumbs(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
218 """return list of breadcrumbs from here to the root"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
219 crumbs = [(self.getFullTitle(), self.absolute_url(), self)]
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
220 parent = self.aq_parent
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
221 if hasattr(parent, 'getBreadcrumbs'):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
222 if self.title:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
223 return parent.getBreadcrumbs() + crumbs
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
224 else:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
225 # if there's no title, skip this level
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
226 return parent.getBreadcrumbs()
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
227
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
228 return crumbs
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
229
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
230 getSection = getSection
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
231
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
232 getSubSection = getSubSection
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
233
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
234
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
235 def manage_addMPIWGFeatureForm(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
236 """Form for adding"""
16
54f135c1ed65 updated MPIWGFeature.
casties
parents: 9
diff changeset
237 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt/feature/manage_add_MPIWGFeature.zpt')).__of__(self)
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
238 return pt()
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
239
17
6d374d94c7e3 nicer add feature form.
casties
parents: 16
diff changeset
240 def manage_addMPIWGFeature(self, id, title=None, weight=0, title_en=None, title_de=None, RESPONSE=None):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
241 "Add a MPIWG Feature object"
17
6d374d94c7e3 nicer add feature form.
casties
parents: 16
diff changeset
242 newObj=MPIWGFeature(id,title=title,weight=weight,title_en=title_en,title_de=title_de)
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
243 self.Destination()._setObject(id,newObj)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
244 if RESPONSE is not None:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
245 RESPONSE.redirect('manage_main')
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
246