Changeset 89165c1


Ignore:
Timestamp:
Sep 15, 2013, 7:05:10 AM (13 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, stable, stage
Children:
00ec3e4
Parents:
645ab74
git-author:
Alex Dehnert <adehnert@…> (09/15/13 06:42:50)
git-committer:
Alex Dehnert <adehnert@…> (09/15/13 07:05:10)
Message:

Track student status with moira "affiliation"

Moira recently added an "affiliation" field with information about whether a
person is student, staff, etc.. This changes the ASA DB to use that field by
default to determine student status. For some people with suppressed directory
information ("secret people"), however, affiliation will be "affiliate" but
should be "student". Those people can have their record changed to use a "loose
student" algorithm that considers somebody a student if their affiliation or
account class indicate that they're a student.

Location:
asadb
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • asadb/groups/admin.py

    rfa218b1 r89165c1  
    203203        'last_name',
    204204        'account_class',
     205        'affiliation_basic',
     206        'loose_student',
    205207        'mutable',
    206208        'add_date',
     
    210212    list_display_links = ( 'id', 'username', )
    211213    search_fields = ( 'username', 'mit_id', 'first_name', 'last_name', 'account_class', )
    212     list_filter = ( 'account_class', 'mutable', )
     214    list_filter = (
     215        'account_class',
     216        'affiliation_basic', 'affiliation_detailed',
     217        'loose_student',
     218        'mutable',
     219    )
    213220admin.site.register(groups.models.AthenaMoiraAccount, Admin_AthenaMoiraAccount)
  • asadb/groups/load_people.py

    r161ce5f r89165c1  
    2626    'last_name',
    2727    'account_class',
     28    'affiliation_basic',
     29    'affiliation_detailed',
    2830]
    2931
  • asadb/groups/models.py

    rc4282e2 r89165c1  
    1212from django.conf import settings
    1313from django.db import models
     14from django.db.models import Q
    1415from django.core.validators import RegexValidator
    1516from django.contrib.auth.models import User
     
    525526        return super(AthenaMoiraAccount_ActiveManager, self).get_query_set().filter(del_date=None)
    526527
     528def student_account_classes():
     529    year = datetime.datetime.now().year
     530    return ["G"] + [str(yr) for yr in range(year-5, year+10)]
     531
    527532class AthenaMoiraAccount(models.Model):
    528533    username = models.CharField(max_length=8, unique=True, )
     
    531536    last_name       = models.CharField(max_length=45)
    532537    account_class   = models.CharField(max_length=10)
     538    affiliation_basic       = models.CharField(max_length=10)
     539    affiliation_detailed    = models.CharField(max_length=40)
     540    loose_student   = models.BooleanField(default=False, help_text='Whether to use loose or strict determination of student status. Loose means that either the account class or the affiliation should indicate student status; strict means that the affiliation must be student. In general, we use strict; for some people ("secret people") directory information is suppressed and the affiliation will be misleading.')
    533541    mutable         = models.BooleanField(default=True)
    534542    add_date        = models.DateField(help_text="Date when this person was added to the dump.", )
     
    540548
    541549    def is_student(self, ):
    542         # XXX: Is this... right?
    543         return self.account_class == 'G' or self.account_class.isdigit()
     550        student_affiliation = (self.affiliation_basic == 'student')
     551        student_class = (self.account_class in student_account_classes())
     552        return student_affiliation or (student_class and self.loose_student)
     553
     554    @staticmethod
     555    def student_q():
     556        q_affiliation = Q(affiliation_basic='student')
     557        q_class = Q(account_class__in=student_account_classes())
     558        return q_affiliation | (q_class & Q(loose_student=True))
    544559
    545560    def format(self, ):
  • asadb/groups/views.py

    r242566d r89165c1  
    12941294def show_nonstudent_officers(request, ):
    12951295    student_roles  = groups.models.OfficerRole.objects.filter(require_student=True, )
    1296     year = datetime.datetime.now().year
    1297     account_classes = ["G"] + [str(yr) for yr in range(year-5, year+10)]
    1298     students = groups.models.AthenaMoiraAccount.active_accounts.filter(account_class__in=account_classes)
     1296    student_q = groups.models.AthenaMoiraAccount.student_q()
     1297    students = groups.models.AthenaMoiraAccount.active_accounts.filter(student_q)
    12991298    office_holders = groups.models.OfficeHolder.current_holders.order_by('group__name', 'role', )
    13001299    office_holders = office_holders.filter(role__in=student_roles)
  • asadb/template/groups/reporting/non-students.html

    r52fb1d5 r89165c1  
    4444    <td>{{holder.group.group_status}}</td>
    4545    <td>{{holder.role.display_name}}</td>
    46     <td>{{holder.person}}</td>
     46    <td>{% if perms.groups.change_athenamoiraaccount %}<a href='{% url admin:groups_athenamoiraaccount_changelist %}?username={{holder.person}}'>{{holder.person}}</a>{% else %}{{holder.person}}{% endif %}</td>
    4747</tr>
    4848{% endfor %}
Note: See TracChangeset for help on using the changeset viewer.