app/soc/views/user/roles.py
author Pawel Solyga <Pawel.Solyga@gmail.com>
Sun, 16 Nov 2008 15:26:40 +0000
changeset 485 2865922ea06a
parent 482 839740b061ad
child 499 d22e4fe8e64b
permissions -rw-r--r--
Change id to account in base.html template (without this change we couldn't signout using top right links and also couldn't display currently logged in account information on the left side of links). This patch is related to commit in revision r1022. http://code.google.com/p/soc/source/detail?r=1022 Patch by: Pawel Solyga

#!/usr/bin/python2.5
#
# Copyright 2008 the Melange authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Views of a User's various Roles on the site.

dashboard:  dashboard view of all of a User's Roles on the site

public:  a public view of the User's Roles on the site
"""

__authors__ = [
  '"Todd Larsen" <tlarsen@google.com>',
  ]


from soc.views.helper import decorators
from soc.views.helper import responses


@decorators.view
def dashboard(request, page_name=None, link_name=None,
              template='soc/user/roles/dashboard.html'):
  """A per-User dashboard of that User's Roles on the site.

  Args:
    request: the standard django request object.
    page: a soc.logic.site.page.Page object which is abstraction that combines 
      a Django view with sidebar menu info
    link_name: the User's site-unique "link_name" extracted from the URL
    template: the template path to use for rendering the template.

  Returns:
    A subclass of django.http.HttpResponse with generated template.
  """
  #TODO(tlarsen): this module is currently a placeholder for future work
  
  # TODO: check that user is logged in and "owns" the link_name;
  #   if not, call public() view instead
  #   This might be tricky, since we want to use the same style
  #   of template that was passed to us, but how do we figure out
  #   what the equivalent public.html template is?  Perhaps this
  #   view needs to require that, for a foo/bar/dashboard.html
  #   template, a corresponding foo/bar/public.html template must
  #   also exist...

  return responses.respond(request,
      template, {'template': template})


@decorators.view
def public(request, page_name=None, link_name=None,
           template='soc/user/roles/public.html'):
  """A "general public" view of a User's Roles on the site.

  Args:
    request: the standard django request object.
    page: a soc.logic.site.page.Page object which is abstraction that combines 
      a Django view with sidebar menu info
    link_name: the User's site-unique "link_name" extracted from the URL
    template: the template path to use for rendering the template.

  Returns:
    A subclass of django.http.HttpResponse with generated template.
  """
  #TODO(tlarsen): this module is currently a placeholder for future work
  
  # TODO: if link_name is empty or not a valid link_name on the site, display
  # some sort of "user does not exist" page (a custom 404 page, maybe?).
  
  return responses.respond(request,
      template, {'template': template})