app/soc/views/site/user/profile.py
changeset 358 843d83b87282
parent 355 9b3f26057f74
child 361 465e4df617de
equal deleted inserted replaced
357:9bd78a5073c2 358:843d83b87282
    92       raise forms.ValidationError('Account not found.')
    92       raise forms.ValidationError('Account not found.')
    93     
    93     
    94 
    94 
    95 DEF_SITE_USER_PROFILE_LOOKUP_TMPL = 'soc/site/user/profile/lookup.html'
    95 DEF_SITE_USER_PROFILE_LOOKUP_TMPL = 'soc/site/user/profile/lookup.html'
    96 
    96 
    97 def lookup(request, template=DEF_SITE_USER_PROFILE_LOOKUP_TMPL):
    97 def lookup(request, page=None, template=DEF_SITE_USER_PROFILE_LOOKUP_TMPL):
    98   """View for a Developer to look up a User Model entity.
    98   """View for a Developer to look up a User Model entity.
    99 
    99 
   100   Args:
   100   Args:
   101     request: the standard django request object
   101     request: the standard django request object
       
   102     page: a soc.logic.site.page.Page object which is abstraction that combines 
       
   103       a Django view with sidebar menu info
   102     template: the "sibling" template (or a search list of such templates)
   104     template: the "sibling" template (or a search list of such templates)
   103       from which to construct the public.html template name (or names)
   105       from which to construct the public.html template name (or names)
   104 
   106 
   105   Returns:
   107   Returns:
   106     A subclass of django.http.HttpResponse which either contains the form to
   108     A subclass of django.http.HttpResponse which either contains the form to
   246 DEF_SITE_USER_PROFILE_EDIT_TMPL = 'soc/site/user/profile/edit.html'
   248 DEF_SITE_USER_PROFILE_EDIT_TMPL = 'soc/site/user/profile/edit.html'
   247 DEF_CREATE_NEW_USER_MSG = ' You can create a new user by visiting' \
   249 DEF_CREATE_NEW_USER_MSG = ' You can create a new user by visiting' \
   248                           ' <a href="/site/user/profile">Create ' \
   250                           ' <a href="/site/user/profile">Create ' \
   249                           'a New User</a> page.'
   251                           'a New User</a> page.'
   250 
   252 
   251 def edit(request, link_name=None, template=DEF_SITE_USER_PROFILE_EDIT_TMPL):
   253 def edit(request, page=None, link_name=None, template=DEF_SITE_USER_PROFILE_EDIT_TMPL):
   252   """View for a Developer to modify the properties of a User Model entity.
   254   """View for a Developer to modify the properties of a User Model entity.
   253 
   255 
   254   Args:
   256   Args:
   255     request: the standard django request object
   257     request: the standard django request object
       
   258     page: a soc.logic.site.page.Page object which is abstraction that combines 
       
   259       a Django view with sidebar menu info
   256     link_name: the User's site-unique "link_name" extracted from the URL
   260     link_name: the User's site-unique "link_name" extracted from the URL
   257     template: the "sibling" template (or a search list of such templates)
   261     template: the "sibling" template (or a search list of such templates)
   258       from which to construct the public.html template name (or names)
   262       from which to construct the public.html template name (or names)
   259 
   263 
   260   Returns:
   264   Returns:
   277     if link_name:
   281     if link_name:
   278       user = id_user.getUserFromLinkNameOr404(link_name)
   282       user = id_user.getUserFromLinkNameOr404(link_name)
   279   except out_of_band.ErrorResponse, error:
   283   except out_of_band.ErrorResponse, error:
   280     # show custom 404 page when link name doesn't exist in Datastore
   284     # show custom 404 page when link name doesn't exist in Datastore
   281     error.message = error.message + DEF_CREATE_NEW_USER_MSG
   285     error.message = error.message + DEF_CREATE_NEW_USER_MSG
   282     return simple.errorResponse(request, error, template, context)
   286     return simple.errorResponse(request, error, template, context, page)
   283 
   287 
   284 
   288 
   285   if request.method == 'POST':
   289   if request.method == 'POST':
   286     form = EditForm(request.POST)
   290     form = EditForm(request.POST)
   287 
   291 
   395     return form_id
   399     return form_id
   396 
   400 
   397 
   401 
   398 DEF_SITE_CREATE_USER_PROFILE_TMPL = 'soc/site/user/profile/edit.html'
   402 DEF_SITE_CREATE_USER_PROFILE_TMPL = 'soc/site/user/profile/edit.html'
   399 
   403 
   400 def create(request, template=DEF_SITE_CREATE_USER_PROFILE_TMPL):
   404 def create(request, page=None, template=DEF_SITE_CREATE_USER_PROFILE_TMPL):
   401   """View for a Developer to create a new User Model entity.
   405   """View for a Developer to create a new User Model entity.
   402 
   406 
   403   Args:
   407   Args:
   404     request: the standard django request object
   408     request: the standard django request object
       
   409     page: a soc.logic.site.page.Page object which is abstraction that combines 
       
   410       a Django view with sidebar menu info
   405     template: the "sibling" template (or a search list of such templates)
   411     template: the "sibling" template (or a search list of such templates)
   406       from which to construct the public.html template name (or names)
   412       from which to construct the public.html template name (or names)
   407 
   413 
   408   Returns:
   414   Returns:
   409     A subclass of django.http.HttpResponse which either contains the form to
   415     A subclass of django.http.HttpResponse which either contains the form to