app/soc/views/user/roles.py
author Todd Larsen <tlarsen@google.com>
Thu, 02 Oct 2008 20:22:15 +0000
changeset 262 52a42831d9d6
parent 99 8c38b546a3cf
child 298 c76a366c7ab4
permissions -rw-r--r--
Factor out an isIdAvailable() function from EditForm.clean_id() in soc/views/site/user/profile.py and add it to soc/logic/site/id_user.py. Addresses some comments on r614. Patch by: Todd Larsen Review by: Pawel Solyga Review URL: http://codereviews.googleopensourceprograms.com/1202
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
82
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     2
#
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     4
#
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     8
#
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    10
#
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    15
# limitations under the License.
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    16
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    17
"""Views of a User's various Roles on the site.
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    18
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    19
dashboard:  dashboard view of all of a User's Roles on the site
84
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    20
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    21
public:  a public view of the User's Roles on the site
82
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    22
"""
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    23
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    24
__authors__ = [
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    25
  '"Todd Larsen" <tlarsen@google.com>',
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    26
  ]
1456e633bf8a Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    27
84
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    28
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    29
from google.appengine.api import users
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    30
from django import http
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    31
from soc.views.helpers import response_helpers
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    32
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    33
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    34
def dashboard(request, linkname=None,
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    35
              template='soc/user/roles/dashboard.html'):
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    36
  """A per-User dashboard of that User's Roles on the site.
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    37
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    38
  Args:
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    39
    request: the standard django request object.
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    40
    linkname: the User's site-unique "linkname" extracted from the URL
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    41
    template: the template path to use for rendering the template.
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    42
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    43
  Returns:
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    44
    A subclass of django.http.HttpResponse with generated template.
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    45
  """
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    46
  #TODO(tlarsen): this module is currently a placeholder for future work
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    47
  
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    48
  # TODO: check that user is logged in and "owns" the linkname;
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    49
  #   if not, call public() view instead
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    50
  #   This might be tricky, since we want to use the same style
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    51
  #   of template that was passed to us, but how do we figure out
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    52
  #   what the equivalent public.html template is?  Perhaps this
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    53
  #   view needs to require that, for a foo/bar/dashboard.html
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    54
  #   template, a corresponding foo/bar/public.html template must
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    55
  #   also exist...
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    56
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    57
  return response_helpers.respond(request,
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    58
      template, {'template': template})
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    59
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    60
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    61
def public(request, linkname=None,
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    62
           template='soc/user/roles/public.html'):
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    63
  """A "general public" view of a User's Roles on the site.
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    64
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    65
  Args:
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    66
    request: the standard django request object.
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    67
    linkname: the User's site-unique "linkname" extracted from the URL
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    68
    template: the template path to use for rendering the template.
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    69
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    70
  Returns:
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    71
    A subclass of django.http.HttpResponse with generated template.
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    72
  """
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    73
  #TODO(tlarsen): this module is currently a placeholder for future work
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    74
  
99
8c38b546a3cf Added public view support (not using controller yet)
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 84
diff changeset
    75
  # TODO: if linkname is empty or not a valid linkname on the site, display
84
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    76
  # some sort of "user does not exist" page (a custom 404 page, maybe?).
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    77
  
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    78
  return response_helpers.respond(request,
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    79
      template, {'template': template})
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    80