Conjunto de mudanças 6575 no repositório publico


Ignorar:
Timestamp:
28/06/2012 18:40:24 (9 anos atrás)
Autor:
mazza
Mensagem:

refatoracao: IRelated como schema base para algumas caixas

Localização:
PortalInterlegis/produtos/il.portalinterlegis/trunk/src/il/portalinterlegis
Arquivos:
1 adicionado
3 editados
1 movido

Legenda:

Não Modificado
Adicionado
Removido
  • PortalInterlegis/produtos/il.portalinterlegis/trunk/src/il/portalinterlegis/browser/boxes/interfaces.py

    r6555 r6575  
    1414    """
    1515
    16 
    1716# decorator
    18 def rich(*args, **kwargs):
     17def rich(**kwargs):
    1918    def f(cls):
    20         cls.setTaggedValue(WIDGETS_KEY,
    21                            dict([(k, WysiwygFieldWidget) for k in args],
    22                                 **kwargs))
     19        cls.setTaggedValue(WIDGETS_KEY, dict(**kwargs))
    2320        return cls
    2421    return f
    2522
    2623
    27 @rich('text', target=AutocompleteFieldWidget)
    28 class ISimpleBox(BoxSchema):
    29     title = schema.TextLine(title=u"Título", required=True)
    30     subtitle = schema.TextLine(title=u"Subtítulo", required=True)
    31     text = schema.Text(title=u"Texto", required=False)
    32     target = schema.Choice(title=u"Conteúdo relacionado",
    33                            source=PathSourceBinder(),
    34                            required=False)
    35     # TODO: imagem !!!
    36 
    37 
    38 # TODO: remover esse copiar-e-colar entre esse e ISimpleBox: extrair uma classe base comum?
    39 @rich('text', target=AutocompleteFieldWidget)
    40 class ICarouselItem(BoxSchema):
     24@rich(text=WysiwygFieldWidget, target=AutocompleteFieldWidget)
     25class IRelated(BoxSchema):
    4126    target = schema.Choice(title=u"Conteúdo relacionado",
    4227                           source=PathSourceBinder(),
     
    4530    title = schema.TextLine(title=u"Título", required=True)
    4631    text = schema.Text(title=u"Texto", required=False)
     32
     33
     34class ISuperTitleBox(IRelated):
     35    supertitle = schema.TextLine(title=u"Supertítulo", required=True)
     36
     37
     38class ICarouselItem(IRelated):
     39    # It's important to have a separate class (instead of using IRelated directly)
     40    # since the class name is used for storage
     41    pass
    4742
    4843
  • PortalInterlegis/produtos/il.portalinterlegis/trunk/src/il/portalinterlegis/browser/homes.py

    r6555 r6575  
    22from Products.CMFPlone.interfaces import IPloneSiteRoot
    33from boxes.carousel import CarouselBox
    4 from boxes.interfaces import ISimpleBox, ICalendar, IAcompanheOInterlegis, IHighlight
     4from boxes.interfaces import ISuperTitleBox, ICalendar, IAcompanheOInterlegis, IHighlight
    55from boxes.manager import DtRow, Box, GridView
    66from boxes.tabs import Tab, TabbedPane
     
    3333            ))),
    3434        ___((FULL, _(IAcompanheOInterlegis, 1)), ),
    35         ___((4, _(IHighlight, 1)), (4, _(ISimpleBox, 1)), (4, _(ISimpleBox, 2)), (4, _(ISimpleBox, 3)),),
     35        ___((4, _(IHighlight, 1)), (4, _(ISuperTitleBox, 1)), (4, _(ISuperTitleBox, 2)), (4, _(ISuperTitleBox, 3)),),
    3636    ]
    3737
  • PortalInterlegis/produtos/il.portalinterlegis/trunk/src/il/portalinterlegis/tests/testintegration.py

    r6538 r6575  
    66
    77from fixtures import IL_PORTALINTERLEGIS_INTEGRATION_TESTING
    8 from il.portalinterlegis.browser.boxes.interfaces import ISimpleBox
     8from il.portalinterlegis.browser.boxes.interfaces import ISuperTitleBox
    99from il.portalinterlegis.browser.boxes.manager import \
    1010     Box, build_box_form, NUMBER_OF_PRE_CREATED_BOXES
     
    6868
    6969    def test_box_content_is_empty_before_visiting_form(self):
    70         self.assertEqual({}, Box(ISimpleBox, 1).get_data(self.portal))
     70        self.assertEqual({}, Box(ISuperTitleBox, 1).get_data(self.portal))
    7171
    7272    def test_using_box_form_creates_box_content(self):
    7373        context = self.portal
    7474
    75         def use_box_form(title, subtitle, text, target, box):
     75        def use_box_form(supertitle, title, text, target, box):
    7676            browser = self.layer.manager_browser()
    7777            browser.open(self.url(box.form_name))
     78            browser.getControl(name='form.widgets.supertitle').value = supertitle
    7879            browser.getControl(name='form.widgets.title').value = title
    79             browser.getControl(name='form.widgets.subtitle').value = subtitle
    8080            browser.getControl(name='form.widgets.text').value = text
    8181            # TODO: nao sei como testar um AutocompleteFieldWidget com o zope.testbrowser (tem javascript)
     
    8383            browser.getControl(name='form.buttons.apply').click()
    8484
    85         box_1 = Box(ISimpleBox, 1)
    86         use_box_form('TIT_1', 'SUBTIT_1', 'TEXT_1', 'ALVO_1', box_1)
    87         self.assertEqual({'title': 'TIT_1', 'subtitle': 'SUBTIT_1', 'text': 'TEXT_1', 'target': None},
     85        box_1 = Box(ISuperTitleBox, 1)
     86        use_box_form('SUPERTIT_1', 'TIT_1', 'TEXT_1', 'ALVO_1', box_1)
     87        self.assertEqual(dict(supertitle='SUPERTIT_1', title='TIT_1', text='TEXT_1', target=None, image=None),
    8888                         box_1.get_data(context))
    8989
    9090        # a second one to test there is no mutual interference
    91         box_2 = Box(ISimpleBox, 2)
    92         use_box_form('TIT_2', 'SUBTIT_2', 'TEXT_2', 'ALVO_2', box_2)
    93         self.assertEqual({'title': 'TIT_2', 'subtitle': 'SUBTIT_2', 'text': 'TEXT_2', 'target': None},
     91        box_2 = Box(ISuperTitleBox, 2)
     92        use_box_form('SUPERTIT_2', 'TIT_2', 'TEXT_2', 'ALVO_2', box_2)
     93        self.assertEqual(dict(supertitle='SUPERTIT_2', title='TIT_2', text='TEXT_2', target=None, image=None),
    9494                         box_2.get_data(context))
    9595
     
    9797        browser = self.layer.manager_browser()
    9898        # These are ok. No exception raised
    99         browser.open(self.url(Box(ISimpleBox, 0).form_name))
    100         browser.open(self.url(Box(ISimpleBox,
     99        browser.open(self.url(Box(ISuperTitleBox, 0).form_name))
     100        browser.open(self.url(Box(ISuperTitleBox,
    101101                                  NUMBER_OF_PRE_CREATED_BOXES - 1).form_name))
    102102        with self.assertRaises(NotFound):
    103103            # This doesn't exist
    104             browser.open(self.url(Box(ISimpleBox,
     104            browser.open(self.url(Box(ISuperTitleBox,
    105105                                      NUMBER_OF_PRE_CREATED_BOXES).form_name))
    106106
     
    109109           Unfortunately that's not possible.
    110110        """
    111         build_box_form(Box(ISimpleBox, 99))
     111        build_box_form(Box(ISuperTitleBox, 99))
    112112        with self.assertRaises(NotFound):
    113113            browser = self.layer.manager_browser()
    114             browser.open(self.url(Box(ISimpleBox, 99).form_name))
     114            browser.open(self.url(Box(ISuperTitleBox, 99).form_name))
    115115
    116116    # CAROUSEL
Note: Veja TracChangeset para ajuda no uso do visualizador de conjunto de mudanças.
 

The contents and data of this website are published under license:
Creative Commons 4.0 Brasil - Atribuir Fonte - Compartilhar Igual.