Ignore:
Timestamp:
22 Feb 2014, 15:46:03 (11 years ago)
Author:
uli
Message:

Merge changes from uli-diazo-themed back into trunk. If this works, then a miracle happened.

Location:
main/waeup.kofa/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk

  • main/waeup.kofa/trunk/src/waeup/kofa

  • main/waeup.kofa/trunk/src/waeup/kofa/browser/layout.py

    r10709 r11254  
    2626from zope.i18n import translate
    2727from zope.i18nmessageid import Message
    28 from hurry.resource import mode
    2928from megrok.layout import Page, Layout, Form, EditForm, DisplayForm, AddForm
    3029from z3c.flashmessage.interfaces import IMessageSource, IMessageReceiver
     
    3736from waeup.kofa.utils.helpers import to_timezone
    3837from waeup.kofa.browser.interfaces import (
    39     ITheme, IStudentNavigationBase, IApplicantBase)
    40 from waeup.kofa.browser.theming import get_all_themes, KofaThemeBase
     38    IStudentNavigationBase, IApplicantBase)
    4139from waeup.kofa.authentication import get_principal_role_manager
    4240
     
    7472        super(KofaAction, self).__init__(label, **options)
    7573        self.style = style
     74        if style == '':
     75            self.style = 'default'
     76       
    7677
    7778    def render(self):
     
    8283            label = translate(self.label, context=self.form.request)
    8384        return ('<input type="submit" id="%s" name="%s" value="%s"'
    84                 ' class="btn %s"/>' %
     85                ' class="btn btn-%s"/>' %
    8586                (self.__name__, self.__name__, escape(label, quote=True),
    8687                self.style))
     
    9697
    9798    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'
    98105
    99106    def render(self):
     
    105112        msg = translate(self.msg, context=self.form.request)
    106113        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)
    109117                )
    110118
     
    151159        return self.url(site, name)
    152160
    153     def flash(self, message, type='alert-message warning'):
     161    def flash(self, message, type='success'):
    154162        """Send a short message to the user.
    155163        """
     164        cssClass = 'alert alert-%s' % type
    156165        source = queryUtility(IMessageSource, name='session')
    157166        if source is None:
    158167            return None
    159         source.send(message, type)
     168        source.send(message, cssClass)
    160169        return True
    161170
     
    174183        # Width parameters will be overridden by Bootstrap
    175184        # so we have to set the css class
    176         if self.widgets.get('subject'):
    177             self.widgets['subject'].cssClass = 'span9'
    178185        if self.widgets.get('body'):
    179186            self.widgets['body'].height = 10
    180         if self.widgets.get('body'):
    181             self.widgets['body'].cssClass = 'span9'
    182187
    183188class KofaPage(UtilityView,Page):
     
    202207        super(KofaEditFormPage,self).setUpWidgets(ignore_request)
    203208        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'
    208209            if 'address' in widget.name or \
    209210                'comment' in widget.name or \
    210211                'notice' in widget.name:
    211                 widget.cssClass = 'span8'
    212212                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'
    219213        if self.widgets.get('transcript_comment'):
    220             self.widgets['transcript_comment'].cssClass = 'span12'
    221214            self.widgets['transcript_comment'].height = 12
    222215        if self.widgets.get('jamb_subjects'):
    223             self.widgets['jamb_subjects'].cssClass = 'span8'
    224216            self.widgets['jamb_subjects'].height = 6
    225         if self.widgets.get('description'):
    226             self.widgets['description'].cssClass = 'span12'
    227217
    228218class KofaAddFormPage(UtilityView,AddForm):
     
    238228
    239229    #: An instance of the default theme to use for the site layout
    240     default_theme = KofaThemeBase()
    241230    stafftemp = grok.PageTemplateFile('templates/staffsitelayout.pt')
    242231    studenttemp = grok.PageTemplateFile('templates/studentsitelayout.pt')
     
    318307            return None         
    319308
    320     def update(self):
    321         """Include the resources required by the chosen skin/theme.
    322 
    323         University instances provide a 'skin' attribute, that should
    324         hold the internal name of a theme.
    325 
    326         A theme in the waeup.kofa sense consists of a list of
    327         CSS/JavaScript resources defined in the
    328         :mod:`waeup.kofa.browser.resources` module.
    329 
    330         If the context University object has no such attribute or the
    331         set value is not a valid theme name, we pick 'gray waeup
    332         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         return
    341 
    342309    def render(self):
    343310        if self.isStudent() or self.isApplicant() or not self.isAuthenticated():
Note: See TracChangeset for help on using the changeset viewer.