annotate MPIWGFeature.py @ 212:7df88b4746b4

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