Changeset e9af979


Ignore:
Timestamp:
Mar 23, 2012, 1:29:29 AM (14 years ago)
Author:
ASA Group Database <asa-db@…>
Branches:
master, space-access, stable, stage
Children:
bbaf690
Parents:
b90b977
git-author:
Alex Dehnert <adehnert@…> (03/23/12 01:29:29)
git-committer:
ASA Group Database <asa-db@…> (03/23/12 01:29:29)
Message:

Format Midway group list

File:
1 edited

Legend:

Unmodified
Added
Removed
  • asadb/groups/format_groups.py

    rb90b977 re9af979  
    1212
    1313from django.db.models import Q
     14from django.utils import html
    1415
    1516import groups.models
     
    3435        'predicate' : Qsa,
    3536    },
     37    'midway' : {
     38        'prefix': """
     39        <!-- Automatically generated by %(script)s %(mode)s.
     40        Do not edit; instead re-run that script (or edit it as necessary). -->
     41        <select name="groupname" size="5" style="width:500px">
     42        """,
     43        'suffix': "</select>",
     44        'format' : '<option value="%(html_name)s">%(html_name)s</option>',
     45        'predicate' : Q(group_status__slug__in=['active', 'suspended', 'applying', 'nge'], group_class__gets_publicity=True, ),
     46    },
    3647}
    3748
    3849def do_output(mode):
    39     format = functions[mode]['format']
    40     predicate = functions[mode]['predicate']
     50    spec = functions[mode]
     51    format = spec['format']
     52    predicate = spec['predicate']
    4153    gs = groups.models.Group.objects.filter(predicate)
     54    static_args = {'script': 'groups/format_groups.py', 'mode':mode, }
     55    if 'prefix' in spec:
     56        print spec['prefix'] % static_args
    4257    for group in gs:
    4358        print format % {
    4459            'name':group.name,
     60            'html_name':html.escape(group.name),
    4561            'officer_email':group.officer_email,
    4662        }
     63    if 'suffix' in spec:
     64        print spec['suffix'] % static_args
    4765
    4866if __name__ == "__main__":
Note: See TracChangeset for help on using the changeset viewer.