Projet

Général

Profil

Bug #31931 » t2.py

Frédéric Péters, 08 avril 2019 15:21

 
1
from wcs.formdef import FormDef
2

    
3
for formdef in FormDef.select():
4
    changed = False
5
    for field in formdef.fields:
6
        if field.type != 'comment':
7
            continue
8
        if field.label.startswith('<'):
9
            continue
10
        if '<' not in field.label:
11
            continue
12
        if '<li' in field.label or '<p' in field.label or '<span' in field.label or '<div' in field.label or '<i' in field.label or '<b' in field.label or '<a ' in field.label or '<br>' in field.label or '<strong>' in field.label:
13
            if '\n\n' in field.label:
14
                field.label = '<p>' + field.label.replace('\n\n', '</p><p>') + '</p>'
15
            field.label = '<div>%s</div>' % field.label
16
            changed = True
17
            #print formdef, field.label
18
        else:
19
            pass #print formdef, field.label
20
    if changed:
21
        formdef.store()