示例#1
0
	def get_context_data(self, **kwargs):
		context = super(MotivoListView, self).get_context_data(**kwargs)

		motivos_list = Motivo.objects.all()
		motivos_list = sortable_helper(self.request, motivos_list)
		motivos_list = sortable_helper(self.request, motivos_list)

		paginator = Paginator(motivos_list, paginate)
		try:
			page = int(self.request.GET.get('page', '1'))
		except:
			page = 1

		try:
			motivos = paginator.page(page)
		except(EmptyPage, InvalidPage):
			motivos = paginator.page(1)
		index = motivos.number - 1  
		max_index = len(paginator.page_range)
		start_index = index - 3 if index >= 3 else 0
		end_index = index + 3 if index <= max_index - 3 else max_index
		page_range = paginator.page_range[start_index:end_index]

		context['motivos'] = motivos
		context['page_range'] = page_range

		return context
示例#2
0
    def get_context_data(self, **kwargs):
        context = super(FuncionarioList, self).get_context_data(**kwargs)

        estado = self.request.GET[
            'estado'] if 'estado' in self.request.GET else ''
        filtro = self.request.GET[
            'filtro'] if 'filtro' in self.request.GET else ''

        groups = []
        if self.request.user.is_superuser:
            groups = Group.objects.all().values_list('id', flat=True)
        else:
            groups = self.request.user.groups.values_list('id', flat=True)

        if estado != '':
            funcionarios_list = Funcionario.objects.filter(Q(estado=estado, nombre__icontains=filtro,   group__in=groups)
                        | Q(estado=estado, apellido__icontains=filtro,  group__in=groups)
                        | Q(estado=estado, documento__icontains=filtro,  group__in=groups)) \
                      .order_by("-id")

        else:
            funcionarios_list = Funcionario.objects.filter(Q(nombre__icontains=filtro,   group__in=groups)
                        | Q(apellido__icontains=filtro,  group__in=groups)
                        | Q(documento__icontains=filtro,  group__in=groups)) \
                      .order_by("-id")

        funcionarios_list = sortable_helper(self.request, funcionarios_list)

        funcionarios_list = sortable_helper(self.request, funcionarios_list)
        paginator = Paginator(funcionarios_list, paginate)

        try:
            page = int(self.request.GET.get('page', '1'))
        except:
            page = 1

        try:
            funcionarios = paginator.page(page)
        except (EmptyPage, InvalidPage):
            funcionarios = paginator.page(1)
        index = funcionarios.number - 1
        max_index = len(paginator.page_range)
        start_index = index - 3 if index >= 3 else 0
        end_index = index + 3 if index <= max_index - 3 else max_index
        page_range = paginator.page_range[start_index:end_index]

        context['funcionarios'] = funcionarios
        context['page_range'] = page_range
        return context
示例#3
0
def skills_overview(request,
                    topic_slug=None,
                    show_drafts=False,
                    show_recommended=False):
    # Show from topic
    if topic_slug is not None:
        topic = get_object_or_404(Topic, slug=topic_slug)
        skills = topic.skills.all()
    else:
        topic = None
        skills = Skill.objects.all()

    # Show recommended
    if show_recommended:
        skills = skills.filter(is_recommended=True)

    # Show public/drafts
    if request.user.has_perm('skills.add_trainingbit') and show_drafts:
        skills = skills.filter(is_draft=True)
    else:
        # by default show the skill that are _not_ drafts
        # that is - show the public skills
        skills = skills.filter(is_draft=False)

    # Sort
    skills = sortable_helper(request, skills)

    return render(
        request, 'skills/skills_overview.html', {
            'skills': skills,
            'showing_drafts': show_drafts,
            'showing_recommended': show_recommended,
            'topics': Topic.objects.exclude(slug__exact=''),
            'topic_chosen': topic,
        })
