Exemplo n.º 1
0
def hr_application_search(request):
    logger.debug("hr_application_search called by user %s" % request.user)
    if request.method == 'POST':
        form = HRApplicationSearchForm(request.POST)
        logger.debug("Request type POST contains form valid: %s" % form.is_valid())
        if form.is_valid():
            # Really dumb search and only checks character name
            # This can be improved but it does the job for now
            searchstring = form.cleaned_data['search_string']
            applications = []
            logger.debug("Searching for application with character name %s for user %s" % (searchstring, request.user))

            for application in HRApplication.objects.all():
                if searchstring in application.character_name:
                    applications.append(application)
            logger.info("Found %s HRApplications for user %s matching search string %s" % (len(applications), request.user, searchstring))

            context = {'applications': applications, 'search_form': HRApplicationSearchForm()}

            return render_to_response('registered/hrapplicationsearchview.html',
                                      context, context_instance=RequestContext(request))
        else:
            logger.debug("Form invalid - returning for user %s to retry." % request.user)
            context = {'applications': None, 'search_form': form}
            return render_to_response('registered/hrapplicationsearchview.html',
                                                                          context, context_instance=RequestContext(request))

    else:
        logger.debug("Returning empty search form for user %s" % request.user)
        return HttpResponseRedirect("/hr_application_management/")
Exemplo n.º 2
0
def hr_application_search(request):
    logger.debug("hr_application_search called by user %s" % request.user)
    if request.method == "POST":
        form = HRApplicationSearchForm(request.POST)
        logger.debug("Request type POST contains form valid: %s" % form.is_valid())
        if form.is_valid():
            searchstring = form.cleaned_data["search_string"].lower()
            applications = set([])
            logger.debug("Searching for application with character name %s for user %s" % (searchstring, request.user))
            app_list = []
            if request.user.is_superuser:
                app_list = Application.objects.all()
            else:
                auth_info = AuthServicesInfo.objects.get(user=request.user)
                try:
                    character = EveCharacter.objects.get(character_id=auth_info.main_char_id)
                    app_list = Application.objects.filter(form__corp__corporation_id=character.corporation_id)
                except:
                    logger.warn(
                        "User %s missing main character model: unable to filter applications to search" % request.user
                    )
            for application in app_list:
                if application.main_character:
                    if searchstring in application.main_character.character_name.lower():
                        applications.add(application)
                    if searchstring in application.main_character.corporation_name.lower():
                        applications.add(application)
                    if searchstring in application.main_character.alliance_name.lower():
                        applications.add(application)
                for character in application.characters:
                    if searchstring in character.character_name.lower():
                        applications.add(application)
                    if searchstring in character.corporation_name.lower():
                        applications.add(application)
                    if searchstring in character.alliance_name.lower():
                        applications.add(application)
                if searchstring in application.user.username.lower():
                    applications.add(application)
            logger.info(
                "Found %s Applications for user %s matching search string %s"
                % (len(applications), request.user, searchstring)
            )

            context = {"applications": applications, "search_form": HRApplicationSearchForm()}

            return render_to_response(
                "registered/hrapplicationsearchview.html", context, context_instance=RequestContext(request)
            )
        else:
            logger.debug("Form invalid - returning for user %s to retry." % request.user)
            context = {"applications": None, "search_form": form}
            return render_to_response(
                "registered/hrapplicationsearchview.html", context, context_instance=RequestContext(request)
            )

    else:
        logger.debug("Returning empty search form for user %s" % request.user)
        return HttpResponseRedirect("/hr_application_management/")
Exemplo n.º 3
0
def hr_application_search(request):
	if request.method == 'POST':
		form = HRApplicationSearchForm(request.POST)
		if form.is_valid():
			# Really dumb search and only checks character name
			# This can be improved but it does the job for now
			searchstring = form.cleaned_data['search_string']
			applications = []

			for application in HRApplication.objects.all():
				if searchstring in application.character_name:
					applications.append(application)

			context = {'applications': applications, 'search_form': HRApplicationSearchForm()}

			return render_to_response('registered/hrapplicationsearchview.html',
									  context, context_instance=RequestContext(request))
	else:
		return HttpResponseRedirect("/hr_application_management/")
