Projet

Général

Profil

« Précédent | Suivant » 

Révision d8827fce

Ajouté par Frédéric Péters il y a plus de 7 ans

misc: update to new CheckboxesWidget init signature (#13386)

Voir les différences:

extra/modules/agenda.py
236 236
        if tags and remote_calendars:
237 237
            form.widgets.append(HtmlWidget('<table id="agenda-filter"><tr><td>'))
238 238
        if tags:
239
            form.add(CheckboxesWidget, 'tags', title = _('Tags'),
240
                    elements = [(x,x) for x in tags],
241
                    inline = False)
239
            form.add(CheckboxesWidget, 'tags', title=_('Tags'),
240
                    options=[(x,x) for x in tags],
241
                    inline=False)
242 242
        if tags and remote_calendars:
243 243
            form.widgets.append(HtmlWidget('</td><td>'))
244 244
        if remote_calendars:
245 245
            remote_calendars.sort(lambda x,y: cmp(x.label, y.label))
246
            form.add(CheckboxesWidget, 'calendars', title = _('Calendars'),
247
                    elements = [('local', _('Local'))] + [(x.id, x.label) for x in remote_calendars],
248
                    inline = False)
246
            form.add(CheckboxesWidget, 'calendars', title=_('Calendars'),
247
                    options=[('local', _('Local'))] + [(x.id, x.label) for x in remote_calendars],
248
                    inline=False)
249 249
        if tags and remote_calendars:
250 250
            form.widgets.append(HtmlWidget('</td></tr></table>'))
251 251

  
extra/modules/myspace.py
707 707

  
708 708
        form = Form(enctype = 'multipart/form-data')
709 709
        form.add(CheckboxesWidget, 'themes', title=_('Announce Themes'),
710
                value=enabled_themes, elements=options,
710
                value=enabled_themes, options=[(x, x) for x in options],
711 711
                inline=False, required=False)
712 712

  
713 713
        form.add_submit('submit', _('Apply Changes'))
tests/test_user_pages.py
119 119
    resp = resp.follow(status=302)
120 120
    resp.location.startswith('http://example.net/cat/test/?mt=')
121 121
    resp = resp.follow(status=403)
122

  
123
def test_announces():
124
    from modules.announces import Announce, AnnounceSubscription
125

  
126
    if not 'misc' in pub.cfg:
127
        pub.cfg['misc'] = {}
128
    pub.cfg['misc']['announce_themes'] = ['Foo', 'Bar']
129
    pub.write_cfg()
130

  
131
    announce = Announce()
132
    announce.title = 'Hello World'
133
    announce.text = 'Lorem ipsum...'
134
    announce.publication_time = time.gmtime(time.time()-100000)
135
    announce.store()
136

  
137
    user = create_user()
138
    app = login(get_app(pub), username='user', password='user')
139
    resp = app.get('/announces/', status=200)
140
    resp = resp.click('Receiving those Announces')
141
    resp = resp.click('Email')
142
    assert 'You are logged in but there is no email address in your profile.' in resp.body
143
    assert 'email' in resp.form.fields
144
    user.email = 'foo@localhost'
145
    user.store()
146
    resp = app.get('/announces/email', status=200)
147
    assert 'foo@localhost' in resp.body
148
    assert not 'email' in resp.form.fields
149
    resp = resp.form.submit()
150
    assert AnnounceSubscription.count() == 1
151

  
152
    resp = app.get('/myspace/', status=200)
153
    resp = resp.click('Edit my Subscription to Announces')
154
    assert resp.form['themes$elementFoo'].checked
155
    assert resp.form['themes$elementBar'].checked
156
    resp.form['themes$elementFoo'].checked = False
157
    resp = resp.form.submit('submit')
158
    assert AnnounceSubscription.count() == 1
159

  
160
    resp = app.get('/myspace/announces', status=200)
161
    assert not resp.form['themes$elementFoo'].checked
162
    assert resp.form['themes$elementBar'].checked
163

  
164
def test_agenda():
165
    from modules.events import Event, RemoteCalendar
166

  
167
    remote_calendar = RemoteCalendar()
168
    remote_calendar.label = 'Remote'
169
    remote_calendar.store()
170

  
171
    event = Event()
172
    event.title = 'Hello World'
173
    event.description = 'Lorem ipsum...'
174
    event.date_start = time.strptime('2016-09-10', '%Y-%m-%d')
175
    event.date_end = time.strptime('2016-09-12', '%Y-%m-%d')
176
    event.store()
177

  
178
    app = get_app(pub)
179
    resp = app.get('/agenda/', status=200)
180
    resp = app.get('/agenda/filter')
181
    assert 'tags$elementAdults' in resp.form.fields
182
    assert 'calendars$elementlocal' in resp.form.fields

Formats disponibles : Unified diff