Changeset 4098256


Ignore:
Timestamp:
Nov 12, 2011, 3:46:00 AM (14 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, space-access, stable, stage, test-hooks
Children:
ea217bd
Parents:
73f0faf
git-author:
Alex Dehnert <adehnert@…> (11/12/11 02:57:03)
git-committer:
Alex Dehnert <adehnert@…> (11/12/11 03:46:00)
Message:

Keep asa-official synced as officer lists change

Location:
asadb
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • asadb/groups/diffs.py

    • Property mode changed from 100644 to 100755
    r73f0faf r4098256  
    2222import groups.models
    2323import settings
     24import util.emails
     25import util.mailman
    2426
    2527update_asa_exec = 'asa-exec@mit.edu'
    2628update_funding_board = 'asa-db@mit.edu'
    2729update_constitution_archive = 'asa-db@mit.edu'
     30
     31asa_all_groups_list = util.mailman.MailmanList('asa-official')
     32asa_all_groups_list = util.mailman.MailmanList('asa-test-mailman')
    2833
    2934class DiffCallback(object):
     
    121126        self.signatory_updates = []
    122127
     128
     129class UpdateOfficerListCallback(DiffCallback):
     130    def start_run(self, since, now, ):
     131        self.add = []
     132        self.delete = []
     133
     134    def end_run(self, ):
     135        if self.add or self.delete:
     136            errors = asa_all_groups_list.change_members(self.add, self.delete)
     137            subject = "asa-official updater"
     138            if errors:
     139                subject = "ERROR: " + subject
     140            context = {
     141                'add': self.add,
     142                'delete': self.delete,
     143                'errors': errors,
     144            }
     145            util.emails.email_from_template(
     146                tmpl='groups/diffs/asa-official-update.txt',
     147                context=context, subject=subject,
     148                to=['testing@mit.edu'],
     149            ).send()
     150
     151    def handle_group(self, before, after, before_fields, after_fields, ):
     152        if before_fields['officer_email'] != after_fields['officer_email']:
     153            self.add.append("%s <%s>" % (after_fields['name'], after_fields['officer_email'], ))
     154            self.delete.append(before_fields['officer_email'])
     155
     156    def new_group(self, after, after_fields, ):
     157        self.add.append(after_fields['officer_email'])
     158
     159
    123160diff_fields = {
    124161    'name' :            [ update_asa_exec, ],
     
    144181    sao_callback.care_about_groups = False
    145182    callbacks.append(sao_callback)
     183    callbacks.append(UpdateOfficerListCallback())
    146184    return callbacks
    147185
Note: See TracChangeset for help on using the changeset viewer.