Changeset 0270ed7


Ignore:
Timestamp:
Feb 5, 2012, 8:14:25 PM (14 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, space-access, stable, stage
Children:
dc81a9e
Parents:
927c824
git-author:
Alex Dehnert <adehnert@…> (02/05/12 20:14:25)
git-committer:
Alex Dehnert <adehnert@…> (02/05/12 20:14:25)
Message:

Display full names of signatories

This displays the full name of signatories (not just the username) in the
group display page and the signatory change page (but not the big list
signatories page). It also requires a database query per signatory being
looked up. (This is one reason for not doing it on the big list signatories
page, the other being that full names take more space.)

Location:
asadb
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • asadb/groups/models.py

    r84af6d7 r0270ed7  
    314314    current_holders = OfficeHolder_CurrentManager()
    315315
     316    def format_person(self, ):
     317        return AthenaMoiraAccount.try_format_by_username(self.person, )
     318
    316319    def expire(self, ):
    317320        self.end_time = datetime.datetime.now()-self.EXPIRE_OFFSET
     
    438441        return self.account_class == 'G' or self.account_class.isdigit()
    439442
     443    def format(self, ):
     444        return "%s %s <%s>" % (self.first_name, self.last_name, self.username, )
     445
    440446    def __str__(self, ):
    441447        if self.mutable:
     
    451457        return str(self)
    452458
     459    @classmethod
     460    def try_format_by_username(cls, username):
     461        try:
     462            moira = AthenaMoiraAccount.objects.get(username=username)
     463            return moira.format()
     464        except AthenaMoiraAccount.DoesNotExist:
     465            return "%s (name not available)" % (username)
     466
    453467    class Meta:
    454468        verbose_name = "Athena (Moira) account"
  • asadb/groups/views.py

    rcb9b105 r0270ed7  
    595595    roles  = groups.models.OfficerRole.objects.all()
    596596
     597    name_map = {}
     598    for name in people:
     599        name_map[name] = groups.models.AthenaMoiraAccount.try_format_by_username(name)
    597600    officers_map = {}
     601
    598602    for officer in officers:
    599603        officers_map[(officer.person, officer.role)] = officer
    600604
    601     return people, roles, officers_map
     605    return people, roles, name_map, officers_map
    602606
    603607def manage_officers(request, pk, ):
     
    609613    max_new = 4
    610614
    611     people, roles, officers_map = load_officers(group)
     615    people, roles, name_map, officers_map = load_officers(group)
    612616
    613617    msgs = []
     
    683687            group.set_updater(request.user)
    684688            group.save()
    685         people, roles, officers_map = load_officers(group)
     689        people, roles, name_map, officers_map = load_officers(group)
    686690
    687691    officers_data = []
     
    693697            else:
    694698                role_list.append((role, False))
    695         officers_data.append((False, person, role_list))
     699        officers_data.append((False, person, name_map[person], role_list))
    696700    null_role_list = [(role, False) for role in roles]
    697701    for i in range(max_new):
    698         officers_data.append((True, "extra.%d" % (i, ), null_role_list))
     702        officers_data.append((True, "extra.%d" % (i, ), "", null_role_list))
    699703
    700704    context = {
  • asadb/template/groups/group_change_officers.html

    rcb9b105 r0270ed7  
    6868</thead>
    6969<tbody>
    70 {%for specify_name, person, role_list in officers %}
     70{%for specify_name, person, formatted_name, role_list in officers %}
    7171<tr>
    7272    <th>
     
    7474        <input type='text' name='{{person}}' value=''>
    7575        {% else %}
    76         {{person}}
     76        {{formatted_name}}
    7777        {% endif %}
    7878    </th>
  • asadb/template/groups/group_detail.html

    rcb9b105 r0270ed7  
    3333    <th>{{name}}{%if not role.publicly_visible %}*{%endif%}</th>
    3434    <td><ul>
    35     {% for person in people %}<li>{{person.person}}</li>{%endfor%}
     35    {% for person in people %}<li>{{person.format_person}}</li>{%endfor%}
    3636    </ul></td>
    3737</tr>
Note: See TracChangeset for help on using the changeset viewer.