app/soc/views/user/roles.py
author Todd Larsen <tlarsen@google.com>
Thu, 20 Nov 2008 18:50:30 +0000
changeset 512 aae25d2b4464
parent 500 44ea4620c5c0
permissions -rw-r--r--
Rename link_name to link_id everywhere, regardless of case (so LINK_NAME becomes LINK_ID, "link name" becomes "link id", etc.). Also, rename LINKNAME to LINK_ID. Patch by: Todd Larsen
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
365
74dec172944e Create decorators module in view/helper and add view decorator that catches exceptions like DeadlineExceededError, MemoryError, AssertionError (this code is being moved from respond function). Add view decorator to all view functions. In addition remove not needed imports from all affected files and fix too long lines.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 358
diff changeset
    29
from soc.views.helper import decorators
74dec172944e Create decorators module in view/helper and add view decorator that catches exceptions like DeadlineExceededError, MemoryError, AssertionError (this code is being moved from respond function). Add view decorator to all view functions. In addition remove not needed imports from all affected files and fix too long lines.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 358
diff changeset
    30
from soc.views.helper import responses
84
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    31
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    32
365
74dec172944e Create decorators module in view/helper and add view decorator that catches exceptions like DeadlineExceededError, MemoryError, AssertionError (this code is being moved from respond function). Add view decorator to all view functions. In addition remove not needed imports from all affected files and fix too long lines.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 358
diff changeset
    33
@decorators.view
512
aae25d2b4464 Rename link_name to link_id everywhere, regardless of case (so LINK_NAME
Todd Larsen <tlarsen@google.com>
parents: 500
diff changeset
    34
def dashboard(request, page_name=None, link_id=None,
84
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:
499
d22e4fe8e64b Fix missing dots in doc strings and some other doc string corrections.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 482
diff changeset
    39
    request: the standard django request object
500
44ea4620c5c0 Replace old page parameter doc string description with new one for page_name.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 499
diff changeset
    40
    page_name: the page name displayed in templates as page and header title
512
aae25d2b4464 Rename link_name to link_id everywhere, regardless of case (so LINK_NAME
Todd Larsen <tlarsen@google.com>
parents: 500
diff changeset
    41
    link_id: the User's site-unique "link_id" extracted from the URL
499
d22e4fe8e64b Fix missing dots in doc strings and some other doc string corrections.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 482
diff changeset
    42
    template: the template path to use for rendering the template
84
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    43
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    44
  Returns:
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    45
    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
    46
  """
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    47
  #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
    48
  
512
aae25d2b4464 Rename link_name to link_id everywhere, regardless of case (so LINK_NAME
Todd Larsen <tlarsen@google.com>
parents: 500
diff changeset
    49
  # TODO: check that user is logged in and "owns" the link_id;
84
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    50
  #   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
    51
  #   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
    52
  #   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
    53
  #   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
    54
  #   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
    55
  #   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
    56
  #   also exist...
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    57
365
74dec172944e Create decorators module in view/helper and add view decorator that catches exceptions like DeadlineExceededError, MemoryError, AssertionError (this code is being moved from respond function). Add view decorator to all view functions. In addition remove not needed imports from all affected files and fix too long lines.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 358
diff changeset
    58
  return responses.respond(request,
84
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    59
      template, {'template': template})
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
365
74dec172944e Create decorators module in view/helper and add view decorator that catches exceptions like DeadlineExceededError, MemoryError, AssertionError (this code is being moved from respond function). Add view decorator to all view functions. In addition remove not needed imports from all affected files and fix too long lines.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 358
diff changeset
    62
@decorators.view
512
aae25d2b4464 Rename link_name to link_id everywhere, regardless of case (so LINK_NAME
Todd Larsen <tlarsen@google.com>
parents: 500
diff changeset
    63
def public(request, page_name=None, link_id=None,
84
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    64
           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
    65
  """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
    66
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    67
  Args:
499
d22e4fe8e64b Fix missing dots in doc strings and some other doc string corrections.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 482
diff changeset
    68
    request: the standard django request object
500
44ea4620c5c0 Replace old page parameter doc string description with new one for page_name.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 499
diff changeset
    69
    page_name: the page name displayed in templates as page and header title
512
aae25d2b4464 Rename link_name to link_id everywhere, regardless of case (so LINK_NAME
Todd Larsen <tlarsen@google.com>
parents: 500
diff changeset
    70
    link_id: the User's site-unique "link_id" extracted from the URL
499
d22e4fe8e64b Fix missing dots in doc strings and some other doc string corrections.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 482
diff changeset
    71
    template: the template path to use for rendering the template
84
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
  Returns:
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    74
    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
    75
  """
1b31d238ba39 Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents: 82
diff changeset
    76
  #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
    77
  
512
aae25d2b4464 Rename link_name to link_id everywhere, regardless of case (so LINK_NAME
Todd Larsen <tlarsen@google.com>
parents: 500
diff changeset
    78
  # TODO: if link_id is empty or not a valid link_id 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
    79
  # 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
    80
  
365
74dec172944e Create decorators module in view/helper and add view decorator that catches exceptions like DeadlineExceededError, MemoryError, AssertionError (this code is being moved from respond function). Add view decorator to all view functions. In addition remove not needed imports from all affected files and fix too long lines.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 358
diff changeset
    81
  return responses.respond(request,
74dec172944e Create decorators module in view/helper and add view decorator that catches exceptions like DeadlineExceededError, MemoryError, AssertionError (this code is being moved from respond function). Add view decorator to all view functions. In addition remove not needed imports from all affected files and fix too long lines.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 358
diff changeset
    82
      template, {'template': template})