Changeset 11254 for main/waeup.kofa/trunk/src/waeup/kofa/browser/layout.py
- Timestamp:
- 22 Feb 2014, 15:46:03 (11 years ago)
- Location:
- main/waeup.kofa/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk
- Property svn:mergeinfo changed
-
main/waeup.kofa/trunk/src/waeup/kofa
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/main/waeup.kofa/branches/uli-diazo-themed/src/waeup/kofa merged eligible /main/waeup.kofa/branches/uli-autoinclude-less/src/waeup/kofa 8871-8888 /main/waeup.sirp/branches/uli-studentpw/src/waeup/kofa 6703-6755 /main/waeup.sirp/branches/ulif-extimgstore/src/waeup/kofa 7001-7062 /main/waeup.sirp/branches/ulif-schoolgrades/src/waeup/kofa 7761-7794
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
main/waeup.kofa/trunk/src/waeup/kofa/browser/layout.py
r10709 r11254 26 26 from zope.i18n import translate 27 27 from zope.i18nmessageid import Message 28 from hurry.resource import mode29 28 from megrok.layout import Page, Layout, Form, EditForm, DisplayForm, AddForm 30 29 from z3c.flashmessage.interfaces import IMessageSource, IMessageReceiver … … 37 36 from waeup.kofa.utils.helpers import to_timezone 38 37 from waeup.kofa.browser.interfaces import ( 39 ITheme, IStudentNavigationBase, IApplicantBase) 40 from waeup.kofa.browser.theming import get_all_themes, KofaThemeBase 38 IStudentNavigationBase, IApplicantBase) 41 39 from waeup.kofa.authentication import get_principal_role_manager 42 40 … … 74 72 super(KofaAction, self).__init__(label, **options) 75 73 self.style = style 74 if style == '': 75 self.style = 'default' 76 76 77 77 78 def render(self): … … 82 83 label = translate(self.label, context=self.form.request) 83 84 return ('<input type="submit" id="%s" name="%s" value="%s"' 84 ' class="btn %s"/>' %85 ' class="btn btn-%s"/>' % 85 86 (self.__name__, self.__name__, escape(label, quote=True), 86 87 self.style)) … … 96 97 97 98 msg = _('\'Are you sure?\'') 99 100 def __init__(self, label, style='', **options): 101 super(JSAction, self).__init__(label, **options) 102 self.style = style 103 if style == '': 104 self.style = 'default' 98 105 99 106 def render(self): … … 105 112 msg = translate(self.msg, context=self.form.request) 106 113 return ('<input type="submit" id="%s" name="%s" value="%s"' 107 ' class="btn" onclick="return confirmPost(%s)" />' % 108 (self.__name__, self.__name__, escape(label, quote=True), msg) 114 ' class="btn btn-%s" onclick="return window.confirm(%s)" />' % 115 (self.__name__, self.__name__, escape(label, quote=True), 116 self.style, msg) 109 117 ) 110 118 … … 151 159 return self.url(site, name) 152 160 153 def flash(self, message, type=' alert-message warning'):161 def flash(self, message, type='success'): 154 162 """Send a short message to the user. 155 163 """ 164 cssClass = 'alert alert-%s' % type 156 165 source = queryUtility(IMessageSource, name='session') 157 166 if source is None: 158 167 return None 159 source.send(message, type)168 source.send(message, cssClass) 160 169 return True 161 170 … … 174 183 # Width parameters will be overridden by Bootstrap 175 184 # so we have to set the css class 176 if self.widgets.get('subject'):177 self.widgets['subject'].cssClass = 'span9'178 185 if self.widgets.get('body'): 179 186 self.widgets['body'].height = 10 180 if self.widgets.get('body'):181 self.widgets['body'].cssClass = 'span9'182 187 183 188 class KofaPage(UtilityView,Page): … … 202 207 super(KofaEditFormPage,self).setUpWidgets(ignore_request) 203 208 for widget in self.widgets: 204 if widget.__class__.__name__ == 'TextWidget':205 widget.cssClass = 'span8'206 elif widget.__class__.__name__ == 'IntWidget':207 widget.cssClass = 'span2'208 209 if 'address' in widget.name or \ 209 210 'comment' in widget.name or \ 210 211 'notice' in widget.name: 211 widget.cssClass = 'span8'212 212 widget.height = 6 213 if self.widgets.get('title'):214 self.widgets['title'].cssClass = 'span12'215 if self.widgets.get('frontpage'):216 self.widgets['frontpage'].cssClass = 'span12'217 if self.widgets.get('phone'):218 self.widgets['phone'].cssClass = 'span4'219 213 if self.widgets.get('transcript_comment'): 220 self.widgets['transcript_comment'].cssClass = 'span12'221 214 self.widgets['transcript_comment'].height = 12 222 215 if self.widgets.get('jamb_subjects'): 223 self.widgets['jamb_subjects'].cssClass = 'span8'224 216 self.widgets['jamb_subjects'].height = 6 225 if self.widgets.get('description'):226 self.widgets['description'].cssClass = 'span12'227 217 228 218 class KofaAddFormPage(UtilityView,AddForm): … … 238 228 239 229 #: An instance of the default theme to use for the site layout 240 default_theme = KofaThemeBase()241 230 stafftemp = grok.PageTemplateFile('templates/staffsitelayout.pt') 242 231 studenttemp = grok.PageTemplateFile('templates/studentsitelayout.pt') … … 318 307 return None 319 308 320 def update(self):321 """Include the resources required by the chosen skin/theme.322 323 University instances provide a 'skin' attribute, that should324 hold the internal name of a theme.325 326 A theme in the waeup.kofa sense consists of a list of327 CSS/JavaScript resources defined in the328 :mod:`waeup.kofa.browser.resources` module.329 330 If the context University object has no such attribute or the331 set value is not a valid theme name, we pick 'gray waeup332 theme' as default.333 """334 mode('minified')335 theme_name = getattr(grok.getSite()['configuration'], 'skin', '')336 theme = queryUtility(ITheme, name=theme_name,337 default=self.default_theme)338 for resource in theme.getResources():339 resource.need()340 return341 342 309 def render(self): 343 310 if self.isStudent() or self.isApplicant() or not self.isAuthenticated():
Note: See TracChangeset for help on using the changeset viewer.