annotate MPIWGFeature.py @ 159:ee79f6ba8d01

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