def home(request): #Ping Tola servers activity_up = os.system("ping -c 1 " + "http://tola-activity.mercycorps.org") data_up = os.system("ping -c 1 " + "http://tola-tables.mercycorps.org") #GitHub releases for status tola_repo = settings.GITHUB_REPO_1 tola_activity_repo = settings.GITHUB_REPO_2 tola = latest_release(tola_repo) if tola: tola_url = tola['html_url'] tola_number = tola['tag_name'] else: tola_url = None tola_number = None tola_activity = latest_release(tola_activity_repo) if tola_activity: tola_activity_url = tola_activity['html_url'] tola_activity_number = tola_activity['tag_name'] else: tola_activity_url = None tola_activity_number = None tickets = Ticket.objects.all().values('status').annotate(total=Count('status')).order_by('total') recent_tickets = Ticket.objects.all().exclude(status__in='4').order_by('-created')[:7] votes_tickets = Ticket.objects.all().exclude(status__in='4').filter(type=2).order_by('-votes')[:4] return render(request, 'home.html', {'home_tab': 'active', 'tola_url': tola_url,'tola_number': tola_number, \ 'tola_activity_url': tola_activity_url, 'tola_activity_number': tola_activity_number, \ 'activity_up': activity_up, 'data_up': data_up, 'tickets': tickets, \ 'recent_tickets': recent_tickets,'votes_tickets': votes_tickets})
def home(request): #Ping Tola servers activity_up = os.system("ping -c 1 " + "http://tola-activity.mercycorps.org") data_up = os.system("ping -c 1 " + "http://tola-tables.mercycorps.org") #GitHub releases for status tola_repo = settings.GITHUB_REPO_1 tola_activity_repo = settings.GITHUB_REPO_2 tola = latest_release(tola_repo) if tola: tola_url = tola['html_url'] tola_number = tola['tag_name'] else: tola_url = None tola_number = None tola_activity = latest_release(tola_activity_repo) if tola_activity: tola_activity_url = tola_activity['html_url'] tola_activity_number = tola_activity['tag_name'] else: tola_activity_url = None tola_activity_number = None tickets = Ticket.objects.all().values('status').annotate( total=Count('status')).order_by('total') recent_tickets = Ticket.objects.all().exclude( status__in='4').order_by('-created')[:7] votes_tickets = Ticket.objects.all().exclude(status__in='4').filter( type=2).order_by('-votes')[:4] return render(request, 'home.html', {'home_tab': 'active', 'tola_url': tola_url,'tola_number': tola_number, \ 'tola_activity_url': tola_activity_url, 'tola_activity_number': tola_activity_number, \ 'activity_up': activity_up, 'data_up': data_up, 'tickets': tickets, \ 'recent_tickets': recent_tickets,'votes_tickets': votes_tickets})
def home(request): #Ping Tola servers activity_up = os.system("ping -c 1 " + "http://tola-activity.mercycorps.org") data_up = os.system("ping -c 1 " + "http://tola-tables.mercycorps.org") #GitHub releases for status tola_repo = settings.GITHUB_REPO_1 tola_activity_repo = settings.GITHUB_REPO_2 tola = latest_release(tola_repo) if tola: tola_url = tola['html_url'] tola_number = tola['tag_name'] else: tola_url = None tola_number = None tola_activity = latest_release(tola_activity_repo) if tola_activity: tola_activity_url = tola_activity['html_url'] tola_activity_number = tola_activity['tag_name'] else: tola_activity_url = None tola_activity_number = None tickets = Ticket.objects.all().values('status').annotate(total=Count('status')).order_by('total') recent_tickets = Ticket.objects.all().exclude(status__in='4').order_by('-created')[:5] votes_tickets = Ticket.objects.all().exclude(status__in='4').filter(type=2).order_by('-votes')[:5] recent_tasks = Task.objects.all().order_by('-created_date')[:5] num_tickets = len(Ticket.objects.filter(status__in=[1,2,3])) num_tasks = len(Task.objects.all()) closed_resolved = 0 assigned_to_me = 0 created_by_me = 0 closed = [] tome = [] byme = [] tasks_created = [] total_tasks_created = 0 tasks_assigned = [] total_tasks_assigned = 0 tasks_completed = [] total_tasks_completed = 0 if (request.user.is_authenticated()): #tickets # open & reopened tickets closedresolved = Ticket.objects.select_related('queue').filter( assigned_to=request.user, status__in=[Ticket.CLOSED_STATUS, Ticket.RESOLVED_STATUS], ) closed=(closedresolved).order_by('-created')[:5] closed_resolved = len(closedresolved) # Tickets assigned to current user assigned_tome = Ticket.objects.select_related('queue').filter( assigned_to=request.user, ).exclude( status__in=[Ticket.CLOSED_STATUS, Ticket.RESOLVED_STATUS], ) tome=(assigned_tome).order_by('-created')[:5] assigned_to_me=len(assigned_tome) # Tickets created by current user created_byme = Ticket.objects.select_related('queue').filter( submitter_email=request.user.email, ).exclude( status__in=[Ticket.CLOSED_STATUS, Ticket.RESOLVED_STATUS], ) byme=(created_byme).order_by('-created')[:5] created_by_me = len(created_byme) #Tasks tasks = Task.objects.filter(submitter_email=request.user.email) all_tasks = (tasks).values('status').annotate(total=Count('status')).order_by('total') #tasks created by user tasks_created = (tasks).exclude(status__in=([3,4])).order_by('created_date')[:5] total_tasks_created = len(tasks_created) #tasks assigned to the user tasks_assigned = Task.objects.filter(assigned_to_id=request.user).exclude(status__in=([3,4])).order_by('created_date')[:5] total_tasks_assigned = len(tasks_assigned) #tasks completed by the user tasks_completed = (tasks).filter(status__in='3').order_by('created_date')[:5] total_tasks_completed = len (tasks_completed) #----Data From Tola Tools APIs----#### tolaActivityData = get_TolaActivity_data() tolaTablesData = {} if request.user.is_authenticated(): tolaTablesData = get_TolaTables_data(request) #create ticket modal assignable_users = User.objects.filter(is_active=True).order_by(User.USERNAME_FIELD) initial_data = {} try: if request.user.is_authenticated and request.user.email: initial_data['submitter_email'] = request.user.email except Exception, e: pass