Exemplo n.º 1
0
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})
Exemplo n.º 2
0
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,
			})
Exemplo n.º 3
0
def workspace(user):
	return mergeLists(user.projects_working.filter(active=True), user.projects_managed.filter(active=True))