def project_dashboard(request): my_proj = mergeLists( request.user.projects_working.filter(active=True).order_by("end_date"), request.user.projects_managed.filter(active=True).order_by("end_date") ) my_task = [ [item, dist(item.due_date)] for item in request.user.actionitem_todo.filter(done=False) ] jk_proj = Project.objects.filter(active=True) late_projects = Project.objects.filter(active=True, end_date__lt=date.today()) class MockUserWithCount(object): def __init__(self,user,count): self.user = user self.count = int(count) late_people = [] for u in User.objects.all(): c = u.actionitem_todo.filter(done=False,due_date__lt=date.today()).count() if c > 0: late_people.append(MockUserWithCount(u,c)) late_people.sort(lambda x,y: y.count - x.count) late_tasks = ActionItem.objects.filter(done=False,due_date__lt=date.today()) return render(request,'project_dashboard.html',{ 'my_proj_list':my_proj, 'my_task_list':my_task, 'jk_proj_list':jk_proj, 'late_projects':late_projects, 'late_people':late_people, 'late_tasks':late_tasks, })
def project_detail(request,object_id): p = get_object_or_404(Project,id=object_id) if not p.check_user(request.user): return PermissionDenied(request) return render(request,'project_detail.html',{ 'object':p, 'notes': p.note_set.order_by("-set_date"), 'actionitems': [ [item, dist(item.due_date)] for item in p.actionitem_set.all() ] })
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 todo(value): max_letters = 25 f = lambda x: x and (x + ' days left') or 'No due date' return "<ul>" + "\n".join([ ("<li class='%s'><a href='%s' title='%s in %s with %s priority'>%s</a></li>" % ( color_status(obj),obj.get_absolute_url(),f(dist(obj.due_date)),obj.project.name,obj.get_priority_display(),truncate(obj.title, max_letters)) ) for obj in User.objects.get(username=value).actionitem_todo.filter(done=False) ]) + "</ul>"