示例#4
0
def trainingbits_overview(request,
                          topic_slug=None,
                          show_drafts=False,
                          show_recommended=False):
    if topic_slug is not None:
        topic = get_object_or_404(Topic, slug=topic_slug)
        trainingbits = topic.trainingbits.all()
    else:
        topic = None
        trainingbits = TrainingBit.objects.all()

    # Show public/drafts
    if request.user.has_perm('skills.add_trainingbit') and show_drafts:
        trainingbits = trainingbits.filter(is_draft=True)
    else:
        # by default show the trainingbits that are _not_ drafts
        # that is - show the public trainingbits
        trainingbits = trainingbits.filter(is_draft=False)

    # Show recommended
    if show_recommended:
        trainingbits = trainingbits.filter(is_recommended=True)

    trainingbits = sortable_helper(request, trainingbits)
    return render(
        request, 'skills/trainingbits_overview.html', {
            'trainingbits': trainingbits,
            'topics': Topic.objects.all(),
            'topic_chosen': topic,
            'showing_recommended': show_recommended,
            'showing_drafts': show_drafts,
        })
示例#5
0
文件: views.py 项目: imclab/Franklin
def skills_overview(request, topic_slug=None, show_drafts=False, show_recommended=False):
    # Show from topic
    if topic_slug is not None:
        topic = get_object_or_404(Topic, slug=topic_slug)
        skills = topic.skills.all()
    else:
        topic = None
        skills = Skill.objects.all()

    # Show recommended
    if show_recommended:
        skills = skills.filter(is_recommended=True)

    # Show public/drafts
    if request.user.has_perm('skills.add_trainingbit') and show_drafts:
        skills = skills.filter(is_draft=True)
    else:
        # by default show the skill that are _not_ drafts
        # that is - show the public skills
        skills = skills.filter(is_draft=False)

    # Sort
    skills = sortable_helper(request, skills)

    return render(request, 'skills/skills_overview.html', {
        'skills': skills,
        'showing_drafts': show_drafts,
        'showing_recommended': show_recommended,
        'topics': Topic.objects.exclude(slug__exact=''),
        'topic_chosen': topic,
    })
示例#6
0
文件: views.py 项目: imclab/Franklin
def trainingbits_overview(request, topic_slug=None, show_drafts=False, show_recommended=False):
    if topic_slug is not None:
        topic = get_object_or_404(Topic, slug=topic_slug)
        trainingbits = topic.trainingbits.all()
    else:
        topic = None
        trainingbits = TrainingBit.objects.all()

    # Show public/drafts
    if request.user.has_perm('skills.add_trainingbit') and show_drafts:
        trainingbits = trainingbits.filter(is_draft=True)
    else:
        # by default show the trainingbits that are _not_ drafts
        # that is - show the public trainingbits
        trainingbits = trainingbits.filter(is_draft=False)

    # Show recommended
    if show_recommended:
        trainingbits = trainingbits.filter(is_recommended=True)

    trainingbits = sortable_helper(request, trainingbits)
    return render(request, 'skills/trainingbits_overview.html', {
        'trainingbits': trainingbits,
        'topics': Topic.objects.all(),
        'topic_chosen': topic,
        'showing_recommended': show_recommended,
        'showing_drafts': show_drafts,
    })
示例#7
0
	def get_queryset(self):
		filtro = self.request.GET['filtro'] if 'filtro' in self.request.GET else ''
		funcionarios = Funcionario.objects.filter(Q(estado='activo', nombre__icontains=filtro)
												  | Q(estado='activo', apellido__icontains=filtro)
												  | Q(estado='activo', documento__icontains=filtro))
		funcionarios = sortable_helper(self.request, funcionarios)
		for funcionario in funcionarios:
			periodos = Periodo.objects.filter(funcionario_id=funcionario.id, estado='activo').aggregate(
				total_libres=Sum('libres'))
			total_libres = periodos['total_libres'] if periodos['total_libres'] else 0
			funcionario.total_libres = total_libres

		return funcionarios
