Changeset 7d0207b


Ignore:
Timestamp:
Mar 14, 2012, 3:27:01 PM (14 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, space-access, stable, stage
Children:
b2d74ac
Parents:
d85ba8f (diff), 4368c00 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Alex Dehnert <adehnert@…> (03/14/12 15:27:01)
git-committer:
Alex Dehnert <adehnert@…> (03/14/12 15:27:01)
Message:

Merge branch 'master' into office-access

Files:
14 added
12 edited

Legend:

Unmodified
Added
Removed
  • asadb/groups/diffs.py

    r7654a6d r80a8145  
    6464        self.since = since
    6565        self.now = now
     66        self.stats = collections.defaultdict(lambda: 0)
    6667
    6768    def handle_group(self, before, after, before_fields, after_fields, ):
     
    102103                prev_group = signatory.group
    103104            else:
    104                 print "Ignoring role %s (signatory %s)" % (signatory.role.slug, signatory, )
     105                self.stats["role." + signatory.role.slug] += 1
     106                #print "Ignoring role %s (signatory %s)" % (signatory.role.slug, signatory, )
    105107
    106108    def end_run(self, ):
     109        print "\nChange stats for email to %s:" % (self.address, )
     110        for stat_key, stat_val in self.stats.items():
     111            print "%20s:\t%6d" % (stat_key, stat_val, )
     112        print ""
     113
    107114        message = "\n\n".join(self.updates)
    108115        signatories_message = "\n".join(self.signatory_updates)
     
    158165    def handle_group(self, before, after, before_fields, after_fields, ):
    159166        if before_fields['officer_email'] != after_fields['officer_email']:
    160             self.add.append("%s <%s>" % (after_fields['name'], after_fields['officer_email'], ))
     167            name = after_fields['name']
     168            self.add.append((after_fields['name'], after_fields['officer_email'], ))
    161169            self.delete.append(before_fields['officer_email'])
    162170
     
    178186        address='asa-admin@mit.edu',
    179187        template='groups/diffs/asa-update-mail.txt',
    180         signatories=['president', 'treasurer', 'financial', ]
     188        signatories=['president', 'treasurer', 'financial', 'group-admin', 'temp-admin', ]
    181189    ))
    182190    sao_callback = StaticMailCallback(
     
    198206    return objs
    199207
    200 def diff_objects(objs, since, callbacks):
     208def diff_objects(objs, since, callbacks, stats, ):
    201209    revs  = reversion.models.Revision.objects.all()
    202210    old_revs = revs.filter(date_created__lte=since)
     
    212220            if len(before_versions) > 0:
    213221                before = before_versions[0]
     222                stats['change_old'] += 1
    214223            else:
    215224                # New group that's been edited since. Diff against the creation
    216225                # (since creation sent mail, but later changes haven't)
    217                 after = after_versions[-1]
    218             print "Change?: before=%s (%d), after=%s (%d), type=%s, new=%s" % (
    219                 before, before.pk,
    220                 after, after.pk,
    221                 after.type, after.field_dict,
    222             )
     226                before = after_versions.reverse()[0]
     227                stats['change_new'] += 1
     228            stats['change_total'] += 1
     229            #print "Change?: before=%s (%d), after=%s (%d), type=%s, new=%s" % (
     230            #    before, before.pk,
     231            #    after, after.pk,
     232            #    after.type, after.field_dict,
     233            #)
    223234            before_fields = before.field_dict
    224235            after_fields = after.field_dict
     
    227238        else:
    228239            # New group that's only been edited once
    229             pass
     240            # Note that "normal" new groups will have their startup form
     241            # (which creates the Group object) and the approval (which makes
     242            # more changes, so this is group startups + NGEs, not actually
     243            # normal new groups)
     244            stats['new_group'] += 1
    230245
    231246def diff_signatories(since, now, callbacks):
     
    244259    objs = recent_groups(since=recent)
    245260    callbacks = build_callbacks()
     261    stats = collections.defaultdict(lambda: 0)
    246262    for callback in callbacks: callback.start_run(since=recent, now=now, )
    247     diff_objects(objs, since=recent, callbacks=callbacks)
     263    diff_objects(objs, since=recent, callbacks=callbacks, stats=stats)
    248264    diff_signatories(recent, now, callbacks=callbacks, )
    249265    for callback in callbacks: callback.end_run()
    250266
     267    print "\nOverall change stats:"
     268    for stat_key, stat_val in stats.items():
     269        print "%20s:\t%6d" % (stat_key, stat_val, )
     270    print ""
     271
    251272if __name__ == '__main__':
    252273    generate_diffs()
  • asadb/groups/import_signatories.py

    r0653daa r00079cf  
    7474
    7575@transaction.commit_on_success
    76 def perform_sync(stats, dj_map, wh_map, ):
     76def perform_sync(stats, dj_map, wh_map, roles=None, dj_groups=None, ):
    7777    # Statistics
    7878    stats['loops'] = 0
     
    8383    stats['added'] = 0
    8484    stats['missing_rg'] = 0
     85    stats['missing_role'] = 0
    8586
    8687    today = datetime.date.today()
    87     roles = load_roles()
    88     dj_groups = load_groups()
     88    if roles is None:
     89        roles = load_roles()
     90    if dj_groups is None:
     91        dj_groups = load_groups()
    8992    for key in set(dj_map.keys()).union(wh_map.keys()):
    9093        stats['loops'] += 1
     
    130133                        stats['added'] += 1
    131134                    else:
    132                         print "Missing role or group: person=%s, role=%s, group=%d, start=%s, expiry=%s" % (
    133                             person, role_slug, group_id, start, expiry,
    134                         )
    135                         stats['missing_rg'] += 1
     135                        if role_slug not in roles:
     136                            stats['missing_role'] += 1
     137                        else:
     138                            print "Missing role or group: person=%s, role=%s, group=%d, start=%s, expiry=%s" % (
     139                                person, role_slug, group_id, start, expiry,
     140                            )
     141                            stats['missing_rg'] += 1
     142
    136143
    137144if __name__ == '__main__':
    138     stats = {}
     145    stats = {
     146        'group_ign': 0,
     147    }
     148
     149    mode = 'all'
     150    roles = None # default
     151    if len(sys.argv) > 1:
     152        if sys.argv[1] == 'squash':
     153            mode = 'squash'
     154        elif sys.argv[1] == 'all':
     155            pass
     156        else:
     157            raise NotImplementedError
     158    if mode == 'squash':
     159        roles = load_roles()
     160        repl = roles['temp-admin']
     161        for slug, role in roles.items():
     162            if slug in ('president', 'treasurer', 'financial', ):
     163                roles[slug] = repl
     164            else:
     165                del roles[slug]
    139166
    140167    print "Phase 1: %s: Loading Django officer information" % (datetime.datetime.now(), )
     
    142169    print "Phase 1: %s: Complete: Loading Django officer information" % (datetime.datetime.now(), )
    143170
    144     print "Phase 2: %s: Loading warehouse officer information" % (datetime.datetime.now(), )
     171    print "Phase 2: %s: Loading Django group information" % (datetime.datetime.now(), )
     172    dj_groups = load_groups()
     173    if mode == 'squash':
     174        for pk, group in dj_groups.items():
     175            if len(group.officers()) > 1:
     176                stats['group_ign'] += 1
     177                del dj_groups[pk]
     178            else:
     179                print "Keeping ", group
     180    print "Phase 2: %s: Complete: Loading Django group information" % (datetime.datetime.now(), )
     181
     182    print "Phase 3: %s: Loading warehouse officer information" % (datetime.datetime.now(), )
    145183    wh_map = load_warehouse(stats)
    146     print "Phase 2: %s: Complete: Loading warehouse officer information" % (datetime.datetime.now(), )
    147 
    148     print "Phase 3: %s: Performing sync" % (datetime.datetime.now(), )
    149     perform_sync(stats, dj_map, wh_map, )
    150     print "Phase 3: %s: Complete: Performing sync" % (datetime.datetime.now(), )
     184    print "Phase 3: %s: Complete: Loading warehouse officer information" % (datetime.datetime.now(), )
     185
     186    print "Phase 4: %s: Performing sync" % (datetime.datetime.now(), )
     187    perform_sync(stats, dj_map, wh_map, roles, dj_groups, )
     188    print "Phase 4: %s: Complete: Performing sync" % (datetime.datetime.now(), )
    151189
    152190    print """
     
    155193    Django current:         %(dj_total_current)6d
    156194    Django distinct:        %(dj_distinct_current)6d
     195    Django ignored groups:  %(group_ign)6d
    157196
    158197    Warehouse p/r/g tuples: %(wh_size)6d
     
    164203    People expired:         %(expired)6d
    165204    People missing from WH: %(missing_wh)6d
     205    People in missing group:%(missing_rg)6d
     206    People for missing role:%(missing_role)6d
    166207    People added:           %(added)6d
    167208    """ % stats
  • asadb/groups/models.py

    r0270ed7 rf8bd496  
    3838    num_community = models.IntegerField(null=True, blank=True, )
    3939    num_other = models.IntegerField(null=True, blank=True, )
    40     group_email = models.EmailField(blank=True, )
    41     officer_email = models.EmailField()
     40    group_email = models.EmailField(verbose_name="group email list", blank=True, )
     41    officer_email = models.EmailField(verbose_name="officers' email list")
    4242    main_account_id = models.IntegerField(null=True, blank=True, )
    4343    funding_account_id = models.IntegerField(null=True, blank=True, )
  • asadb/groups/views.py

    r0270ed7 r4368c00  
    9393            roles.append((role.display_name, role, group.officers(role=role), ))
    9494        context['roles'] = roles
     95        context['my_roles'] = group.officers(person=self.request.user.username).select_related('role')
    9596
    9697        return context
     
    160161        model = groups.models.Group
    161162
     163@login_required
    162164def manage_main(request, pk, ):
    163165    group = get_object_or_404(groups.models.Group, pk=pk)
     
    399401    return render_to_response('groups/create/nge.html', context, context_instance=RequestContext(request), )
    400402
     403@login_required
    401404def startup_form(request, ):
    402405    msg = None
     
    605608    return people, roles, name_map, officers_map
    606609
     610@login_required
    607611def manage_officers(request, pk, ):
    608612    group = get_object_or_404(groups.models.Group, pk=pk)
     
    652656                    if person in new_holders:
    653657                        if (person, role) in officers_map:
    654                             if role.require_student and not moira_accounts[person].is_student():
     658                            if person not in moira_accounts:
     659                                pass # already errored above
     660                            elif role.require_student and not moira_accounts[person].is_student():
    655661                                msgs.append('Only students can have the %s role, and %s does not appear to be a student. (If this is not the case, please contact us.) You should replace this person ASAP.' % (role, person, ))
    656662                            #changes.append(("Kept", "yellow", person, role))
     
    658664                        else:
    659665                            if person not in moira_accounts:
    660                                 msgs.append('Could not add nonexistent Athena account "%s" as %s.' % (person, role, ))
     666                                pass # already errored above
    661667                            elif role.require_student and not moira_accounts[person].is_student():
    662668                                msgs.append('Only students can have the %s role, and %s does not appear to be a student. (If this is not the case, please contact us.)' % (role, person, ))
     
    676682                        if i in new_people:
    677683                            person = new_people[i]
     684                            assert person in moira_accounts
    678685                            if role.require_student and not moira_accounts[person].is_student():
    679686                                msgs.append('Only students can have the %s role, and %s does not appear to be a student.' % (role, person, ))
  • asadb/media/style/style.css

    re499677 rbb48649  
    2727    color: #008;
    2828}
     29
     30table.group-list tbody th
     31{
     32    text-align: left;
     33}
     34
    2935ul.errorlist
    3036{
  • asadb/template/groups/group_detail.html

    r0270ed7 r41f8b1e  
    8989</table>
    9090
     91<h2>My Connection</h2>
     92
     93{% if my_roles %}
     94<p>You have the following connections to this group:</p>
     95<table class='pretty-table'>
     96<tr>
     97    <th>Connection</th>
     98    <th>Description</th>
     99</tr>
     100{% for holder in my_roles %}
     101<tr>
     102    <th>{{holder.role.display_name}}</th>
     103    <td>{{holder.role.description}}</td>
     104</tr>
     105{% endfor %}
     106</table>
     107{% else %}
     108<p>No roles in this group.</p>
     109{% endif %}
     110
    91111<h2>Notes</h2>
    92112
  • asadb/template/groups/group_list.html

    re499677 r8c7a670  
    2121    <tr>
    2222        <th>Name</th>
     23        <th>Abbreviation</th>
    2324        <th>Status</th>
    2425        <th>Website</th>
     
    3233    <tr class='group-status-{{group.group_status.slug}} group-active-{{group.group_status.is_active}}'>
    3334        <th>{{group.name}}</th>
     35        <th>{{group.abbreviation}}</th>
    3436        <td class='group-status'>{{group.group_status}}</td>
    3537        <td>{% if group.website_url %}<a href='{{group.website_url}}'>Website</a>{%endif%}</td>
  • asadb/template/groups/groups_signatories.html

    re499677 r8389289  
    1717<h2>The Groups</h2>
    1818
    19 <table class='pretty-table'>
     19<table class='pretty-table group-list'>
    2020<thead>
    2121<tr>
     
    2929{%for group, role_list in officers %}
    3030<tr>
    31     <th><a href='{% url groups:group-detail group.pk %}'>{{group}}</a> ({{group.group_status}})</th>
     31    <th>
     32        <a href='{% url groups:group-detail group.pk %}'>{{group}}</a> ({{group.group_status}})
     33        {% if group.abbreviation %}<br>Abbreviation: {{group.abbreviation}}{% endif %}
     34        {% if user.is_authenticated and group.officer_email %}<br>Officer list: {{group.officer_email}}{% endif %}
     35    </th>
    3236    {%for holders in role_list%}
    3337    <td>{% if holders %}<ul>{% for person in holders %}<li>{{person}}</li>{%endfor%}</ul>{% endif %}</td>
  • asadb/template/index.html

    r6229687 r9ec48f9  
    3939        <li><a href='{%url fysm-select%}'>Submit an entry</a></li>
    4040    </ul></li>
     41    {% comment %}
    4142    <li>Membership updates<ul>
    4243        <li><a href='{%url membership-update%}'>Group update</a></li>
     
    4546        {% if perms.groups.view_group_private_info %}<li><a href='{%url membership-issues%}'>Issues</a> (CSV)</li>{% endif %}
    4647    </ul></li>
     48    {% endcomment %}
    4749    <li>Group recognition<ul>
    4850        <li><a href='http://web.mit.edu/asa/start/new-group-app.html'>New Group Application</a></li>
     
    5355    <li><a href='{% url about %}'>About the ASA Database</a><ul>
    5456        <li><a href='{% url about-data %}'>Use of Data</a></li>
     57    </ul></li>
     58    <li>Related resources<ul>
     59        <li><a href='http://web.mit.edu/asa/'>Association of Student Activities (ASA)</a></li>
     60        <li><a href='http://studentlife.mit.edu/sao'>Student Activities Office (SAO)</a></li>
     61        <li><a href='http://studentlife.mit.edu/cac'>Campus Activities Complex (CAC)</a></li>
    5562    </ul></li>
    5663</ul>
  • asadb/util/mailman.py

    r4098256 rfb76571  
    3333        for member in add_members:
    3434            cmdline.append('-a')
     35            if type(member) == type(()):
     36                name, email = member
     37                name = name.replace('"', "''")
     38                member = '"%s" <%s>' % (name, email, )
    3539            cmdline.append(member)
    3640        for member in delete_members:
  • asadb/groups/urls.py

    raa2aa58 r6ff04b1  
    22
    33import groups.views
     4import space.views
    45
    56group_patterns = patterns('',
     
    89    url(r'^edit/officers$', groups.views.manage_officers, name='group-manage-officers', ),
    910    url(r'^history/$', groups.views.GroupHistoryView.as_view(), name='group-manage-history', ),
     11    url(r'^space/view/$', space.views.view_access, name='group-space-access', ),
    1012)
    1113
  • asadb/settings.py

    r8d36a62 ra86a924  
    124124    'groups',
    125125    'forms',
     126    'space',
    126127)
    127128
Note: See TracChangeset for help on using the changeset viewer.