Changeset ecf87c8


Ignore:
Timestamp:
Jun 5, 2013, 5:53:11 AM (13 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, stable, stage
Children:
17c118f
Parents:
242566d (diff), 72a3d90 (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@…> (06/05/13 05:53:05)
git-committer:
Alex Dehnert <adehnert@…> (06/05/13 05:53:11)
Message:

Merge branch 'space-access'

This branch was created to fix ASA-#96 ("Differentiate between spaces CAC does
and does not manage access to"), but also fixes a wide variety of other
space-related issues.

  • space-access: (23 commits) Fill in the office access timeframe Fix grammar ({e,a}ffect) Punt another spurious slash Use "Space Access" more consistently Add "Details" link to "Space access" page Rename 50-030 to 50-032 and set its lock type Space: tell groups CAC should reply (ASA-#235) Warn people off the "Space access" page (ASA-#233) Don't let people edit spaces the DB doesn't manage More Walker rooms Correct Walker room access Add info_url to the admin Incorporate feedback from CAC Update the space emails with non-DB-managed info Comment space/diffs.py's locker code a bit better Show lock types on manage access page Describe the lock types and list on space summary Add list of lock types and assign them to rooms Use pagename "groups", not "group" WIP: more non-CAC space work ...
Location:
asadb
Files:
4 added
13 edited

Legend:

Unmodified
Added
Removed
  • asadb/space/admin.py

    r358b26f r3c1b20b  
    66import util.admin
    77
     8class Admin_LockType(VersionAdmin):
     9    list_display = (
     10        'id',
     11        'name',
     12        'slug',
     13        'info_addr',
     14        'info_url',
     15        'db_update',
     16    )
     17    list_display_links = ( 'id', 'name', 'slug', )
     18    search_fields = ('name', 'slug', 'info_addr', 'info_url', 'db_update', )
     19admin.site.register(space.models.LockType, Admin_LockType)
     20
    821class Admin_Space(VersionAdmin):
    922    list_display = (
     
    1124        'number',
    1225        'asa_owned',
     26        'lock_type',
    1327        'merged_acl',
    1428    )
    1529    list_display_links = ( 'id', 'number', )
     30    list_filter = ('lock_type', )
    1631    search_fields = ('number', )
    1732admin.site.register(space.models.Space, Admin_Space)
  • asadb/space/diffs.py

    rc8f4eea r27e09a9  
    88    cur_file = os.path.abspath(__file__)
    99    django_dir = os.path.abspath(os.path.join(os.path.dirname(cur_file), '..'))
     10    django_dir_parent = os.path.abspath(os.path.join(os.path.dirname(cur_file), '../..'))
    1011    sys.path.append(django_dir)
     12    sys.path.append(django_dir_parent)
    1113    os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
    1214
    1315from django.core.mail import EmailMessage
     16from django.core.urlresolvers import reverse
    1417from django.db import connection
    1518from django.db.models import Q
     
    100103
    101104    def list_office_changes(self, ):
    102         cac_lines = []
     105        systems_lines = {
     106            'cac-card': [],
     107            'none': [],
     108        }
    103109        group_lines = []
    104         def append_change(mit_id, verb, name):
    105             cac_lines.append("%s:\t%s:\t%s" % (mit_id, verb, name))
    106             group_lines.append("%s:\t%s" % (verb, name))
    107110        for space_pk, space_data in self.offices.items():
     111            lock_type = all_spaces[space_pk].lock_type
     112            system_lines = systems_lines[lock_type.db_update]
     113            def append_change(mit_id, verb, name):
     114                system_lines.append("%s:\t%s:\t%s" % (mit_id, verb, name))
     115                group_lines.append("%s:\t%s" % (verb, name))
     116
    108117            line = "Changes in %s:" % (all_spaces[space_pk].number, )
    109             cac_lines.append(line)
     118            system_lines.append(line)
    110119            group_lines.append(line)
     120
     121            if lock_type.db_update == 'none':
     122                tmpl =  'Warning: You submitted changes affecting this space, but this space is ' + \
     123                        'a "%s" space, and is not managed through the ASA DB. See ' + \
     124                        'https://asa.mit.edu%s for details on how to update spaces of this type.'
     125                line = tmpl % (lock_type.name, reverse('space-lock-type'), )
     126                group_lines.append(line)
     127
    111128            for mit_id, (old_names, new_names) in space_data.items():
    112129                if mit_id is None: mit_id = "ID unknown"
     
    125142                        else:
    126143                            append_change(mit_id, "Add", name)
    127             cac_lines.append("")
     144            system_lines.append("")
    128145            group_lines.append("")
    129146
    130         cac_msg = "\n".join(cac_lines)
     147        systems_msg = dict([
     148            (system, '\n'.join(lines), ) for (system, lines) in systems_lines.items()
     149        ])
    131150        group_msg = "\n".join(group_lines)
    132         return cac_msg, group_msg
     151        return systems_msg, group_msg
    133152
    134153    def add_locker_signatories(self, space_access, time):
     
    177196
    178197def safe_add_change_real(change_by_name, change):
     198    """Add a new change to our dict of pending changes.
     199
     200    If a different change has already been added for this person (eg, "Remove"
     201    instead of "Keep", or with a different list of groups), error.  This should
     202    always succeed; if it doesn't, the code is buggy. We worry about this
     203    because we want to be really sure that the email that goes to just CAC is
     204    compatible with the emails that go to each groups. Since we iterate over
     205    the changes once per group, we want to be sure that for each group
     206    iteration we're building compatible information.
     207    """
     208
    179209    name = change.name
    180210    if name in change_by_name:
     
    200230        print "ID=%s (%s):\n\t%s\t(%s)\n\t%s\t(%s)\n" % (mit_id, unchanged, old_by_names, old_by_group, new_by_names, new_by_group, ),
    201231        for group_pk in joint_keys(old_by_group, new_by_group):
     232            # TODO: Do we need to do an iteration for each group? This seems
     233            # slightly questionable. Can we just loop over all known names?
     234
    202235            old_names = old_by_group[group_pk]
    203236            new_names = new_by_group[group_pk]
     
    267300    cac_locker_msgs = []
    268301
    269     process_spaces =  space.models.Space.objects.all()
     302    process_spaces =  space.models.Space.objects.all().select_related('lock_type')
    270303    for the_space in process_spaces:
    271304        new_cac_msgs = space_specific_access(the_space, group_data, old_time, new_time)
     
    274307
    275308    changed_groups = []
     309    cac_chars = 0
    276310    for group_pk, group_info in group_data.items():
    277311        group_info.add_office_signatories(old_time, new_time)
    278         cac_changes, group_office_changes = group_info.list_office_changes()
     312        systems_changes, group_office_changes = group_info.list_office_changes()
    279313        if group_info.changes:
    280             changed_groups.append((group_info.group, cac_changes, group_office_changes, group_info.locker_messages, ))
     314            cac_chars += len(systems_changes['cac-card'])
     315            changed_groups.append((group_info.group, systems_changes['cac-card'], group_office_changes, group_info.locker_messages, ))
    281316
    282317    asa_rcpts = ['asa-space@mit.edu', 'asa-db@mit.edu', ]
    283     if changed_groups:
     318    if cac_chars > 0 or cac_locker_msgs:
    284319        util.emails.email_from_template(
    285320            tmpl='space/cac-change-email.txt',
  • asadb/space/models.py

    r7eea15c r8aea837  
    1111EXPIRE_OFFSET   = datetime.timedelta(seconds=1)
    1212
     13LOCK_DB_UPDATE_NONE = 'none'
     14LOCK_DB_UPDATE_CAC_CARD = 'cac-card'
     15lock_db_update_choices = (
     16    (LOCK_DB_UPDATE_NONE, "No database management"),
     17    (LOCK_DB_UPDATE_CAC_CARD, "CAC-managed card-based access"),
     18)
     19
     20class LockType(models.Model):
     21    name = models.CharField(max_length=50)
     22    slug = models.SlugField(unique=True, )
     23    description = models.TextField()
     24    info_addr = models.EmailField(default='asa-exec@mit.edu', help_text='Address groups should email to get more information about managing access through this lock type.')
     25    info_url = models.URLField(blank=True, help_text='URL that groups can visit to get more information about this lock type.')
     26    db_update = models.CharField(max_length=20, default='none', choices=lock_db_update_choices)
     27
     28    def __unicode__(self, ):
     29        return self.name
     30
     31
    1332class Space(models.Model):
    1433    number = models.CharField(max_length=20, unique=True, )
    1534    asa_owned = models.BooleanField(default=True, )
     35    lock_type = models.ForeignKey(LockType)
    1636    merged_acl = models.BooleanField(default=False, help_text="Does this room have a single merged ACL, that combines all groups together, or CAC maintain a separate ACL per-group? Generally, the shared storage offices get a merged ACL and everything else doesn't.")
    1737    notes = models.TextField(blank=True, )
  • asadb/space/views.py

    rde2f0ac rf6982d4  
    9090        'allow_edit': allow_edit,
    9191        'extras_indices': extras_indices,
    92         'pagename':'group',
     92        'pagename':'groups',
    9393    }
    9494    return render_to_response('space/manage-access.html', context, context_instance=RequestContext(request), )
     
    112112        'locker_num',
    113113        'group__name',
    114     ).select_related('space', 'group')
     114    ).select_related('space', 'space__lock_type', 'group')
    115115    office_assignments = assignments.filter(locker_num='')
    116116
     
    127127        'offices': office_assignments,
    128128        'lockers': locker_rooms,
    129         'pagename':'group',
     129        'pagename':'groups',
    130130    }
    131131    return render_to_response('space/summary.html', context, context_instance=RequestContext(request), )
     132
     133def lock_types(request, ):
     134    lock_types = space.models.LockType.objects.order_by('name')
     135    context = {
     136        'lock_types': lock_types,
     137        'pagename': 'groups',
     138    }
     139    return render_to_response('space/lock_types.html', context, context_instance=RequestContext(request), )
  • asadb/template/index.html

    r870992c r3c1b20b  
    5858    </ul></li>
    5959    <li><a href='{% url space-summary %}'>Space assignments</a>
     60        <ul>
     61        <li><a href='{% url space-lock-type %}'>Lock Types</a></li>
    6062        {% if perms.groups.view_group_private_info %}
    61         <ul>
    6263        <li><a href='{% url space-dump-locker-access %}'>Locker access (CSV)</a></li>
    6364        <li><a href='{% url space-dump-office-access %}'>Office access (CSV)</a></li>
     65        {% endif %}
    6466        </ul>
    65         {% endif %}
    6667    </li>
    6768    <li><a href='{% url about %}'>About the ASA Database</a><ul>
  • asadb/template/space/group-change-email.txt

    rd768e47 r72a3d90  
    11{% autoescape off %}Hi {{group.name}},
    2     Thank you for updating space access on the ASA database today. We've forwarded the following changes on to CAC:
     2
     3Thank you for updating space access on the ASA database today. We are forwarding these changes to CAC, which generally updates access within one week. They will reply when the update has been done; if you don't get a reply, the message may have been lost and you should reply-all to this email reminding them.
     4
     5We believe you made the following changes:
    36
    47{% if office_msg %}
  • asadb/template/space/manage-access.html

    r78de8cb r1927d79  
    11{% extends "base.html" %}
    22
    3 {% block title %}{{group.name}}: Office Access{% endblock %}
     3{% block title %}{{group.name}}: Space Access{% endblock %}
    44{% block content %}
    55
    6 <h1>{{group.name}}: Office Access</h1>
     6<h1>{{group.name}}: Space Access</h1>
    77
    88{% include "groups/group_tools.part.html" %}
     
    4848    <th>{{assignment.space}}</th>
    4949    <td>
     50        {% with assignment.space.lock_type as lock_type %}
     51        {% if lock_type.db_update == "none" %}
     52        <p><strong>Warning: Access to this office is not managed through the ASA DB.</strong></p>
     53        <p><em><a href='{% url space-lock-type %}'>{{lock_type.name}}</a></em>: {{lock_type.description}}{% if lock_type.info_url %} <a href='{{lock_type.info_url}}'>Details.</a>{%endif%}</p>
     54        <p>Contact <a href='mailto:{{lock_type.info_addr}}'>{{lock_type.info_addr}}</a> for more information.</p>
     55
     56        {% else %}
     57
     58        <p>We recommend managing access on the <a href='{% url groups:group-manage-officers group.id %}'>update people</a> page if possible. You should only need to use this page if:</p>
     59        <ul>
     60            <li>You need to grant access to somebody who does not have an Athena account, or</li>
     61            <li>Your group has several offices, and somebody needs access to one or more of the offices, but should not have access to all of them</li>
     62        </ul>
     63
    5064        <table class='pretty-table'>
    5165            <tr>
     
    6781            </tr>{% endfor %}
    6882        </table>
     83
     84        {% endif %}
     85        {% endwith %}
     86
    6987    </td>
    7088</tr>
  • asadb/template/space/summary.html

    rde2f0ac rf6982d4  
    2727    <th>Room</th>
    2828    <th>Group</th>
     29    <th><a href='{% url space-lock-type %}'>Lock Type</a></th>
    2930    <th>Access</th>
    3031</tr>
     
    3334    <td>{{office.space.number}}</td>
    3435    <td><a href='{% url groups:group-detail office.group.pk %}'>{{office.group}}</a></td>
     36    <td>{{office.space.lock_type.name}}</td>
    3537    <td><a href='{% url groups:group-space-access office.group.pk %}'>Access</a></td>
    3638</tr>
  • asadb/urls.py

    r870992c r3c1b20b  
    8686    url(r'^space/dump/office-access.csv$', space.views.dump_office_access, name='space-dump-office-access', ),
    8787    url(r'^space/$', space.views.summary, name='space-summary', ),
     88    url(r'^space/lock_types.html$', space.views.lock_types, name='space-lock-type', ),
    8889
    8990    # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
  • asadb/util/diff_static_data.sh

    raab0dc8 r3c1b20b  
    1212../../manage.py dumpdata --format=xml --indent=4 groups.ActivityCategory > groups_initial_data.xml
    1313../../manage.py dumpdata --format=xml --indent=4 forms.FYSMCategory > forms_initial_data.xml
    14 git add {groups,forms}_initial_data.xml
     14../../manage.py dumpdata --format=xml --indent=4 space.LockType --format=xml --indent=4 > space_lock_types.xml
     15git add {groups,forms}_initial_data.xml space_lock_types.xml
    1516
    1617echo
  • asadb/groups/views.py

    r8ccd88f r242566d  
    630630        self.fields['constitution_url'].required = True
    631631        self.fields['constitution_url'].help_text = "Please put a copy of your finalized constitution on a publicly-accessible website (e.g. your group's, or your own, Public folder), and link to it in the box above."
     632        self.fields['group_email'].required = True
    632633        self.fields['athena_locker'].required = True
    633634        self.fields['athena_locker'].help_text = "In general, this is limited to twelve characters. You should stick to letters, numbers, and hyphens. (Underscores and dots are also acceptable, but may cause problems in some situations.)"
     
    849850            group_startup.save()
    850851
    851             group.group_status = groups.models.GroupStatus.objects.get(slug='active')
     852            group.group_status = groups.models.GroupStatus.objects.get(slug='suspended')
    852853            group.constitution_url = ""
    853854            group.recognition_date = datetime.datetime.now()
    854855            group.set_updater(request.user)
     856
     857            note = groups.models.GroupNote(
     858                author=request.user.username,
     859                body="Approved group for recognition.",
     860                acl_read_group=True,
     861                acl_read_offices=True,
     862                group=group,
     863            ).save()
    855864
    856865            group.save()
  • asadb/template/groups/account_lookup.html

    rcfde3dc r9469a73  
    4141</tr>
    4242</table>
     43{% endif %}
     44
     45{% if account_number %}
     46<p>You may be able to find information about account {{account_number}} in <a href='https://rolesweb.mit.edu/cgi-bin/roleauth2.pl?category=SAP+SAP-related&amp;func_name=CAN+SPEND+OR+COMMIT+FUNDS&amp;qual_code=F{{account_number}}&amp;skip_root=Y'>Roles</a>.</p>
    4347{% endif %}
    4448
  • asadb/template/groups/diffs/new-group-announce.txt

    r798ec5b rf38b6d0  
    55to the MIT community!
    66
    7 The last step to finalize the group recognition is for you to finish entering the
    8 group's complete information into the ASA Database:
     7Your group is currently *suspended*. The last step to finalize the group
     8recognition is for you to finish entering the group's complete information into
     9the ASA Database:
    910
    1011      http://web.mit.edu/asa/www/asa-db.shtml
     
    2930can modify the information and that MIT personal certificates are
    3031required to access the group's account in the ASA Database.
     32
     33Once you have completed these steps, you must *notify asa-groups@mit.edu* to
     34become an active group.
    3135
    3236*** Please keep this e-mail for further reference. ***
Note: See TracChangeset for help on using the changeset viewer.