app/soc/views/sponsor/profile.py
changeset 512 aae25d2b4464
parent 500 44ea4620c5c0
equal deleted inserted replaced
511:52557918ec8f 512:aae25d2b4464
    34 
    34 
    35 
    35 
    36 DEF_SPONSOR_PUBLIC_TMPL = 'soc/group/profile/public.html'
    36 DEF_SPONSOR_PUBLIC_TMPL = 'soc/group/profile/public.html'
    37 
    37 
    38 @decorators.view
    38 @decorators.view
    39 def public(request, page_name=None, link_name=None, 
    39 def public(request, page_name=None, link_id=None, 
    40            template=DEF_SPONSOR_PUBLIC_TMPL):
    40            template=DEF_SPONSOR_PUBLIC_TMPL):
    41   """How the "general public" sees the Sponsor profile.
    41   """How the "general public" sees the Sponsor profile.
    42 
    42 
    43   Args:
    43   Args:
    44     request: the standard django request object.
    44     request: the standard django request object.
    45     page_name: the page name displayed in templates as page and header title
    45     page_name: the page name displayed in templates as page and header title
    46     link_name: the Sponsor's site-unique "link_name" extracted from the URL
    46     link_id: the Sponsor's site-unique "link_id" extracted from the URL
    47     template: the template path to use for rendering the template
    47     template: the template path to use for rendering the template
    48 
    48 
    49   Returns:
    49   Returns:
    50     A subclass of django.http.HttpResponse with generated template.
    50     A subclass of django.http.HttpResponse with generated template.
    51   """
    51   """
    52   # create default template context for use with any templates
    52   # create default template context for use with any templates
    53   context = helper.responses.getUniversalContext(request)
    53   context = helper.responses.getUniversalContext(request)
    54   context['page_name'] = page_name
    54   context['page_name'] = page_name
    55 
    55 
    56   try:
    56   try:
    57     link_name_sponsor = soc.logic.models.sponsor.logic.getIfFields(
    57     link_id_sponsor = soc.logic.models.sponsor.logic.getIfFields(
    58         link_name=link_name)
    58         link_id=link_id)
    59   except out_of_band.ErrorResponse, error:
    59   except out_of_band.ErrorResponse, error:
    60     # show custom 404 page when link name doesn't exist in Datastore
    60     # show custom 404 page when link ID doesn't exist in Datastore
    61     return simple.errorResponse(request, page_name, error, template, context)
    61     return simple.errorResponse(request, page_name, error, template, context)
    62 
    62 
    63   link_name_sponsor.description = \
    63   link_id_sponsor.description = \
    64       helper.templates.unescape(link_name_sponsor.description)
    64       helper.templates.unescape(link_id_sponsor.description)
    65   
    65   
    66   context.update({'entity': link_name_sponsor,
    66   context.update({'entity': link_id_sponsor,
    67                   'entity_type': sponsor_model.Sponsor.TYPE_NAME})
    67                   'entity_type': sponsor_model.Sponsor.TYPE_NAME})
    68 
    68 
    69   return helper.responses.respond(request, template, context)
    69   return helper.responses.respond(request, template, context)