Exemplo n.º 1
0
def personal(request, sport_id = ""):
    section = request.path_info
    pageContext = {"title": "Pagina personale",
                   "sport_id": sport_id,
                   "section": section,
                   "tabmenu": []}
    
    # Subscribed sports dinamically added as new tabs in the Pagina personale
    tab_name = ""
    sport = None
    sport_list = request.user.praticante_set.all();
    for sp in sport_list:
        try:
            if (int(sport_id) == sp.sport.id):
                sport = sp.sport
                tab_name = sp.sport.nome
        except:
            pass
        pageContext.get("tabmenu").append({"name": sp.sport.nome, 
                                           "section": "/personal_%s/%s/" % (request.user.id, sp.sport.id)})
    pageContext.get("tabmenu").append({"name": "Dati personali", 
                                       "section": "/personal_%s/" % request.user.id})
    
    temp = []
    if sport:
        cat = sport.categoriaevento_set.all()
        for c in cat:
            temp.extend(c.evento_set.all())
    
    pageContext.update({"list": temp, "channel": "Milano"})
    
    # figurina
    pageContext.update(get_url_gravatar("picture", request.user.email, 200))
    
    page = section.strip("/").split("_")[1]
    if len(page) > 1:
        pageContext.update({"title": "Pagina " + tab_name.lower()})
        page = "personal_sport"
    else:
        page = "personal"
    return render_to_response(page + ".html", pageContext, RequestContext(request))
Exemplo n.º 2
0
 def render(self, context):
     user = context["user"]
     if user.is_authenticated():
         context.update(get_url_gravatar("gravatar", user.email, 128))
     t = template.loader.get_template("profile.html")
     return t.render(template.Context(context, autoescape = context.autoescape))