- Timestamp:
- Dec 3, 2013, 12:21:44 AM (13 years ago)
- Branches:
- master, stable, stage
- Children:
- ed7ddec
- Parents:
- 88a856b
- git-author:
- Alex Dehnert <adehnert@…> (12/02/13 23:56:40)
- git-committer:
- Alex Dehnert <adehnert@…> (12/03/13 00:21:44)
- Location:
- asadb
- Files:
-
- 3 edited
-
forms/models.py (modified) (5 diffs)
-
forms/views.py (modified) (2 diffs)
-
template/membership/people-lookup.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
asadb/forms/models.py
r88a856b rd66942f 243 243 'affiliate': other, 244 244 } 245 descriptions = {246 'undergrads': 'Undergraduate students',247 'grads': 'Graduate students',248 'staff': 'MIT Staff (including faculty)',249 'secret': 'People with directory information suppressed. These people have Athena accounts, but they could have any MIT affiliation, including just being a student group member.',250 'affiliate': 'This includes some alumni, group members with Athena accounts sponsored through SAO, and many others.',251 }252 245 for result in results: 253 246 username = result[1]['uid'][0] … … 257 250 year = result[1].get('mitDirStudentYear', [None])[0] 258 251 if year == 'G': 259 grads.append( username)252 grads.append((username, None)) 260 253 elif year.isdigit(): 261 254 undergrads.append((username, year)) … … 263 256 other.append((username, year)) 264 257 else: 265 info[affiliation].append(username) 266 info['unknown'] = left 267 descriptions['unknown'] = "While this looks like an Athena account, we couldn't find it. This could be a deactivated account, or it might never have existed." 268 return descriptions, info 258 info[affiliation].append((username, None, )) 259 info['unknown'] = [(u, None) for u in left] 260 return info 269 261 270 262 def classify_people(self, people): 271 263 mit_usernames = set() 272 alum_addresses = set()273 other_mit_addresses = set()274 nonmit_addresses = set()264 alum_addresses = [] 265 other_mit_addresses = [] 266 nonmit_addresses = [] 275 267 276 268 for name in people: … … 279 271 mit_usernames.add(local) 280 272 elif domain.lower() == 'alum.mit.edu': 281 alum_addresses.a dd(name)273 alum_addresses.append((name, None)) 282 274 elif domain.endswith('.mit.edu'): 283 other_mit_addresses.a dd(name)275 other_mit_addresses.append((name, None)) 284 276 else: 285 nonmit_addresses.add(name) 286 287 descriptions, results = self.ldap_classify(mit_usernames) 288 descriptions['alum'] = "Alumni Association addresses" 289 descriptions['other-mit'] = ".mit.edu addresses that aren't @mit.edu or @alum.mit.edu." 290 descriptions['non-mit'] = "Non-MIT addresses, including outside addresses of MIT students." 277 nonmit_addresses.append((name, None)) 278 279 results = self.ldap_classify(mit_usernames) 291 280 results['alum'] = alum_addresses 292 281 results['other-mit'] = other_mit_addresses 293 282 results['non-mit'] = nonmit_addresses 294 295 sorted_results = {} 296 for k, v in results.items(): 297 sorted_results[k] = { 298 'description': descriptions[k], 299 'people': sorted(v), 300 } 301 return sorted_results 283 return results 302 284 303 285 def update_classified_people(self): 304 people = [p.strip() for p in self.people.split('\n')] 305 print people 286 people = [p for p in [p.strip() for p in self.people.split('\n')] if p] 306 287 self._classified_people = self.classify_people(people) 307 288 self.classified_people_json = json.dumps(self._classified_people) … … 314 295 return self._classified_people 315 296 297 def classifications_with_descriptions(self): 298 descriptions = { 299 'undergrads': 'Undergraduate students (class year in parentheses)', 300 'grads': 'Graduate students', 301 'alum': "Alumni Association addresses", 302 'staff': 'MIT Staff (including faculty)', 303 'affiliate': 'This includes some alumni, group members with Athena accounts sponsored through SAO, and many others.', 304 'secret': 'People with directory information suppressed. These people have Athena accounts, but they could have any MIT affiliation, including just being a student group member.', 305 'unknown': "While this looks like an Athena account, we couldn't find it. This could be a deactivated account, or it might never have existed.", 306 'other-mit': ".mit.edu addresses that aren't @mit.edu or @alum.mit.edu.", 307 'non-mit': "Non-MIT addresses, including outside addresses of MIT students.", 308 } 309 310 names = ( 311 ('undergrads', 'Undergrads', ), 312 ('grads', 'Grad students', ), 313 ('alum', 'Alumni', ), 314 ('staff', 'Staff', ), 315 ('affiliate', 'Affiliates', ), 316 ('secret', 'Secret', ), 317 ('unknown', 'Unknown', ), 318 ('other-mit', 'Other MIT addresses', ), 319 ('non-mit', 'Non-MIT addresses', ), 320 ) 321 322 classifications = self.classified_people 323 sorted_results = [] 324 for k, label in names: 325 sorted_results.append({ 326 'label': label, 327 'description': descriptions[k], 328 'people': sorted(classifications[k]), 329 }) 330 return sorted_results 331 316 332 317 333 ########## -
asadb/forms/views.py
r88a856b rd66942f 572 572 lookup.requestor = request.user 573 573 lookup.referer = request.META['HTTP_REFERER'] 574 results = lookup.update_classified_people() 574 lookup.update_classified_people() 575 results = lookup.classifications_with_descriptions() 575 576 lookup.save() 576 577 else: … … 580 581 if request.user.has_perm('forms.view_peoplestatusupdate'): 581 582 lookup = get_object_or_404(forms.models.PeopleStatusLookup, pk=int(pk)) 582 results = lookup.classifi ed_people583 results = lookup.classifications_with_descriptions() 583 584 form = None 584 585 else: -
asadb/template/membership/people-lookup.html
r88a856b rd66942f 4 4 {% block content %} 5 5 6 <h 2>People lookup</h2>6 <h1>People lookup</h1> 7 7 8 8 {% if form %} 9 <p>You can specify a list of email addresses and/or MIT usernames below, and we'll try to identify which ones are undergrads, grad students, etc.. This is not definitive (<kbd>joe.mit.student@gmail.com</kbd> will show up as "other", for example, and we can't check the student status of people who chose to suppress MIT directory information), but it may be a good first step in figuring out the breakdown of your membership numbers.</p>9 <p>You can specify a list of email addresses and/or MIT usernames below, and we'll try to identify which ones are undergrads, grad students, and so forth:</p> 10 10 11 11 <form enctype="multipart/form-data" method="post" action=""> … … 20 20 21 21 {% if results %} 22 <h2>Results</h2> 23 24 <p>This information is not definitive (<kbd>joe.mit.student@gmail.com</kbd> will show up as "other", for example, and we can't check the student status of people who chose to suppress MIT directory information), but we hope it can be helpful in figuring out the breakdown of your membership numbers.</p> 25 26 <p><em>If you wish to use this for an ASA form, <strong>you</strong> will need to transfer the numbers yourself – we do not do that automatically.</em></p> 27 22 28 <table class='pretty-table'> 23 29 <tr> 24 30 <th>Type</th> 25 <th >Description</th>31 <th style='width: 20em;'>Description</th> 26 32 <th>Number</th> 27 33 <th>People</th> 28 34 </tr> 29 {% for name,result in results.items %}35 {% for result in results %} 30 36 <tr> 31 <th>{{ name}}</th>37 <th>{{result.label}}</th> 32 38 <td>{{result.description}}</td> 33 <td >{{result.people|length}}</td>39 <td style='text-align: right; padding: 0.5em;'>{{result.people|length}}</td> 34 40 <td><ul> 35 41 {% for person in result.people %} 36 <li>{{person }}</li>42 <li>{{person.0}}{% if person.1 %} ({{person.1}}){%endif%}</li> 37 43 {% endfor %} 38 44 </ul></td>
Note: See TracChangeset
for help on using the changeset viewer.