Changeset 59ed3da


Ignore:
Timestamp:
Apr 16, 2012, 11:36:22 PM (14 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, space-access, stable, stage
Children:
b38a26a
Parents:
bc7d506
git-author:
Alex Dehnert <adehnert@…> (04/16/12 23:36:22)
git-committer:
Alex Dehnert <adehnert@…> (04/16/12 23:36:22)
Message:

Allow read-only access to the space page

This mostly fixes ASA Trac #92.

Location:
asadb
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • asadb/space/views.py

    r2c86ed1 r59ed3da  
    4444def manage_access(request, pk, ):
    4545    group = get_object_or_404(groups.models.Group, pk=pk)
    46     if not request.user.has_perm('groups.admin_group', group):
     46
     47    priv_view = request.user.has_perm('groups.view_group_private_info', group)
     48    priv_admin = request.user.has_perm('groups.admin_group', group)
     49    priv_rw = priv_admin
     50    if not (priv_view or priv_admin):
    4751        raise PermissionDenied
     52
    4853    office_access = group.officers(role='office-access')
    4954    locker_access = group.officers(role='locker-access')
     
    5257    locker_pairs = []
    5358    changes = []
    54     extras_indices = range(6)
    55     if request.method == 'POST':
     59    if priv_rw:
     60        extras_indices = range(6)
     61    else:
     62        extras_indices = []
     63    if request.method == 'POST' and priv_rw:
    5664        edited = True
    5765    else:
     
    7179        pair = (assignment, entries)
    7280        pairs.append(pair)
    73     submit_button = (len(office_pairs) + len(locker_pairs)) > 0
     81    allow_edit = priv_rw and ((len(office_pairs) + len(locker_pairs)) > 0)
    7482    context = {
    7583        'group': group,
     
    7987        'locker_pairs': locker_pairs,
    8088        'changes': changes,
    81         'submit_button': submit_button,
     89        'allow_edit': allow_edit,
    8290        'extras_indices': extras_indices,
    8391        'pagename':'group',
  • asadb/template/space/manage-access.html

    r96ef09f r59ed3da  
    5050        <table class='pretty-table'>
    5151            <tr>
    52                 <th>Grant</th>
     52                {%if allow_edit%}<th>Grant</th>{%endif%}
    5353                <th>Name</th>
    5454                <th>MIT ID</th>
     
    5656        {% for entry in entries %}
    5757            <tr>
    58                 <td><input type='checkbox' name='grant[{{assignment.pk}}][{{entry.pk}}]' checked='checked'></td>
     58                {%if allow_edit%}<td><input type='checkbox' name='grant[{{assignment.pk}}][{{entry.pk}}]' checked='checked'></td>{% endif %}
    5959                <td>{{entry.name}}</td>
    6060                <td>{{entry.card_number}}</td>
     
    110110{% endif %}
    111111
    112 {% if submit_button %}
     112{% if allow_edit %}
    113113<input type='submit' name='submit' value='Update' />
    114114{% endif %}
Note: See TracChangeset for help on using the changeset viewer.