Changeset 0bd161f
- Timestamp:
- Aug 14, 2011, 8:28:33 PM (14 years ago)
- Branches:
- master, space-access, stable, stage, test-hooks
- Children:
- 33b19c3
- Parents:
- aa6a940
- git-author:
- Alex Dehnert <adehnert@…> (08/14/11 19:42:20)
- git-committer:
- Alex Dehnert <adehnert@…> (08/14/11 20:28:33)
- Location:
- asadb
- Files:
-
- 3 added
- 4 edited
-
groups/admin.py (modified) (2 diffs)
-
groups/migrations/0009_add_notes.py (added)
-
groups/models.py (modified) (2 diffs)
-
groups/views.py (modified) (1 diff)
-
template/groups/group_detail.html (modified) (1 diff)
-
template/groups/note/detail.head.html (added)
-
template/groups/note/detail.row.html (added)
Legend:
- Unmodified
- Added
- Removed
-
asadb/groups/admin.py
rb713ac7 r0bd161f 25 25 date_hierarchy = 'update_date' 26 26 search_fields = [ 'id', 'name', 'abbreviation', 'officer_email', 'athena_locker', ] 27 28 class Admin_GroupNote(VersionAdmin): 29 list_display = ( 30 'pk', 31 'author', 32 'timestamp', 33 'acl_read_group', 34 'acl_read_offices', 35 'group', 36 ) 37 list_display_links = ('pk', 'timestamp', ) 38 list_filter = [ 39 'acl_read_group', 40 'acl_read_offices', 41 ] 42 date_hierarchy = 'timestamp' 43 search_fields = [ 44 'author', 45 'group__name', 46 'group__abbreviation', 47 'group__officer_email', 48 'group__athena_locker', 49 ] 27 50 28 51 class OfficerRoleAdmin(VersionAdmin): … … 129 152 130 153 admin.site.register(groups.models.Group, GroupAdmin) 154 admin.site.register(groups.models.GroupNote, Admin_GroupNote) 131 155 admin.site.register(groups.models.OfficerRole, OfficerRoleAdmin) 132 156 admin.site.register(groups.models.OfficeHolder, OfficeHolderAdmin) -
asadb/groups/models.py
raa6a940 r0bd161f 50 50 super(Group, self).save() 51 51 52 def viewable_notes(self, user): 53 return GroupNote.viewable_notes(self, user) 54 52 55 def officers(self, role=None, person=None, as_of="now",): 53 56 """Get the set of people holding some office. … … 83 86 ('admin_group', 'Administer basic group information'), 84 87 ('view_signatories', 'View signatory information for all groups'), 88 ) 89 90 91 class GroupNote(models.Model): 92 author = models.CharField(max_length=30, ) # match Django username field 93 timestamp = models.DateTimeField(default=datetime.datetime.now, editable=False, ) 94 body = models.TextField() 95 acl_read_group = models.BooleanField(default=True, help_text='Can the group read this note') 96 acl_read_offices = models.BooleanField(default=True, help_text='Can "offices" that interact with groups (SAO, CAC, and funding boards) read this note') 97 group = models.ForeignKey(Group) 98 99 def __str__(self, ): 100 return "Note by %s on %s" % (self.author, self.timestamp, ) 101 102 @classmethod 103 def viewable_notes(cls, group, user): 104 notes = cls.objects.filter(group=group) 105 if not user.has_perm('groups.view_note_all'): 106 q = models.Q(pk=0) 107 if user.has_perm('groups.view_note_group', group): 108 q |= models.Q(acl_read_group=True) 109 if user.has_perm('groups.view_note_office'): 110 q |= models.Q(acl_read_offices=True) 111 notes = notes.filter(q) 112 return notes 113 114 class Meta: 115 permissions = ( 116 ('view_note_group', 'View notes intended for the group to see', ), 117 ('view_note_office', 'View notes intended for "offices" to see', ), 118 ('view_note_all', 'View all notes', ), 85 119 ) 86 120 -
asadb/groups/views.py
raa6a940 r0bd161f 184 184 context['viewpriv'] = self.request.user.has_perm('groups.view_group_private_info', group) 185 185 context['adminpriv'] = self.request.user.has_perm('groups.admin_group', group) 186 context['notes'] = group.viewable_notes(self.request.user) 187 186 188 return context 187 189 -
asadb/template/groups/group_detail.html
raa6a940 r0bd161f 71 71 </table> 72 72 73 <h2>Notes</h2> 74 75 {% if notes %} 76 <table class='pretty-table'> 77 <thead> 78 {% include "groups/note/detail.head.html" %} 79 </thead> 80 <tbody> 81 {% for note in notes %} 82 {% include "groups/note/detail.row.html" %} 83 {% endfor %} 84 </tbody> 85 </table> 86 {% else %} 87 <p>No notes are visible to you at this time.</p> 88 {% endif %} 89 90 {% if perms.groups.add_groupnote %} 91 <p><a href='{% url admin:groups_groupnote_add %}'>Add note</a></p> 92 {% endif %} 93 73 94 {% endblock %} 74 95
Note: See TracChangeset
for help on using the changeset viewer.