mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-12 14:00:17 +02:00
Implement additional requests in #305
This commit is contained in:
parent
eaa44c0254
commit
a425d32405
@ -46,7 +46,7 @@ class Application(models.Model):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def characters(self):
|
def characters(self):
|
||||||
return EveCharacter.objects.filter(user=user)
|
return EveCharacter.objects.filter(user=self.user)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def apis(self):
|
def apis(self):
|
||||||
|
@ -2,6 +2,7 @@ from django.template import RequestContext
|
|||||||
from django.shortcuts import render_to_response, get_object_or_404, redirect
|
from django.shortcuts import render_to_response, get_object_or_404, redirect
|
||||||
from django.contrib.auth.decorators import permission_required
|
from django.contrib.auth.decorators import permission_required
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
from django.contrib.auth.decorators import user_passes_test
|
||||||
from django.shortcuts import HttpResponseRedirect
|
from django.shortcuts import HttpResponseRedirect
|
||||||
from notifications import notify
|
from notifications import notify
|
||||||
from models import HRApplication
|
from models import HRApplication
|
||||||
@ -24,10 +25,18 @@ import logging
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
def create_application_test(user):
|
||||||
|
auth, c = AuthServicesInfo.objects.get_or_create(user=user)
|
||||||
|
if auth.main_char_id:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def hr_application_management_view(request):
|
def hr_application_management_view(request):
|
||||||
logger.debug("hr_application_management_view called by user %s" % request.user)
|
logger.debug("hr_application_management_view called by user %s" % request.user)
|
||||||
corp_applications = []
|
corp_applications = []
|
||||||
|
finished_corp_applications = []
|
||||||
auth_info, c = AuthServicesInfo.objects.get_or_create(user=request.user)
|
auth_info, c = AuthServicesInfo.objects.get_or_create(user=request.user)
|
||||||
main_char = None
|
main_char = None
|
||||||
if auth_info.main_char_id:
|
if auth_info.main_char_id:
|
||||||
@ -41,14 +50,19 @@ def hr_application_management_view(request):
|
|||||||
if ApplicationForm.objects.filter(corp__corporation_id=main_char.corporation_id).exists():
|
if ApplicationForm.objects.filter(corp__corporation_id=main_char.corporation_id).exists():
|
||||||
app_form = ApplicationForm.objects.get(corp__corporation_id=main_char.corporation_id)
|
app_form = ApplicationForm.objects.get(corp__corporation_id=main_char.corporation_id)
|
||||||
corp_applications = Application.objects.filter(form=app_form).filter(approved=None)
|
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))
|
logger.debug("Retrieved %s personal, %s corp applications for %s" % (len(request.user.applications.all()), len(corp_applications), request.user))
|
||||||
context = {
|
context = {
|
||||||
'personal_apps': request.user.applications.all(),
|
'personal_apps': request.user.applications.all(),
|
||||||
'applications': corp_applications,
|
'applications': corp_applications,
|
||||||
'search_form': HRApplicationSearchForm()}
|
'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))
|
return render_to_response('registered/hrapplicationmanagement.html', context, context_instance=RequestContext(request))
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
@user_passes_test(create_application_test)
|
||||||
def hr_application_create_view(request, form_id=None):
|
def hr_application_create_view(request, form_id=None):
|
||||||
if form_id:
|
if form_id:
|
||||||
app_form = get_object_or_404(ApplicationForm, id=form_id)
|
app_form = get_object_or_404(ApplicationForm, id=form_id)
|
||||||
@ -98,8 +112,11 @@ def hr_application_personal_removal(request, app_id):
|
|||||||
logger.debug("hr_application_personal_removal called by user %s for app id %s" % (request.user, app_id))
|
logger.debug("hr_application_personal_removal called by user %s for app id %s" % (request.user, app_id))
|
||||||
app = get_object_or_404(Application, pk=app_id)
|
app = get_object_or_404(Application, pk=app_id)
|
||||||
if app.user == request.user:
|
if app.user == request.user:
|
||||||
logger.info("User %s deleting %s" % (request.user, app))
|
if app.accepted == None:
|
||||||
app.delete()
|
logger.info("User %s deleting %s" % (request.user, app))
|
||||||
|
app.delete()
|
||||||
|
else:
|
||||||
|
logger.warn("User %s attempting to delete reviewed app %s" % (request.user, app))
|
||||||
else:
|
else:
|
||||||
logger.warn("User %s not authorized to delete %s" % (request.user, app))
|
logger.warn("User %s not authorized to delete %s" % (request.user, app))
|
||||||
return redirect('auth_hrapplications_view')
|
return redirect('auth_hrapplications_view')
|
||||||
@ -188,17 +205,35 @@ def hr_application_search(request):
|
|||||||
form = HRApplicationSearchForm(request.POST)
|
form = HRApplicationSearchForm(request.POST)
|
||||||
logger.debug("Request type POST contains form valid: %s" % form.is_valid())
|
logger.debug("Request type POST contains form valid: %s" % form.is_valid())
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
# Really dumb search and only checks character name
|
searchstring = form.cleaned_data['search_string'].lower()
|
||||||
# This can be improved but it does the job for now
|
|
||||||
searchstring = form.cleaned_data['search_string']
|
|
||||||
applications = set([])
|
applications = set([])
|
||||||
logger.debug("Searching for application with character name %s for user %s" % (searchstring, request.user))
|
logger.debug("Searching for application with character name %s for user %s" % (searchstring, request.user))
|
||||||
|
app_list = []
|
||||||
for application in Application.objects.all():
|
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 application.main_character:
|
||||||
if searchstring in application.main_character.character_name:
|
if searchstring in application.main_character.character_name.lower():
|
||||||
applications.add(application)
|
applications.add(application)
|
||||||
if searchstring in application.user.username:
|
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)
|
applications.add(application)
|
||||||
logger.info("Found %s Applications for user %s matching search string %s" % (len(applications), request.user, searchstring))
|
logger.info("Found %s Applications for user %s matching search string %s" % (len(applications), request.user, searchstring))
|
||||||
|
|
||||||
|
@ -12,13 +12,11 @@
|
|||||||
{% if not perms.auth.member %}
|
{% if not perms.auth.member %}
|
||||||
<h1 class="page-header text-center">Personal Applications
|
<h1 class="page-header text-center">Personal Applications
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
<a href="{% url 'auth_hrapplication_create_view' %}">
|
{% if create %}
|
||||||
{% if personal_app %}
|
<a href="{% url 'auth_hrapplication_create_view' %}"><button type="button" class="btn btn-success">Create Application</button></a>
|
||||||
<button type="button" class="btn btn-success" disabled>Create Application</button>
|
{% else %}
|
||||||
{% else %}
|
<button type="button" class="btn btn-success" disabled>Create Application</button>
|
||||||
<button type="button" class="btn btn-success">Create Application</button>
|
{% endif %}
|
||||||
{% endif %}
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
</h1>
|
</h1>
|
||||||
<table class="table table-bordered table-condensed">
|
<table class="table table-bordered table-condensed">
|
||||||
@ -67,40 +65,93 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</h1>
|
</h1>
|
||||||
<div class="container-fluid">
|
<ul class="nav nav-tabs">
|
||||||
<table class="table table-bordered">
|
<li class="active"><a data-toggle="tab" href="#pending">Pending</a></li>
|
||||||
<tr>
|
<li><a data-toggle="tab" href="#reviewed">Reviewed</a></li>
|
||||||
<th class="text-center">Application ID</th>
|
</ul>
|
||||||
<th class="text-center">Username</th>
|
<div class="tab-content">
|
||||||
<th class="text-center">Main Character</th>
|
<div id="pending" class="tab-pane fade in active">
|
||||||
<th class="text-center">Corporation</th>
|
<div class="panel-body">
|
||||||
<th class="text-center">Status</th>
|
<table class="table">
|
||||||
<th class="text-center">Actions</th>
|
<tr>
|
||||||
</tr>
|
<th class="text-center">Date</th>
|
||||||
{% for app in applications %}
|
<th class="text-center">Username</th>
|
||||||
<tr>
|
<th class="text-center">Main Character</th>
|
||||||
<td class="text-center">{{ app.id }}</td>
|
<th class="text-center">Corporation</th>
|
||||||
<td class="text-center">{{ app.user.username }}</td>
|
<th class="text-center">Status</th>
|
||||||
<td class="text-center">{{ app.main_character }}</td>
|
<th class="text-center">Actions</th>
|
||||||
<td class="text-center">{{ app.form.corp.corporation_name }}</td>
|
</tr>
|
||||||
<td class="text-center">
|
{% for app in applications %}
|
||||||
{% if app.approved_denied == None %}
|
<tr>
|
||||||
<div class="panel panel-warning" role="alert">Pending</div>
|
<td class="text-center">{{ app.created }}</td>
|
||||||
{% elif app.approved_denied == True %}
|
<td class="text-center">{{ app.user.username }}</td>
|
||||||
<div class="panel panel-success" role="alert">Approved</div>
|
<td class="text-center">{{ app.main_character }}</td>
|
||||||
{% else %}
|
<td class="text-center">{{ app.form.corp.corporation_name }}</td>
|
||||||
<div class="panel panel-danger" role="alert">Rejected</div>
|
<td class="text-center">
|
||||||
{% endif %}
|
{% if app.approved_denied == None %}
|
||||||
</td>
|
{% if app.reviewer_str %}
|
||||||
<td class="text-center">
|
<div class="label label-info">Reviewer: {{ app.reviewer_str }}</div>
|
||||||
<a href="/hr_application_view/{{ app.id }}">
|
{% else %}
|
||||||
<button type="button" class="btn btn-primary"><span
|
<div class="label label-warning">Pending</div>
|
||||||
class="glyphicon glyphicon-eye-open"></span></button>
|
{% endif %}
|
||||||
</a>
|
{% elif app.approved_denied == True %}
|
||||||
</td>
|
<div class="label label-success">Approved</div>
|
||||||
</tr>
|
{% else %}
|
||||||
{% endfor %}
|
<div class="label label-danger">Rejected</div>
|
||||||
</table>
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td class="text-center">
|
||||||
|
<a href="/hr_application_view/{{ app.id }}">
|
||||||
|
<button type="button" class="btn btn-primary"><span
|
||||||
|
class="glyphicon glyphicon-eye-open"></span></button>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="reviewed" class="tab-pane fade">
|
||||||
|
<div class="panel-body">
|
||||||
|
<table class="table">
|
||||||
|
<tr>
|
||||||
|
<th class="text-center">Date</th>
|
||||||
|
<th class="text-center">Username</th>
|
||||||
|
<th class="text-center">Main Character</th>
|
||||||
|
<th class="text-center">Corporation</th>
|
||||||
|
<th class="text-center">Status</th>
|
||||||
|
<th class="text-center">Actions</th>
|
||||||
|
</tr>
|
||||||
|
{% for app in finished_applications %}
|
||||||
|
<tr>
|
||||||
|
<td class="text-center">{{ app.created }}</td>
|
||||||
|
<td class="text-center">{{ app.user.username }}</td>
|
||||||
|
<td class="text-center">{{ app.main_character }}</td>
|
||||||
|
<td class="text-center">{{ app.form.corp.corporation_name }}</td>
|
||||||
|
<td class="text-center">
|
||||||
|
{% if app.approved_denied == None %}
|
||||||
|
{% if app.reviewer_str %}
|
||||||
|
<div class="label label-info">Reviewer: {{ app.reviewer_str }}</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="label label-warning">Pending</div>
|
||||||
|
{% endif %}
|
||||||
|
{% elif app.approved_denied == True %}
|
||||||
|
<div class="label label-success">Approved</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="label label-danger">Rejected</div>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td class="text-center">
|
||||||
|
<a href="/hr_application_view/{{ app.id }}">
|
||||||
|
<button type="button" class="btn btn-primary"><span
|
||||||
|
class="glyphicon glyphicon-eye-open"></span></button>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -21,14 +21,53 @@
|
|||||||
{% if app.reviewer_str %}
|
{% if app.reviewer_str %}
|
||||||
<div class="alert alert-info">Reviewer: {{ app.reviewer_str }}</div>
|
<div class="alert alert-info">Reviewer: {{ app.reviewer_str }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for response in responses %}
|
</div>
|
||||||
<div class="panel panel-default">
|
<div class="row">
|
||||||
<div class="panel-heading">{{ response.question.title }}</div>
|
<div class="panel panel-info">
|
||||||
<div class="alert">{{ response.answer }}</div>
|
<div class="panel-heading">Applicant</div>
|
||||||
</div>
|
<table class="table">
|
||||||
{% endfor %}
|
<tr>
|
||||||
|
<th class="text-center">User</th>
|
||||||
|
<th class="text-center">Main Character</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="text-center">{{ app.user }}</td>
|
||||||
|
<td class="text-center">{{ app.main_character }}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="panel panel-info">
|
||||||
|
<div class="panel-heading">Characters</div>
|
||||||
|
<table class="table">
|
||||||
|
<tr>
|
||||||
|
<th class="text-center"></th>
|
||||||
|
<th class="text-center">Name</th>
|
||||||
|
<th class="text-center">Corp</th>
|
||||||
|
<th class="text-center">Alliance</th>
|
||||||
|
</tr>
|
||||||
|
{% for char in app.characters %}
|
||||||
|
<tr>
|
||||||
|
<td class="text-center">
|
||||||
|
<img class="ra-avatar img-responsive" src="https://image.eveonline.com/Character/{{ char.character_id }}_32.jpg">
|
||||||
|
</td>
|
||||||
|
<td class="text-center">{{ char.character_name }}</td>
|
||||||
|
<td class="text-center">{{ char.corporation_name }}</td>
|
||||||
|
<td class="text-center">{{ char.alliance_name }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
{% for response in responses %}
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">{{ response.question.title }}</div>
|
||||||
|
<div class="alert">{{ response.answer }}</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% if buttons %}
|
{% if buttons %}
|
||||||
|
<div class="row">
|
||||||
{% if perms.auth.human_resources %}
|
{% if perms.auth.human_resources %}
|
||||||
<div class="panel panel-primary">
|
<div class="panel panel-primary">
|
||||||
<div class="panel-heading">Actions</div>
|
<div class="panel-heading">Actions</div>
|
||||||
@ -83,6 +122,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user