示例#8
0
    def get_context_data(self, **kwargs):

        context = super(SeccionList, self).get_context_data(**kwargs)
        filtro = self.request.GET[
            'filtro'] if 'filtro' in self.request.GET else ''

        groups = []
        if self.request.user.is_superuser:
            groups = Group.objects.all().values_list('id', flat=True)
        else:
            groups = self.request.user.groups.values_list('id', flat=True)

        secciones_list = Seccion.objects.filter(
            Q(nombre__icontains=filtro, group__in=groups)).order_by("-id")
        secciones_list = sortable_helper(self.request, secciones_list)

        secciones_list = sortable_helper(self.request, secciones_list)
        paginator = Paginator(secciones_list, paginate)

        try:
            page = int(self.request.GET.get('page', '1'))
        except:
            page = 1

        try:
            secciones = paginator.page(page)
        except (EmptyPage, InvalidPage):
            secciones = paginator.page(1)
        index = secciones.number - 1
        max_index = len(paginator.page_range)
        start_index = index - 3 if index >= 3 else 0
        end_index = index + 3 if index <= max_index - 3 else max_index
        page_range = paginator.page_range[start_index:end_index]

        context['secciones'] = secciones
        context['page_range'] = page_range

        return context
示例#9
0
    def get_context_data(self, **kwargs):
        context = super(JustificacionList, self).get_context_data(**kwargs)

        estado = self.request.GET[
            'estado'] if 'estado' in self.request.GET else ''
        filtro = self.request.GET[
            'filtro'] if 'filtro' in self.request.GET else ''
        user = self.request.user

        if estado != '':
            filtro = {
                Q(estado=estado, funcionario__nombre__icontains=filtro)
                | Q(estado=estado, funcionario__apellido__icontains=filtro)
                | Q(estado=estado, funcionario__documento__icontains=filtro)
            }

        else:
            filtro = {
                Q(funcionario__nombre__icontains=filtro)
                | Q(funcionario__apellido__icontains=filtro)
                | Q(funcionario__documento__icontains=filtro)
            }

        justificacion_list = Justificacion.objects.filter(
            *filtro).order_by("-id")

        justificacion_list = sortable_helper(self.request, justificacion_list)

        paginator = Paginator(justificacion_list, paginate)
        try:
            page = int(self.request.GET.get('page', '1'))
        except:
            page = 1

        try:
            justificaciones = paginator.page(page)
        except (EmptyPage, InvalidPage):
            justificaciones = paginator.page(1)
        index = justificaciones.number - 1
        max_index = len(paginator.page_range)
        start_index = index - 3 if index >= 3 else 0
        end_index = index + 3 if index <= max_index - 3 else max_index
        page_range = paginator.page_range[start_index:end_index]

        context['justificaciones'] = justificaciones
        context['page_range'] = page_range
        context["autor"] = user
        context["group"] = user.groups.first()

        return context
示例#10
0
	def get_context_data(self, **kwargs):
		context = super(SolicitudList, self).get_context_data(**kwargs)

		estado = self.request.GET['estado'] if 'estado' in self.request.GET else ''
		filtro = self.request.GET['filtro'] if 'filtro' in self.request.GET else ''
		
		# Listado de grupos para restriccion
		groups = []
		if self.request.user.is_superuser:
			groups = Group.objects.all().values_list('id', flat=True)
		else:
			groups = self.request.user.groups.values_list('id', flat=True)

		if estado != '':
			solicitud_list = Solicitud.objects.filter(Q(estado=estado, 	funcionario__nombre__icontains=filtro, 		funcionario__group__in=groups )
												   | Q(estado=estado, 	funcionario__apellido__icontains=filtro, 	funcionario__group__in=groups )
												   | Q(estado=estado, 	funcionario__documento__icontains=filtro, 	funcionario__group__in=groups )) \
				.order_by("-id")

		else:
			solicitud_list = Solicitud.objects.filter(Q(funcionario__nombre__icontains=filtro, 			funcionario__group__in=groups )
												   | Q(funcionario__apellido__icontains=filtro, 		funcionario__group__in=groups )
												   | Q(funcionario__documento__icontains=filtro, 	funcionario__group__in=groups )) \
				.order_by("-id")



		solicitud_list = sortable_helper(self.request, solicitud_list)

		paginator = Paginator(solicitud_list, paginate)
		try:
			page = int(self.request.GET.get('page', '1'))
		except:
			page = 1

		try:
			solicitudes = paginator.page(page)
		except(EmptyPage, InvalidPage):
			solicitudes = paginator.page(1)
		index = solicitudes.number - 1
		max_index = len(paginator.page_range)
		start_index = index - 3 if index >= 3 else 0
		end_index = index + 3 if index <= max_index - 3 else max_index
		page_range = paginator.page_range[start_index:end_index]

		context['solicitudes'] = solicitudes
		context['page_range'] = page_range

		return context