Exemplo n.º 4
0
def hr_application_search(request):
    logger.debug("hr_application_search called by user %s" % request.user)
    if request.method == 'POST':
        form = HRApplicationSearchForm(request.POST)
        logger.debug("Request type POST contains form valid: %s" %
                     form.is_valid())
        if form.is_valid():
            # Really dumb search and only checks character name
            # This can be improved but it does the job for now
            searchstring = form.cleaned_data['search_string']
            applications = []
            logger.debug(
                "Searching for application with character name %s for user %s"
                % (searchstring, request.user))

            for application in HRApplication.objects.all():
                if searchstring in application.character_name:
                    applications.append(application)
            logger.info(
                "Found %s HRApplications for user %s matching search string %s"
                % (len(applications), request.user, searchstring))

            context = {
                'applications': applications,
                'search_form': HRApplicationSearchForm()
            }

            return render_to_response(
                'registered/hrapplicationsearchview.html',
                context,
                context_instance=RequestContext(request))
        else:
            logger.debug("Form invalid - returning for user %s to retry." %
                         request.user)
            context = {'applications': None, 'search_form': form}
            return render_to_response(
                'registered/hrapplicationsearchview.html',
                context,
                context_instance=RequestContext(request))

    else:
        logger.debug("Returning empty search form for user %s" % request.user)
        return HttpResponseRedirect("/hr_application_management/")
Exemplo n.º 5
0
def hr_application_management_view(request):
    logger.debug("hr_application_management_view called by user %s" %
                 request.user)
    personal_app = None
    corp_applications = None

    if request.user.is_superuser:
        logger.debug("User %s is superuser: returning all applications." %
                     request.user)
        corp_applications = HRApplication.objects.all()
    else:
        # Get the corp the member is in
        auth_info = AuthServicesInfo.objects.get(user=request.user)
        if auth_info.main_char_id != "":
            try:
                main_corp_id = EveManager.get_charater_corporation_id_by_id(
                    auth_info.main_char_id)
                main_alliance_id = EveManager.get_charater_alliance_id_by_id(
                    auth_info.main_char_id)
                if (settings.IS_CORP and main_corp_id == settings.CORP_ID) or (
                        not settings.IS_CORP
                        and main_alliance_id == settings.ALLIANCE_ID):
                    main_char = EveCharacter.objects.get(
                        character_id=auth_info.main_char_id)
                    if EveCorporationInfo.objects.filter(
                            corporation_id=main_char.corporation_id).exists():
                        corp = EveCorporationInfo.objects.get(
                            corporation_id=main_char.corporation_id)
                        corp_applications = HRApplication.objects.filter(
                            corp=corp).filter(approved_denied=None)
                    else:
                        corp_applications = None
                else:
                    corp_applications = None
            except:
                logger.error(
                    "Unable to determine user %s main character id %s corp. Returning no corp hrapplications."
                    % (request.user, auth_info.main_char_id))
                corp_applications = None
    context = {
        'personal_apps': HRApplication.objects.all().filter(user=request.user),
        'applications': corp_applications,
        'search_form': HRApplicationSearchForm()
    }

    return render_to_response('registered/hrapplicationmanagement.html',
                              context,
                              context_instance=RequestContext(request))
Exemplo n.º 6
0
def hr_application_management_view(request):
    logger.debug("hr_application_management_view called by user %s" %
                 request.user)
    corp_applications = []
    finished_corp_applications = []
    auth_info, c = AuthServicesInfo.objects.get_or_create(user=request.user)
    main_char = None
    if auth_info.main_char_id:
        try:
            main_char = EveCharacter.objects.get(
                character_id=auth_info.main_char_id)
        except:
            pass
    if request.user.is_superuser:
        corp_applications = Application.objects.filter(approved=None)
        finished_corp_applications = Application.objects.exclude(approved=None)
    elif request.user.has_perm('auth.human_resources') and main_char:
        if ApplicationForm.objects.filter(
                corp__corporation_id=main_char.corporation_id).exists():
            app_form = ApplicationForm.objects.get(
                corp__corporation_id=main_char.corporation_id)
            corp_applications = Application.objects.filter(
                form=app_form).filter(approved=None)
            finished_corp_applications = Application.objects.filter(
                form=app_form).filter(approved__in=[True, False])
    logger.debug("Retrieved %s personal, %s corp applications for %s" %
                 (len(request.user.applications.all()), len(corp_applications),
                  request.user))
    context = {
        'personal_apps': request.user.applications.all(),
        'applications': corp_applications,
        'finished_applications': finished_corp_applications,
        'search_form': HRApplicationSearchForm(),
        'create': create_application_test(request.user)
    }
    return render_to_response('registered/hrapplicationmanagement.html',
                              context,
                              context_instance=RequestContext(request))
