Exemple #1
0
def hr_application_view(request, app_id):
	if request.method == 'POST':
		form = HRApplicationCommentForm(request.POST)
		if form.is_valid():
			auth_info = AuthServicesInfo.objects.get(user=request.user)

			comment = HRApplicationComment()
			comment.application = HRApplication.objects.get(id=int(form.cleaned_data['app_id']))
			comment.commenter_user = request.user
			comment.commenter_character = EveCharacter.objects.get(character_id=auth_info.main_char_id)
			comment.comment = form.cleaned_data['comment']
			comment.save()

	else:
		form = HRApplicationCommentForm()

	if HRApplication.objects.filter(id=app_id).exists():
		application = HRApplication.objects.get(id=app_id)
		comments = HRApplicationComment.objects.all().filter(application=application)
	else:
		application = HRApplication()
		comments = []

	context = {'application': application, 'comments': comments, 'comment_form': form}

	return render_to_response('registered/hrapplicationview.html',
							  context, context_instance=RequestContext(request))
Exemple #2
0
def hr_application_view(request, app_id):
    logger.debug("hr_application_view called by user %s for app id %s" % (request.user, app_id))
    if request.method == 'POST':
        form = HRApplicationCommentForm(request.POST)
        logger.debug("Request type POST contains form valid: %s" % form.is_valid())
        if form.is_valid():
            auth_info = AuthServicesInfo.objects.get(user=request.user)

            comment = HRApplicationComment()
            comment.application = HRApplication.objects.get(id=int(form.cleaned_data['app_id']))
            comment.commenter_user = request.user
            comment.commenter_character = EveCharacter.objects.get(character_id=auth_info.main_char_id)
            comment.comment = form.cleaned_data['comment']
            comment.save()
            logger.info("Saved comment by user %s to hrapplication %s" % (request.user, comment.application))

    else:
        logger.debug("Returning blank HRApplication comment form.")
        form = HRApplicationCommentForm()

    if HRApplication.objects.filter(id=app_id).exists():
        application = HRApplication.objects.get(id=app_id)
        comments = HRApplicationComment.objects.all().filter(application=application)
        logger.debug("Retrieved hrpplication id %s on behalf of user %s with comments %s" % (app_id, request.user, len(comments)))
    else:
        application = HRApplication()
        comments = []
        logger.error("HRAppllication with id %s not found - returning blank applicatin to user %s" % request.user)

    context = {'application': application, 'comments': comments, 'comment_form': form}

    return render_to_response('registered/hrapplicationview.html',
                              context, context_instance=RequestContext(request))
Exemple #3
0
def hr_application_view(request, app_id):
    logger.debug("hr_application_view called by user %s for app id %s" % (request.user, app_id))
    app = get_object_or_404(Application, pk=app_id)
    if request.method == "POST":
        if request.user.has_perm("hrapplications.add_applicationcomment"):
            form = HRApplicationCommentForm(request.POST)
            logger.debug("Request type POST contains form valid: %s" % form.is_valid())
            if form.is_valid():
                comment = ApplicationComment()
                comment.application = app
                comment.user = request.user
                comment.text = form.cleaned_data["comment"]
                comment.save()
                logger.info("Saved comment by user %s to %s" % (request.user, app))
        else:
            logger.warn("User %s does not have permission to add ApplicationComments" % request.user)
    else:
        logger.debug("Returning blank HRApplication comment form.")
        form = HRApplicationCommentForm()
    apis = []
    if request.user.has_perm("hrapplications.view_apis"):
        apis = app.apis
    context = {
        "app": app,
        "responses": ApplicationResponse.objects.filter(application=app),
        "buttons": True,
        "apis": apis,
        "comments": ApplicationComment.objects.filter(application=app),
        "comment_form": form,
    }
    return render_to_response("registered/hrapplicationview.html", context, context_instance=RequestContext(request))
Exemple #4
0
def hr_application_personal_view(request, app_id):
    logger.debug(
        "hr_application_personal_view called by user %s for app id %s" %
        (request.user, app_id))
    app = get_object_or_404(Application, pk=app_id)
    if app.user == request.user:
        context = {
            'app': app,
            'responses': ApplicationResponse.objects.filter(application=app),
            'buttons': False,
            'comments': ApplicationComment.objects.filter(application=app),
            'comment_form': HRApplicationCommentForm(),
            'apis': [],
        }
        return render_to_response('registered/hrapplicationview.html',
                                  context,
                                  context_instance=RequestContext(request))
    else:
        logger.warn("User %s not authorized to view %s" % (request.user, app))
        return redirect('auth_hrapplications_view')
Exemple #5
0
def hr_application_view(request, app_id):
    logger.debug("hr_application_view called by user %s for app id %s" %
                 (request.user, app_id))
    if request.method == 'POST':
        form = HRApplicationCommentForm(request.POST)
        logger.debug("Request type POST contains form valid: %s" %
                     form.is_valid())
        if form.is_valid():
            auth_info = AuthServicesInfo.objects.get(user=request.user)

            comment = HRApplicationComment()
            comment.application = HRApplication.objects.get(
                id=int(form.cleaned_data['app_id']))
            comment.commenter_user = request.user
            comment.commenter_character = EveCharacter.objects.get(
                character_id=auth_info.main_char_id)
            comment.comment = form.cleaned_data['comment']
            comment.save()
            logger.info("Saved comment by user %s to hrapplication %s" %
                        (request.user, comment.application))

    else:
        logger.debug("Returning blank HRApplication comment form.")
        form = HRApplicationCommentForm()

    if HRApplication.objects.filter(id=app_id).exists():
        application = HRApplication.objects.get(id=app_id)
        comments = HRApplicationComment.objects.all().filter(
            application=application)
        logger.debug(
            "Retrieved hrpplication id %s on behalf of user %s with comments %s"
            % (app_id, request.user, len(comments)))
    else:
        application = HRApplication()
        comments = []
        logger.error(
            "HRAppllication with id %s not found - returning blank applicatin to user %s"
            % request.user)

    context = {
        'application': application,
        'comments': comments,
        'comment_form': form
    }

    return render_to_response('registered/hrapplicationview.html',
                              context,
                              context_instance=RequestContext(request))
Exemple #6
0
def hr_application_view(request, app_id):
    logger.debug("hr_application_view called by user %s for app id %s" %
                 (request.user, app_id))
    app = get_object_or_404(Application, pk=app_id)
    if request.method == 'POST':
        if request.user.has_perm('hrapplications.add_applicationcomment'):
            form = HRApplicationCommentForm(request.POST)
            logger.debug("Request type POST contains form valid: %s" %
                         form.is_valid())
            if form.is_valid():
                comment = ApplicationComment()
                comment.application = app
                comment.user = request.user
                comment.text = form.cleaned_data['comment']
                comment.save()
                logger.info("Saved comment by user %s to %s" %
                            (request.user, app))
        else:
            logger.warn(
                "User %s does not have permission to add ApplicationComments" %
                request.user)
    else:
        logger.debug("Returning blank HRApplication comment form.")
        form = HRApplicationCommentForm()
    apis = []
    if request.user.has_perm('hrapplications.view_apis'):
        apis = app.apis
    context = {
        'app': app,
        'responses': ApplicationResponse.objects.filter(application=app),
        'buttons': True,
        'apis': apis,
        'comments': ApplicationComment.objects.filter(application=app),
        'comment_form': form,
    }
    return render_to_response('registered/hrapplicationview.html',
                              context,
                              context_instance=RequestContext(request))