Flesh out the user/roles placeholders a little bit more.
authorTodd Larsen <tlarsen@google.com>
Tue, 19 Aug 2008 23:51:31 +0000
changeset 84 1b31d238ba39
parent 83 3f4f7c540b75
child 85 426b4ca2a72a
Flesh out the user/roles placeholders a little bit more.
app/soc/templates/soc/user/roles/dashboard.html
app/soc/templates/soc/user/roles/public.html
app/soc/views/user/__init__.py
app/soc/views/user/roles.py
app/urls.py
--- a/app/soc/templates/soc/user/roles/dashboard.html	Tue Aug 19 23:13:24 2008 +0000
+++ b/app/soc/templates/soc/user/roles/dashboard.html	Tue Aug 19 23:51:31 2008 +0000
@@ -13,6 +13,6 @@
 limitations under the License.
 {% endcomment %}
 
-{% comment %}
-TODO(tlarsen): this template is currently a placeholder for future work
-{% endcomment %}
+{% block body %}
+    <div class="todo">TODO(tlarsen): this template is currently a placeholder for future work</div>
+{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/user/roles/public.html	Tue Aug 19 23:51:31 2008 +0000
@@ -0,0 +1,19 @@
+{% extends "soc/base.html" %}
+{% comment %}
+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.
+{% endcomment %}
+
+{% block body %}
+    <div class="todo">TODO(tlarsen): this template is currently a placeholder for future work</div>
+{% endblock %}
+
--- a/app/soc/views/user/roles.py	Tue Aug 19 23:13:24 2008 +0000
+++ b/app/soc/views/user/roles.py	Tue Aug 19 23:51:31 2008 +0000
@@ -17,10 +17,64 @@
 """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>',
   ]
 
-#TODO(tlarsen): this module is currently a placeholder for future work
+
+from google.appengine.api import users
+from django import http
+from soc.views.helpers import response_helpers
+
+
+def dashboard(request, linkname=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.
+    linkname: the User's site-unique "linkname" 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 linkname;
+  #   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 response_helpers.respond(request,
+      template, {'template': template})
+
+
+def public(request, linkname=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.
+    linkname: the User's site-unique "linkname" 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 linkname is empty or not a vaild linkname on the site, display
+  # some sort of "user does not exist" page (a custom 404 page, maybe?).
+  
+  return response_helpers.respond(request,
+      template, {'template': template})
+
--- a/app/urls.py	Tue Aug 19 23:13:24 2008 +0000
+++ b/app/urls.py	Tue Aug 19 23:51:31 2008 +0000
@@ -24,8 +24,16 @@
 urlpatterns = patterns(
     '',
     (r'^$', 'soc.views.site.home.public'),
+
+    # attempt to send User to their dashboard
+    # (will display soc.views.user.roles.public() if "linkname" is not
+    # current logged-in User)    
+    (r'^user/roles/(?P<linkname>[_0-9a-z]+)$',
+     'soc.views.user.roles.dashboard'),
+
     (r'^user/profile$','soc.views.user.profile'),
     (r'^user/profile/(?P<linkname>[_0-9a-z]+)$','soc.views.user.profile'),
+
     (r'^org/profile/(?P<program>ghop[_0-9a-z]+)/(?P<linkname>[_0-9a-z]+)/$',
      'soc.views.person.profile.edit',
      {'template': 'ghop/person/profile/edit.html'}),