Exemplo n.º 7
0
def hr_application_management_view(request):
	personal_app = None
	corp_applications = None

	if request.user.is_superuser:
		corp_applications = HRApplication.objects.all()
	else:
		# Get the corp the member is in
		auth_info = AuthServicesInfo.objects.get(user=request.user)
		if auth_info.main_char_id != "":
			main_alliance_id = EveManager.get_charater_alliance_id_by_id(auth_info.main_char_id)
			if main_alliance_id == settings.ALLIANCE_ID:
				main_char = EveCharacter.objects.get(character_id=auth_info.main_char_id)
				corp = EveCorporationInfo.objects.get(corporation_id=main_char.corporation_id)
				corp_applications = HRApplication.objects.filter(corp=corp).filter(approved_denied=None)
			else:
				corp_applications = None

	context = {'personal_apps': HRApplication.objects.all().filter(user=request.user),
			   'applications': corp_applications,
			   'search_form': HRApplicationSearchForm()}

	return render_to_response('registered/hrapplicationmanagement.html',
							  context, context_instance=RequestContext(request))
Exemplo n.º 8
0
def hr_application_search(request):
    logger.debug("hr_application_search called by user %s" % request.user)
    if request.method == 'POST':
        form = HRApplicationSearchForm(request.POST)
        logger.debug("Request type POST contains form valid: %s" %
                     form.is_valid())
        if form.is_valid():
            searchstring = form.cleaned_data['search_string'].lower()
            applications = set([])
            logger.debug(
                "Searching for application with character name %s for user %s"
                % (searchstring, request.user))
            app_list = []
            if request.user.is_superuser:
                app_list = Application.objects.all()
            else:
                auth_info = AuthServicesInfo.objects.get(user=request.user)
                try:
                    character = EveCharacter.objects.get(
                        character_id=auth_info.main_char_id)
                    app_list = Application.objects.filter(
                        form__corp__corporation_id=character.corporation_id)
                except:
                    logger.warn(
                        "User %s missing main character model: unable to filter applications to search"
                        % request.user)
            for application in app_list:
                if application.main_character:
                    if searchstring in application.main_character.character_name.lower(
                    ):
                        applications.add(application)
                    if searchstring in application.main_character.corporation_name.lower(
                    ):
                        applications.add(application)
                    if searchstring in application.main_character.alliance_name.lower(
                    ):                        \
                                                applications.add(application)
                for character in application.characters:
                    if searchstring in character.character_name.lower():
                        applications.add(application)
                    if searchstring in character.corporation_name.lower():
                        applications.add(application)
                    if searchstring in character.alliance_name.lower():
                        applications.add(application)
                if searchstring in application.user.username.lower():
                    applications.add(application)
            logger.info(
                "Found %s Applications for user %s matching search string %s" %
                (len(applications), request.user, searchstring))

            context = {
                'applications': applications,
                'search_form': HRApplicationSearchForm()
            }

            return render_to_response(
                'registered/hrapplicationsearchview.html',
                context,
                context_instance=RequestContext(request))
        else:
            logger.debug("Form invalid - returning for user %s to retry." %
                         request.user)
            context = {'applications': None, 'search_form': form}
            return render_to_response(
                'registered/hrapplicationsearchview.html',
                context,
                context_instance=RequestContext(request))

    else:
        logger.debug("Returning empty search form for user %s" % request.user)
        return HttpResponseRedirect("/hr_application_management/")