Changeset ecf87c8
- Timestamp:
- Jun 5, 2013, 5:53:11 AM (13 years ago)
- 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)
- Location:
- asadb
- Files:
-
- 4 added
- 13 edited
-
space/admin.py (modified) (2 diffs)
-
space/diffs.py (modified) (7 diffs)
-
space/fixtures/LockTypes.xml (added)
-
space/migrations/0005_add_lock_type.py (added)
-
space/migrations/0006_lock_types_setup.py (added)
-
space/models.py (modified) (1 diff)
-
space/views.py (modified) (3 diffs)
-
template/index.html (modified) (1 diff)
-
template/space/group-change-email.txt (modified) (1 diff)
-
template/space/lock_types.html (added)
-
template/space/manage-access.html (modified) (3 diffs)
-
template/space/summary.html (modified) (2 diffs)
-
urls.py (modified) (1 diff)
-
util/diff_static_data.sh (modified) (1 diff)
-
groups/views.py (modified) (2 diffs)
-
template/groups/account_lookup.html (modified) (1 diff)
-
template/groups/diffs/new-group-announce.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
asadb/space/admin.py
r358b26f r3c1b20b 6 6 import util.admin 7 7 8 class 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', ) 19 admin.site.register(space.models.LockType, Admin_LockType) 20 8 21 class Admin_Space(VersionAdmin): 9 22 list_display = ( … … 11 24 'number', 12 25 'asa_owned', 26 'lock_type', 13 27 'merged_acl', 14 28 ) 15 29 list_display_links = ( 'id', 'number', ) 30 list_filter = ('lock_type', ) 16 31 search_fields = ('number', ) 17 32 admin.site.register(space.models.Space, Admin_Space) -
asadb/space/diffs.py
rc8f4eea r27e09a9 8 8 cur_file = os.path.abspath(__file__) 9 9 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), '../..')) 10 11 sys.path.append(django_dir) 12 sys.path.append(django_dir_parent) 11 13 os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' 12 14 13 15 from django.core.mail import EmailMessage 16 from django.core.urlresolvers import reverse 14 17 from django.db import connection 15 18 from django.db.models import Q … … 100 103 101 104 def list_office_changes(self, ): 102 cac_lines = [] 105 systems_lines = { 106 'cac-card': [], 107 'none': [], 108 } 103 109 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))107 110 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 108 117 line = "Changes in %s:" % (all_spaces[space_pk].number, ) 109 cac_lines.append(line)118 system_lines.append(line) 110 119 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 111 128 for mit_id, (old_names, new_names) in space_data.items(): 112 129 if mit_id is None: mit_id = "ID unknown" … … 125 142 else: 126 143 append_change(mit_id, "Add", name) 127 cac_lines.append("")144 system_lines.append("") 128 145 group_lines.append("") 129 146 130 cac_msg = "\n".join(cac_lines) 147 systems_msg = dict([ 148 (system, '\n'.join(lines), ) for (system, lines) in systems_lines.items() 149 ]) 131 150 group_msg = "\n".join(group_lines) 132 return cac_msg, group_msg151 return systems_msg, group_msg 133 152 134 153 def add_locker_signatories(self, space_access, time): … … 177 196 178 197 def 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 179 209 name = change.name 180 210 if name in change_by_name: … … 200 230 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, ), 201 231 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 202 235 old_names = old_by_group[group_pk] 203 236 new_names = new_by_group[group_pk] … … 267 300 cac_locker_msgs = [] 268 301 269 process_spaces = space.models.Space.objects.all() 302 process_spaces = space.models.Space.objects.all().select_related('lock_type') 270 303 for the_space in process_spaces: 271 304 new_cac_msgs = space_specific_access(the_space, group_data, old_time, new_time) … … 274 307 275 308 changed_groups = [] 309 cac_chars = 0 276 310 for group_pk, group_info in group_data.items(): 277 311 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() 279 313 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, )) 281 316 282 317 asa_rcpts = ['asa-space@mit.edu', 'asa-db@mit.edu', ] 283 if c hanged_groups:318 if cac_chars > 0 or cac_locker_msgs: 284 319 util.emails.email_from_template( 285 320 tmpl='space/cac-change-email.txt', -
asadb/space/models.py
r7eea15c r8aea837 11 11 EXPIRE_OFFSET = datetime.timedelta(seconds=1) 12 12 13 LOCK_DB_UPDATE_NONE = 'none' 14 LOCK_DB_UPDATE_CAC_CARD = 'cac-card' 15 lock_db_update_choices = ( 16 (LOCK_DB_UPDATE_NONE, "No database management"), 17 (LOCK_DB_UPDATE_CAC_CARD, "CAC-managed card-based access"), 18 ) 19 20 class 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 13 32 class Space(models.Model): 14 33 number = models.CharField(max_length=20, unique=True, ) 15 34 asa_owned = models.BooleanField(default=True, ) 35 lock_type = models.ForeignKey(LockType) 16 36 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.") 17 37 notes = models.TextField(blank=True, ) -
asadb/space/views.py
rde2f0ac rf6982d4 90 90 'allow_edit': allow_edit, 91 91 'extras_indices': extras_indices, 92 'pagename':'group ',92 'pagename':'groups', 93 93 } 94 94 return render_to_response('space/manage-access.html', context, context_instance=RequestContext(request), ) … … 112 112 'locker_num', 113 113 'group__name', 114 ).select_related('space', ' group')114 ).select_related('space', 'space__lock_type', 'group') 115 115 office_assignments = assignments.filter(locker_num='') 116 116 … … 127 127 'offices': office_assignments, 128 128 'lockers': locker_rooms, 129 'pagename':'group ',129 'pagename':'groups', 130 130 } 131 131 return render_to_response('space/summary.html', context, context_instance=RequestContext(request), ) 132 133 def 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 58 58 </ul></li> 59 59 <li><a href='{% url space-summary %}'>Space assignments</a> 60 <ul> 61 <li><a href='{% url space-lock-type %}'>Lock Types</a></li> 60 62 {% if perms.groups.view_group_private_info %} 61 <ul>62 63 <li><a href='{% url space-dump-locker-access %}'>Locker access (CSV)</a></li> 63 64 <li><a href='{% url space-dump-office-access %}'>Office access (CSV)</a></li> 65 {% endif %} 64 66 </ul> 65 {% endif %}66 67 </li> 67 68 <li><a href='{% url about %}'>About the ASA Database</a><ul> -
asadb/template/space/group-change-email.txt
rd768e47 r72a3d90 1 1 {% 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 3 Thank 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 5 We believe you made the following changes: 3 6 4 7 {% if office_msg %} -
asadb/template/space/manage-access.html
r78de8cb r1927d79 1 1 {% extends "base.html" %} 2 2 3 {% block title %}{{group.name}}: Office Access{% endblock %}3 {% block title %}{{group.name}}: Space Access{% endblock %} 4 4 {% block content %} 5 5 6 <h1>{{group.name}}: Office Access</h1>6 <h1>{{group.name}}: Space Access</h1> 7 7 8 8 {% include "groups/group_tools.part.html" %} … … 48 48 <th>{{assignment.space}}</th> 49 49 <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 50 64 <table class='pretty-table'> 51 65 <tr> … … 67 81 </tr>{% endfor %} 68 82 </table> 83 84 {% endif %} 85 {% endwith %} 86 69 87 </td> 70 88 </tr> -
asadb/template/space/summary.html
rde2f0ac rf6982d4 27 27 <th>Room</th> 28 28 <th>Group</th> 29 <th><a href='{% url space-lock-type %}'>Lock Type</a></th> 29 30 <th>Access</th> 30 31 </tr> … … 33 34 <td>{{office.space.number}}</td> 34 35 <td><a href='{% url groups:group-detail office.group.pk %}'>{{office.group}}</a></td> 36 <td>{{office.space.lock_type.name}}</td> 35 37 <td><a href='{% url groups:group-space-access office.group.pk %}'>Access</a></td> 36 38 </tr> -
asadb/urls.py
r870992c r3c1b20b 86 86 url(r'^space/dump/office-access.csv$', space.views.dump_office_access, name='space-dump-office-access', ), 87 87 url(r'^space/$', space.views.summary, name='space-summary', ), 88 url(r'^space/lock_types.html$', space.views.lock_types, name='space-lock-type', ), 88 89 89 90 # Uncomment the admin/doc line below and add 'django.contrib.admindocs' -
asadb/util/diff_static_data.sh
raab0dc8 r3c1b20b 12 12 ../../manage.py dumpdata --format=xml --indent=4 groups.ActivityCategory > groups_initial_data.xml 13 13 ../../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 15 git add {groups,forms}_initial_data.xml space_lock_types.xml 15 16 16 17 echo -
asadb/groups/views.py
r8ccd88f r242566d 630 630 self.fields['constitution_url'].required = True 631 631 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 632 633 self.fields['athena_locker'].required = True 633 634 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.)" … … 849 850 group_startup.save() 850 851 851 group.group_status = groups.models.GroupStatus.objects.get(slug=' active')852 group.group_status = groups.models.GroupStatus.objects.get(slug='suspended') 852 853 group.constitution_url = "" 853 854 group.recognition_date = datetime.datetime.now() 854 855 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() 855 864 856 865 group.save() -
asadb/template/groups/account_lookup.html
rcfde3dc r9469a73 41 41 </tr> 42 42 </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&func_name=CAN+SPEND+OR+COMMIT+FUNDS&qual_code=F{{account_number}}&skip_root=Y'>Roles</a>.</p> 43 47 {% endif %} 44 48 -
asadb/template/groups/diffs/new-group-announce.txt
r798ec5b rf38b6d0 5 5 to the MIT community! 6 6 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: 7 Your group is currently *suspended*. The last step to finalize the group 8 recognition is for you to finish entering the group's complete information into 9 the ASA Database: 9 10 10 11 http://web.mit.edu/asa/www/asa-db.shtml … … 29 30 can modify the information and that MIT personal certificates are 30 31 required to access the group's account in the ASA Database. 32 33 Once you have completed these steps, you must *notify asa-groups@mit.edu* to 34 become an active group. 31 35 32 36 *** Please keep this e-mail for further reference. ***
Note: See TracChangeset
for help on using the changeset viewer.