Changeset 7d0207b
- Timestamp:
- Mar 14, 2012, 3:27:01 PM (14 years ago)
- 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)
- Files:
-
- 14 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
asadb/groups/diffs.py
r7654a6d r80a8145 64 64 self.since = since 65 65 self.now = now 66 self.stats = collections.defaultdict(lambda: 0) 66 67 67 68 def handle_group(self, before, after, before_fields, after_fields, ): … … 102 103 prev_group = signatory.group 103 104 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, ) 105 107 106 108 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 107 114 message = "\n\n".join(self.updates) 108 115 signatories_message = "\n".join(self.signatory_updates) … … 158 165 def handle_group(self, before, after, before_fields, after_fields, ): 159 166 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'], )) 161 169 self.delete.append(before_fields['officer_email']) 162 170 … … 178 186 address='asa-admin@mit.edu', 179 187 template='groups/diffs/asa-update-mail.txt', 180 signatories=['president', 'treasurer', 'financial', ]188 signatories=['president', 'treasurer', 'financial', 'group-admin', 'temp-admin', ] 181 189 )) 182 190 sao_callback = StaticMailCallback( … … 198 206 return objs 199 207 200 def diff_objects(objs, since, callbacks ):208 def diff_objects(objs, since, callbacks, stats, ): 201 209 revs = reversion.models.Revision.objects.all() 202 210 old_revs = revs.filter(date_created__lte=since) … … 212 220 if len(before_versions) > 0: 213 221 before = before_versions[0] 222 stats['change_old'] += 1 214 223 else: 215 224 # New group that's been edited since. Diff against the creation 216 225 # (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 #) 223 234 before_fields = before.field_dict 224 235 after_fields = after.field_dict … … 227 238 else: 228 239 # 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 230 245 231 246 def diff_signatories(since, now, callbacks): … … 244 259 objs = recent_groups(since=recent) 245 260 callbacks = build_callbacks() 261 stats = collections.defaultdict(lambda: 0) 246 262 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) 248 264 diff_signatories(recent, now, callbacks=callbacks, ) 249 265 for callback in callbacks: callback.end_run() 250 266 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 251 272 if __name__ == '__main__': 252 273 generate_diffs() -
asadb/groups/import_signatories.py
r0653daa r00079cf 74 74 75 75 @transaction.commit_on_success 76 def perform_sync(stats, dj_map, wh_map, ):76 def perform_sync(stats, dj_map, wh_map, roles=None, dj_groups=None, ): 77 77 # Statistics 78 78 stats['loops'] = 0 … … 83 83 stats['added'] = 0 84 84 stats['missing_rg'] = 0 85 stats['missing_role'] = 0 85 86 86 87 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() 89 92 for key in set(dj_map.keys()).union(wh_map.keys()): 90 93 stats['loops'] += 1 … … 130 133 stats['added'] += 1 131 134 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 136 143 137 144 if __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] 139 166 140 167 print "Phase 1: %s: Loading Django officer information" % (datetime.datetime.now(), ) … … 142 169 print "Phase 1: %s: Complete: Loading Django officer information" % (datetime.datetime.now(), ) 143 170 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(), ) 145 183 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(), ) 151 189 152 190 print """ … … 155 193 Django current: %(dj_total_current)6d 156 194 Django distinct: %(dj_distinct_current)6d 195 Django ignored groups: %(group_ign)6d 157 196 158 197 Warehouse p/r/g tuples: %(wh_size)6d … … 164 203 People expired: %(expired)6d 165 204 People missing from WH: %(missing_wh)6d 205 People in missing group:%(missing_rg)6d 206 People for missing role:%(missing_role)6d 166 207 People added: %(added)6d 167 208 """ % stats -
asadb/groups/models.py
r0270ed7 rf8bd496 38 38 num_community = models.IntegerField(null=True, blank=True, ) 39 39 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") 42 42 main_account_id = models.IntegerField(null=True, blank=True, ) 43 43 funding_account_id = models.IntegerField(null=True, blank=True, ) -
asadb/groups/views.py
r0270ed7 r4368c00 93 93 roles.append((role.display_name, role, group.officers(role=role), )) 94 94 context['roles'] = roles 95 context['my_roles'] = group.officers(person=self.request.user.username).select_related('role') 95 96 96 97 return context … … 160 161 model = groups.models.Group 161 162 163 @login_required 162 164 def manage_main(request, pk, ): 163 165 group = get_object_or_404(groups.models.Group, pk=pk) … … 399 401 return render_to_response('groups/create/nge.html', context, context_instance=RequestContext(request), ) 400 402 403 @login_required 401 404 def startup_form(request, ): 402 405 msg = None … … 605 608 return people, roles, name_map, officers_map 606 609 610 @login_required 607 611 def manage_officers(request, pk, ): 608 612 group = get_object_or_404(groups.models.Group, pk=pk) … … 652 656 if person in new_holders: 653 657 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(): 655 661 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, )) 656 662 #changes.append(("Kept", "yellow", person, role)) … … 658 664 else: 659 665 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 661 667 elif role.require_student and not moira_accounts[person].is_student(): 662 668 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, )) … … 676 682 if i in new_people: 677 683 person = new_people[i] 684 assert person in moira_accounts 678 685 if role.require_student and not moira_accounts[person].is_student(): 679 686 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 27 27 color: #008; 28 28 } 29 30 table.group-list tbody th 31 { 32 text-align: left; 33 } 34 29 35 ul.errorlist 30 36 { -
asadb/template/groups/group_detail.html
r0270ed7 r41f8b1e 89 89 </table> 90 90 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 91 111 <h2>Notes</h2> 92 112 -
asadb/template/groups/group_list.html
re499677 r8c7a670 21 21 <tr> 22 22 <th>Name</th> 23 <th>Abbreviation</th> 23 24 <th>Status</th> 24 25 <th>Website</th> … … 32 33 <tr class='group-status-{{group.group_status.slug}} group-active-{{group.group_status.is_active}}'> 33 34 <th>{{group.name}}</th> 35 <th>{{group.abbreviation}}</th> 34 36 <td class='group-status'>{{group.group_status}}</td> 35 37 <td>{% if group.website_url %}<a href='{{group.website_url}}'>Website</a>{%endif%}</td> -
asadb/template/groups/groups_signatories.html
re499677 r8389289 17 17 <h2>The Groups</h2> 18 18 19 <table class='pretty-table '>19 <table class='pretty-table group-list'> 20 20 <thead> 21 21 <tr> … … 29 29 {%for group, role_list in officers %} 30 30 <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> 32 36 {%for holders in role_list%} 33 37 <td>{% if holders %}<ul>{% for person in holders %}<li>{{person}}</li>{%endfor%}</ul>{% endif %}</td> -
asadb/template/index.html
r6229687 r9ec48f9 39 39 <li><a href='{%url fysm-select%}'>Submit an entry</a></li> 40 40 </ul></li> 41 {% comment %} 41 42 <li>Membership updates<ul> 42 43 <li><a href='{%url membership-update%}'>Group update</a></li> … … 45 46 {% if perms.groups.view_group_private_info %}<li><a href='{%url membership-issues%}'>Issues</a> (CSV)</li>{% endif %} 46 47 </ul></li> 48 {% endcomment %} 47 49 <li>Group recognition<ul> 48 50 <li><a href='http://web.mit.edu/asa/start/new-group-app.html'>New Group Application</a></li> … … 53 55 <li><a href='{% url about %}'>About the ASA Database</a><ul> 54 56 <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> 55 62 </ul></li> 56 63 </ul> -
asadb/util/mailman.py
r4098256 rfb76571 33 33 for member in add_members: 34 34 cmdline.append('-a') 35 if type(member) == type(()): 36 name, email = member 37 name = name.replace('"', "''") 38 member = '"%s" <%s>' % (name, email, ) 35 39 cmdline.append(member) 36 40 for member in delete_members: -
asadb/groups/urls.py
raa2aa58 r6ff04b1 2 2 3 3 import groups.views 4 import space.views 4 5 5 6 group_patterns = patterns('', … … 8 9 url(r'^edit/officers$', groups.views.manage_officers, name='group-manage-officers', ), 9 10 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', ), 10 12 ) 11 13 -
asadb/settings.py
r8d36a62 ra86a924 124 124 'groups', 125 125 'forms', 126 'space', 126 127 ) 127 128
Note: See TracChangeset
for help on using the changeset viewer.