space-accessstablestage
Last change
on this file since 63aea04 was
c547de5,
checked in by Alex Dehnert <adehnert@…>, 13 years ago
|
Improve the header of the exported HTML files
Files in question are /mit/asa-db/data/db-dump/{midway,website}_groups.html, as
generated by groups/format_groups.py midway and util/export_website_groups.py.
Added information:
- Paths to /mit/asa-db/data/db-dump/*.html generated files (ASA-#134)
- Timestamp of generation (ASA-#135)
- Who can re-run the scripts (ASA-#136)
- Which groups are included
|
-
Property mode set to
100755
|
File size:
1.3 KB
|
Rev | Line | |
---|
[d9137a7] | 1 | #!/usr/bin/python |
---|
| 2 | # |
---|
| 3 | # Use as e.g. |
---|
| 4 | # ./export_website_groups.py > /mit/asa/resources/group-include.html |
---|
| 5 | |
---|
[884ab7c] | 6 | import codecs |
---|
[c547de5] | 7 | import datetime |
---|
[d9137a7] | 8 | import os |
---|
| 9 | import sys |
---|
| 10 | |
---|
| 11 | if __name__ == '__main__': |
---|
| 12 | cur_file = os.path.abspath(__file__) |
---|
| 13 | django_dir = os.path.abspath(os.path.join(os.path.dirname(cur_file), '..')) |
---|
| 14 | sys.path.append(django_dir) |
---|
| 15 | os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' |
---|
| 16 | |
---|
| 17 | from django.template import Template, Context |
---|
| 18 | import groups.models |
---|
| 19 | |
---|
[884ab7c] | 20 | TMPL = Template(u""" |
---|
[c547de5] | 21 | <!-- |
---|
| 22 | Automatically generated by asadb/util/export_website_groups.py on {{date}}. |
---|
| 23 | Do not edit; instead ask a DB maintainer (asa-db@) to re-run that script (or edit script as necessary). |
---|
| 24 | |
---|
| 25 | A more recent version may be in /mit/asa-db/data/db-dump/website_groups.html. |
---|
| 26 | Includes groups with status is_active=True (ie, Suspended and Active groups). |
---|
| 27 | --> |
---|
[d9137a7] | 28 | {% for group in groups %} |
---|
| 29 | <tr><td> |
---|
| 30 | {% if group.website_url %} |
---|
| 31 | <a href="{{group.website_url}}">{{group.name}}</a> |
---|
| 32 | {% else %} |
---|
| 33 | {{group.name}} |
---|
| 34 | {% endif %} |
---|
| 35 | </td><td>{{group.description}}</td></tr> |
---|
| 36 | {% endfor %} |
---|
| 37 | """) |
---|
| 38 | |
---|
| 39 | if __name__ == '__main__': |
---|
[c547de5] | 40 | ctx = Context({ |
---|
| 41 | 'groups': groups.models.Group.objects.filter(group_status__is_active=True), |
---|
| 42 | 'date': datetime.datetime.now(), |
---|
| 43 | }) |
---|
| 44 | out = codecs.getwriter('utf-8')(sys.stdout) |
---|
[884ab7c] | 45 | out.write(TMPL.render(ctx)) |
---|
Note: See
TracBrowser
for help on using the repository browser.