示例#11
0
def view_all_collection_records(request,):# *args, **kwargs):
    '''Formatted html of all collection records that are supplemental with
    the logged in user's publishing institutions association.
    '''
    collection_records = CollectionRecord.objects.all()
    if request.user.is_superuser:
        user_records = collection_records
    else:
        #subset records based on user
        user_insts = get_publishing_institutions_for_user(request.user)
        user_records = []
        for rec in collection_records:
            if rec.publisher.id in [ inst.id for inst in user_insts]:
                user_records.append(rec)
    object_list = user_records #alias for Django generic view
    collection_record_sortable = sortable_helper(request, object_list)
    return render(request, 'collection_record/collection_record/list.html',
            locals(),
            )
示例#12
0
def view_all_collection_records(request, ):  # *args, **kwargs):
    '''Formatted html of all collection records that are supplemental with
    the logged in user's publishing institutions association.
    '''
    collection_records = CollectionRecord.objects.all()
    if request.user.is_superuser:
        user_records = collection_records
    else:
        #subset records based on user
        user_insts = get_publishing_institutions_for_user(request.user)
        user_records = []
        for rec in collection_records:
            if rec.publisher.id in [inst.id for inst in user_insts]:
                user_records.append(rec)
    object_list = user_records  #alias for Django generic view
    collection_record_sortable = sortable_helper(request, object_list)
    return render(
        request,
        'collection_record/collection_record/list.html',
        locals(),
    )
示例#13
0
	def get_context_data(self, **kwargs):
		context = super(AjustesList, self).get_context_data(**kwargs)
		filtro = self.request.GET['filtro'] if 'filtro' in self.request.GET else ''
		groups = []
		if self.request.user.is_superuser:
			groups = Group.objects.all().values_list('id', flat=True)
		else:
			groups = self.request.user.groups.values_list('id', flat=True)
		funcionarios_list = Funcionario.objects.filter(	Q(estado='activo', nombre__icontains=filtro,		group__in=groups )
												  | Q(estado='activo', apellido__icontains=filtro,	group__in=groups )
												  | Q(estado='activo', documento__icontains=filtro,	group__in=groups ))
		funcionarios_list = sortable_helper(self.request, funcionarios_list)
		for funcionario in funcionarios_list:
			periodos = Periodo.objects.filter(funcionario_id=funcionario.id, estado='activo').aggregate(total_libres=Sum('libres'))
			total_libres = periodos['total_libres'] if periodos['total_libres'] else 0
			funcionario.total_libres = total_libres

		paginator = Paginator(funcionarios_list, paginate)
		try:
			page = int(self.request.GET.get('page', '1'))
		except:
			page = 1

		try:
			funcionarios = paginator.page(page)
		except(EmptyPage, InvalidPage):
			funcionarios = paginator.page(1)

		index = funcionarios.number - 1  
		max_index = len(paginator.page_range)
		start_index = index - 3 if index >= 3 else 0
		end_index = index + 3 if index <= max_index - 3 else max_index
		page_range = paginator.page_range[start_index:end_index]
		
		context['funcionarios'] = funcionarios
		context['page_range'] = page_range
		return context
示例#14
0
 def get_queryset(self):
     user = self.request.user
     queryset = super(AntiguedadList, self).get_queryset()
     return sortable_helper(self.request, queryset)
