Changeset 1de230f
- Timestamp:
- Aug 24, 2011, 2:42:50 AM (15 years ago)
- Branches:
- master, space-access, stable, stage, test-hooks
- Children:
- 7b57a9b
- Parents:
- 3107c52
- git-author:
- Alex Dehnert <adehnert@…> (08/24/11 02:42:35)
- git-committer:
- Alex Dehnert <adehnert@…> (08/24/11 02:42:50)
- Location:
- asadb
- Files:
-
- 4 edited
-
groups/views.py (modified) (2 diffs)
-
settings.py (modified) (2 diffs)
-
template/groups/group_list.html (modified) (1 diff)
-
urls.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
asadb/groups/views.py
r3107c52 r1de230f 24 24 import form_utils.forms 25 25 import reversion.models 26 import django_filters 26 27 27 28 from util.db_form_utils import StaticWidget … … 170 171 } 171 172 return render_to_response('groups/group_change_main.html', context, context_instance=RequestContext(request), ) 173 174 175 class GroupFilter(django_filters.FilterSet): 176 name = django_filters.CharFilter(lookup_type='icontains', label="Name contains") 177 abbreviation = django_filters.CharFilter(lookup_type='iexact', label="Abbreviation is") 178 179 class Meta: 180 model = groups.models.Group 181 fields = [ 182 'name', 183 'abbreviation', 184 'activity_category', 185 'group_class', 186 'group_status', 187 'group_funding', 188 ] 189 190 191 class GroupListView(ListView): 192 model = groups.models.Group 193 template_object_name = 'group' 194 195 def get(self, *args, **kwargs): 196 qs = super(GroupListView, self).get_queryset() 197 self.filterset = GroupFilter(self.request.GET, qs) 198 return super(GroupListView, self).get(*args, **kwargs) 199 200 def get_queryset(self, ): 201 qs = self.filterset.qs 202 return qs 203 204 def get_context_data(self, **kwargs): 205 context = super(GroupListView, self).get_context_data(**kwargs) 206 # Add in the publisher 207 context['pagename'] = 'groups' 208 context['filter'] = self.filterset 209 return context 172 210 173 211 -
asadb/settings.py
rf07e84b r1de230f 5 5 SITE_ROOT = os.path.normpath(os.path.dirname(__file__)) 6 6 SITE_WEB_PATH = '' 7 8 7 9 8 DEBUG = False … … 105 104 'django.contrib.sites', 106 105 'form_utils', 106 'django_filters', 107 107 'reversion', 108 108 'south', -
asadb/template/groups/group_list.html
r94c79bd r1de230f 5 5 6 6 <h1>MIT Student Groups</h1> 7 8 <h2>Search</h2> 9 10 <form action="" method="get"> 11 <table class='pretty-table'> 12 {{ filter.form.as_table }} 13 </table> 14 <input type="submit" value="Search" /> 15 </form> 16 17 <h2>The Groups</h2> 7 18 8 19 <table class='pretty-table'> -
asadb/urls.py
r9879d18 r1de230f 36 36 37 37 # Group list 38 url( 39 r'^groups/$', 40 list_detail.object_list, 41 { 42 'queryset': groups.models.Group.objects.all(), 43 'template_object_name': 'group', 44 'extra_context': {'pagename': 'groups', }, 45 }, 46 name='group-list', 47 ), 38 url(r'^groups/$', groups.views.GroupListView.as_view(), name='group-list', ), 48 39 url(r'^group/(?P<pk>\d+)/$', groups.views.GroupDetailView.as_view(), name='group-detail', ), 49 40 url(r'^groups/recent_changes/$', groups.views.GroupHistoryView.as_view(), name='groups-manage-history', ),
Note: See TracChangeset
for help on using the changeset viewer.