def profile(request,username): u = get_object_or_404(User, username = username) if not (request.user == u or request.user.has_perm('accounts.view_profiles') or work_together(u, request.user)): return PermissionDenied(request) current_projects = mergeLists(u.projects_working.filter(active=True), u.projects_managed.filter(active=True)) past_projects = mergeLists(u.projects_working.filter(active=False), u.projects_managed.filter(active=False)) todo_list = [ [item, dist(item.due_date)] for item in u.actionitem_todo.filter(done=False) ] try: profile = u.get_profile() except UserProfile.DoesNotExist: profile = None return render(request,'user_profile.html',{'u':u,'current_projects':current_projects,'past_projects':past_projects,'todo_list':todo_list, 'profile':profile})
def can_view_this_cv(user, target): return user == target or (work_together(user, target) and user.has_perm('cvmanager.can_view_team_cv'))