示例#15
0
def update_table(request):
	context = RequestContext(request)
	print("update_table");
	season = request.POST['season']
	team = request.POST['team']
	shooter = request.POST['shooter']
	#outcome = request.POST['outcome']
	#advanced_filters = True#request.POST['advanced_filters']
	advanced_filters = stringToBoolean(request.POST['advanced_filters'])
	goal_checked = stringToBoolean(request.POST['goal_checked'])
	save_checked = stringToBoolean(request.POST['save_checked'])
	miss_checked = stringToBoolean(request.POST['miss_checked'])
	block_checked = stringToBoolean(request.POST['block_checked'])
	even_checked = stringToBoolean(request.POST['even_checked'])
	pp_checked = stringToBoolean(request.POST['pp_checked'])
	sh_checked = stringToBoolean(request.POST['sh_checked'])

	shots = Shot.objects.all()

	if season != "All":
		shots = shots.filter(season=season)
	if team != "All":
		shots = shots.filter(shooting_team=team)
	if shooter != "All":
		shots = shots.filter(shooter=shooter)
	if not goal_checked:
		shots = shots.exclude(outcome="Goal")
	if not save_checked:
		shots = shots.exclude(outcome="Saved")
	if not miss_checked:
		shots = shots.exclude(outcome="Missed")
	if not block_checked:
		shots = shots.exclude(outcome="Blocked")
	if not even_checked:
		shots = shots.exclude(team_strength="even")
	if not pp_checked:
		shots = shots.exclude(team_strength="powerplay")
	if not sh_checked:
		shots = shots.exclude(team_strength="shorthanded")
	# if outcome != "All":
	# 	shots = shots.filter(outcome=outcome)

	if advanced_filters:
		print("advanced_filters")
		advanced_filters = True
		team_against = request.POST['team_against']
		goalie = request.POST['goalie']
		first_assist = request.POST['first_assist']
		second_assist = request.POST['second_assist']
		blocker = request.POST['blocker']

		print(blocker)

		if team_against != "All":
			shots = shots.filter(opposing_team=team_against)
		if goalie != "All":
			shots = shots.filter(goalie=goalie)
		if first_assist != "All":
			shots = shots.filter(first_assist=first_assist)
		if second_assist != "All":
			shots = shots.filter(second_assist=second_assist)
		if blocker != "All":
			print("FILTER BY BLOCKER")
			shots = shots.filter(blocker=blocker)



	context['amount'] = len(shots)
	player_list = shots.values_list('shooter', flat=True).distinct()
	shots_array = [x[:] for x in [[0]*cfg.SQUARE_COUNT_LENGTH]*cfg.SQUARE_COUNT_WIDTH]
	shots_array2 = []
	players = []
	total_count = 0
	for shooter in player_list:
		player = {}
		player['name'] = shooter
		player['goals'] = 0
		player['saves'] = 0
		player['miss'] = 0
		player['block'] = 0
		shot_list = shots.filter(shooter=shooter)
		player['total'] = len(shot_list)
		for shot in shot_list:
			shots_array[shot.x_plotted][shot.y_plotted] += 1
			shots_array2.append([float(shot.y), float(shot.x), 1])
			total_count += 1
			if shot.outcome == "Goal":
				player['goals'] += 1
			if shot.outcome == "Saved":
				player['saves'] += 1
			if shot.outcome == "Missed":
				player['miss'] += 1
			if shot.outcome == "Blocked":
				player['block'] += 1
		players.append(player)

	shots_array3 = []
	max_value = 0
	for i in range(len(shots_array)):
		for l in range(len(shots_array[i])):
			count = shots_array[i][l]
			if count > max_value:
				max_value = count
			shots_array3.append([l + cfg.SQUARE_EDGE_LENGTH, i + cfg.SQUARE_EDGE_LENGTH, count])
	context['shots_array'] = shots_array3
	context['data_array'] = shots_array
	context['max_value'] = total_count #/ 10 #max_value
	context['players'] = sortable_helper(request, players)
	heatmap_container_width = int(request.POST['heatmap_container_width'])
	context['heatmap_container_width'] = heatmap_container_width
	context['heatmap_container_height'] = int(491 / float(973) * heatmap_container_width)
	#return render(request, 'heatmap.html', context)
	print("even_checked")
	return render(request, 'stats_table.html', context)