Commits

Flavio Curella committed 6f0b9aa Merge

Merge

Comments (0)

Files changed (2)

                            views.profile_detail,
                            name='profiles_profile_detail'),
                        url(r'^$',
-                           views.profile_list,
+                           views.ProfileListView.as_view(),
                            name='profiles_profile_list'),
                        )
 from django.shortcuts import get_object_or_404
 from django.shortcuts import render_to_response
 from django.template import RequestContext
-from django.views.generic.list_detail import object_list
+from django.views.generic.list import ListView
 
 from profiles import utils
 
                               { 'profile': profile_obj },
                               context_instance=context)
 
-def profile_list(request, public_profile_field=None,
-                 template_name='profiles/profile_list.html', **kwargs):
+
+class ProfileListView(ListView):
     """
     A list of user profiles.
-    
+
     If no profile model has been specified in the
     ``AUTH_PROFILE_MODULE`` setting,
     ``django.contrib.auth.models.SiteProfileNotAvailable`` will be
         profile will be excluded from the list. Use this feature to
         allow users to mark their profiles as not being publicly
         viewable.
-        
+
         If this argument is not specified, it will be assumed that all
         users' profiles are publicly viewable.
-    
+
     ``template_name``
         The name of the template to use for displaying the profiles. If
         not specified, this will default to
     exception: ``queryset`` will always be the ``QuerySet`` of the
     model specified by the ``AUTH_PROFILE_MODULE`` setting, optionally
     filtered to remove non-publicly-viewable proiles.
-    
+
     **Context:**
-    
+
     Same as the :view:`django.views.generic.list_detail.object_list`
     generic view.
-    
+
     **Template:**
-    
+
     ``template_name`` keyword argument or
     :template:`profiles/profile_list.html`.
-    
+
     """
-    profile_model = utils.get_profile_model()
-    queryset = profile_model._default_manager.all()
-    if public_profile_field is not None:
-        queryset = queryset.filter(**{ public_profile_field: True })
-    kwargs['queryset'] = queryset
-    return object_list(request, template_name=template_name, **kwargs)
+
+    public_profile_field = None
+    template_name = 'profiles/profile_list.html'
+
+    def get_model(self):
+        return utils.get_profile_model()
+
+    def get_queryset(self):
+        queryset = self.get_model()._default_manager.all()
+        if self.public_profile_field is not None:
+            queryset = queryset.filter(**{self.public_profile_field: True})
+        return queryset