<s> from __future__ import absolute_import , unicode_literals <EOL> import logging <EOL> from django . contrib . auth . models import User <EOL> from django . contrib import messages <EOL> from django . template import RequestContext <EOL> from django . http import HttpResponse <EOL> from django . http import HttpResponseRedirect <EOL> from django . conf import settings <EOL> from django . shortcuts import render_to_response <EOL> from django . template . loader import render_to_string <EOL> from django . contrib . auth . decorators import login_required , user_passes_test <EOL> from django . utils . datastructures import SortedDict <EOL> from account . models import Team <EOL> from logical . models import Database <EOL> LOG = logging . getLogger ( __name__ ) <EOL> @ login_required <EOL> def profile ( request , user_id = None ) : <EOL> user = None <EOL> databases = None <EOL> teams = None <EOL> roles = None <EOL> try : <EOL> user = User . objects . get ( id = user_id ) <EOL> teams = Team . objects . filter ( users = user ) <EOL> databases = Database . alive . filter ( <EOL> team__in = [ team . id for team in teams ] ) . order_by ( '<STR_LIT>' ) <EOL> roles = [ team . role for team in teams ] <EOL> except Exception , e : <EOL> LOG . warning ( "<STR_LIT>" % e ) <EOL> return render_to_response ( "<STR_LIT>" , locals ( ) , context_instance = RequestContext ( request ) ) </s>
