Commits

stringfellow  committed 6265390 Draft

whitespace tidyup

  • Participants
  • Parent commits c219625

Comments (0)

Files changed (1)

File profiles/views.py

     """
     Create a profile for the current user, if one doesn't already
     exist.
-    
+
     If the user already has a profile, as determined by
     ``request.user.get_profile()``, a redirect will be issued to the
     :view:`profiles.views.edit_profile` view. If no profile model has
     been specified in the ``AUTH_PROFILE_MODULE`` setting,
     ``django.contrib.auth.models.SiteProfileNotAvailable`` will be
     raised.
-    
+
     **Optional arguments:**
-    
+
     ``extra_context``
         A dictionary of variables to add to the template context. Any
         callable object in this dictionary will be called to produce
         established by ``ModelForm`` of using a method named
         ``save_m2m()`` will be used, and so your form class should
         also define this method.
-        
+
         If this argument is not supplied, this view will use a
         ``ModelForm`` automatically generated from the model specified
         by ``AUTH_PROFILE_MODULE``.
-    
+
     ``success_url``
         The URL to redirect to after successful profile creation. If
         this argument is not supplied, this will default to the URL of
         :view:`profiles.views.profile_detail` for the newly-created
         profile object.
-    
+
     ``template_name``
         The template to use when displaying the profile-creation
         form. If not supplied, this will default to
         :template:`profiles/create_profile.html`.
-    
+
     **Context:**
-    
+
     ``form``
         The profile-creation form.
-    
+
     **Template:**
-    
+
     ``template_name`` keyword argument, or
     :template:`profiles/create_profile.html`.
-    
+
     """
     try:
         profile_obj = request.user.get_profile()
         return HttpResponseRedirect(reverse('profiles_edit_profile'))
     except ObjectDoesNotExist:
         pass
-    
+
     #
     # We set up success_url here, rather than as the default value for
     # the argument. Trying to do it as the argument's default would
     # perform the reverse lookup we need access to profiles/urls.py,
     # but profiles/urls.py in turn imports this module.
     #
-    
+
     if success_url is None:
         success_url = reverse('profiles_profile_detail',
                               kwargs={ 'username': request.user.username })
             return HttpResponseRedirect(success_url)
     else:
         form = form_class()
-    
+
     if extra_context is None:
         extra_context = {}
     context = RequestContext(request)
     for key, value in extra_context.items():
         context[key] = callable(value) and value() or value
-    
+
     return render_to_response(template_name,
                               { 'form': form },
                               context_instance=context)
                  extra_context=None):
     """
     Edit the current user's profile.
-    
+
     If the user does not already have a profile (as determined by
     ``User.get_profile()``), a redirect will be issued to the
     :view:`profiles.views.create_profile` view; if no profile model
     has been specified in the ``AUTH_PROFILE_MODULE`` setting,
     ``django.contrib.auth.models.SiteProfileNotAvailable`` will be
     raised.
-    
+
     **Optional arguments:**
-    
+
     ``extra_context``
         A dictionary of variables to add to the template context. Any
         callable object in this dictionary will be called to produce
         argument is not specified, this view will use a ``ModelForm``
         generated from the model specified in the
         ``AUTH_PROFILE_MODULE`` setting.
-    
+
     ``success_url``
         The URL to redirect to following a successful edit. If not
         specified, this will default to the URL of
         :view:`profiles.views.profile_detail` for the profile object
         being edited.
-    
+
     ``template_name``
         The template to use when displaying the profile-editing
         form. If not specified, this will default to
         :template:`profiles/edit_profile.html`.
-    
+
     **Context:**
-    
+
     ``form``
         The form for editing the profile.
-        
+
     ``profile``
          The user's current profile.
-    
+
     **Template:**
-    
+
     ``template_name`` keyword argument or
     :template:`profiles/edit_profile.html`.
-    
+
     """
     try:
         profile_obj = request.user.get_profile()
     except ObjectDoesNotExist:
         return HttpResponseRedirect(reverse('profiles_create_profile'))
-    
+
     #
     # See the comment in create_profile() for discussion of why
     # success_url is set up here, rather than as a default value for
     # the argument.
     #
-    
+
     if success_url is None:
         success_url = reverse('profiles_profile_detail',
                               kwargs={ 'username': request.user.username })
             return HttpResponseRedirect(success_url)
     else:
         form = form_class(instance=profile_obj)
-    
+
     if extra_context is None:
         extra_context = {}
     context = RequestContext(request)
     for key, value in extra_context.items():
         context[key] = callable(value) and value() or value
-    
+
     return render_to_response(template_name,
                               { 'form': form,
                                 'profile': profile_obj, },
                    extra_context=None):
     """
     Detail view of a user's profile.
-    
+
     If no profile model has been specified in the
     ``AUTH_PROFILE_MODULE`` setting,
     ``django.contrib.auth.models.SiteProfileNotAvailable`` will be
     raised.
-    
+
     If the user has not yet created a profile, ``Http404`` will be
     raised.
-    
+
     **Required arguments:**
-    
+
     ``username``
         The username of the user whose profile is being displayed.
-    
+
     **Optional arguments:**
 
     ``extra_context``
         ``profile`` variable in the template will be ``None``. 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 profile. If
         not specified, this will default to
         :template:`profiles/profile_detail.html`.
-    
+
     **Context:**
-    
+
     ``profile``
         The user's profile, or ``None`` if the user's profile is not
         publicly viewable (see the description of
         ``public_profile_field`` above).
-    
+
     **Template:**
-    
+
     ``template_name`` keyword argument or
     :template:`profiles/profile_detail.html`.
-    
+
     """
     user = get_object_or_404(User, username=username)
     try:
     if public_profile_field is not None and \
        not getattr(profile_obj, public_profile_field):
         profile_obj = None
-    
+
     if extra_context is None:
         extra_context = {}
     context = RequestContext(request)
     for key, value in extra_context.items():
         context[key] = callable(value) and value() or value
-    
+
     return render_to_response(template_name,
                               { 'profile': profile_obj },
                               context_instance=context)
                  template_name='profiles/profile_list.html', **kwargs):
     """
     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()