mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-10 04:50:16 +02:00
Rewrote views to handle new models.
Everything works but comments.
This commit is contained in:
parent
99879e797b
commit
477e579eba
@ -64,7 +64,9 @@ urlpatterns = patterns('',
|
||||
# HR Application Management
|
||||
url(r'^hr_application_management/', 'hrapplications.views.hr_application_management_view',
|
||||
name="auth_hrapplications_view"),
|
||||
url(r'^hr_application_create/', 'hrapplications.views.hr_application_create_view',
|
||||
url(r'^hr_application_create/$', 'hrapplications.views.hr_application_create_view',
|
||||
name="auth_hrapplication_create_view"),
|
||||
url(r'^hr_application_create/(\d+)', 'hrapplications.views.hr_application_create_view',
|
||||
name="auth_hrapplication_create_view"),
|
||||
url(r'^hr_application_remove/(\w+)', 'hrapplications.views.hr_application_remove',
|
||||
name="auth_hrapplication_remove"),
|
||||
|
@ -1,31 +1,7 @@
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
|
||||
from eveonline.models import EveCorporationInfo
|
||||
|
||||
class HRApplicationForm(forms.Form):
|
||||
allchoices = []
|
||||
|
||||
if settings.IS_CORP:
|
||||
corp = EveCorporationInfo.objects.get(corporation_id=settings.CORP_ID)
|
||||
allchoices.append((str(corp.corporation_id), str(corp.corporation_name)))
|
||||
else:
|
||||
for corp in EveCorporationInfo.objects.all():
|
||||
if corp.alliance is not None:
|
||||
if corp.alliance.alliance_id == settings.ALLIANCE_ID:
|
||||
allchoices.append((str(corp.corporation_id), str(corp.corporation_name)))
|
||||
|
||||
character_name = forms.CharField(max_length=254, required=True, label="Main Character Name")
|
||||
corp = forms.ChoiceField(choices=allchoices, required=True, label="Corp")
|
||||
is_a_spi = forms.ChoiceField(choices=[('Yes', 'Yes'), ('No', 'No')], required=True, label='Are you a spy?')
|
||||
about = forms.CharField(widget=forms.Textarea, required=False, label="About You")
|
||||
extra = forms.CharField(widget=forms.Textarea, required=False, label="Extra Application Info")
|
||||
|
||||
|
||||
class HRApplicationCommentForm(forms.Form):
|
||||
app_id = forms.CharField(widget=forms.TextInput(attrs={'readonly': 'True'}))
|
||||
comment = forms.CharField(widget=forms.Textarea, required=False, label="Comment", max_length=254)
|
||||
|
||||
|
||||
class HRApplicationSearchForm(forms.Form):
|
||||
search_string = forms.CharField(max_length=254, required=True, label="Search String")
|
||||
|
@ -3,6 +3,8 @@ from django.contrib.auth.models import User
|
||||
|
||||
from eveonline.models import EveCharacter
|
||||
from eveonline.models import EveCorporationInfo
|
||||
from eveonline.models import EveApiKeyPair
|
||||
from authentication.models import AuthServicesInfo
|
||||
|
||||
class ApplicationQuestion(models.Model):
|
||||
title = models.CharField(max_length=100)
|
||||
@ -15,27 +17,57 @@ class ApplicationForm(models.Model):
|
||||
questions = models.ManyToManyField(ApplicationQuestion)
|
||||
corp = models.OneToOneField(EveCorporationInfo)
|
||||
|
||||
def __str__(self):
|
||||
return str(self.corp)
|
||||
|
||||
class Application(models.Model):
|
||||
form = models.OneToOneField(ApplicationForm, on_delete=models.CASCADE)
|
||||
form = models.OneToOneField(ApplicationForm, on_delete=models.CASCADE, related_name='applications')
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='applications')
|
||||
approved = models.NullBooleanField(blank=True, null=True, default=None)
|
||||
reveiwer = models.ForeignKey(User, on_delete=models.SET_NULL, blank=True, null=True)
|
||||
reveiwer_character = models.ForeignKey(EveCharacter, on_delete=models.SET_NULL, blank=True, null=True)
|
||||
reviewer = models.ForeignKey(User, on_delete=models.SET_NULL, blank=True, null=True)
|
||||
reviewer_character = models.ForeignKey(EveCharacter, on_delete=models.SET_NULL, blank=True, null=True)
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.user + " Application To " + self.corp
|
||||
return str(self.user) + " Application To " + str(self.form)
|
||||
|
||||
class Meta:
|
||||
permissions = (('approve_application', 'Can approve applications'), ('reject_application', 'Can reject applications'), ('view_apis', 'Can view applicant APIs'),)
|
||||
|
||||
@property
|
||||
def main_character(self):
|
||||
try:
|
||||
auth = AuthServicesInfo.objects.get(user=self.user)
|
||||
char = EveCharacter.objects.get(character_id=auth.main_char_id)
|
||||
return char
|
||||
except:
|
||||
return None
|
||||
|
||||
@property
|
||||
def characters(self):
|
||||
return EveCharacter.objects.filter(user=user)
|
||||
|
||||
@property
|
||||
def apis(self):
|
||||
return EveApiKeyPair.objects.filter(user=self.user)
|
||||
|
||||
@property
|
||||
def reviewer_str(self):
|
||||
if self.reviewer_character:
|
||||
return str(self.reviewer_character)
|
||||
elif self.reviewer:
|
||||
return "User " + str(self.reviewer)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
class ApplicationResponse(models.Model):
|
||||
question = models.ForeignKey(ApplicationQuestion, on_delete=models.CASCADE)
|
||||
application = models.ForeignKey(Application, on_delete=models.CASCADE)
|
||||
application = models.ForeignKey(Application, on_delete=models.CASCADE, related_name='responses')
|
||||
answer = models.TextField()
|
||||
|
||||
def __str__(self):
|
||||
return self.form + " Answer To " + self.question
|
||||
return str(self.application) + " Answer To " + str(self.question)
|
||||
|
||||
class Meta:
|
||||
unique_together = ('question', 'application')
|
||||
@ -47,7 +79,7 @@ class ApplicationComment(models.Model):
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.user + " comment on " + self.application
|
||||
return str(self.user) + " comment on " + str(self.application)
|
||||
|
||||
################
|
||||
# Legacy Models
|
||||
|
@ -1,12 +1,16 @@
|
||||
from django.template import RequestContext
|
||||
from django.shortcuts import render_to_response
|
||||
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 login_required
|
||||
from django.shortcuts import HttpResponseRedirect
|
||||
from notifications import notify
|
||||
from models import HRApplication
|
||||
from models import HRApplicationComment
|
||||
from forms import HRApplicationForm
|
||||
from models import ApplicationForm
|
||||
from models import Application
|
||||
from models import ApplicationQuestion
|
||||
from models import ApplicationResponse
|
||||
from models import ApplicationComment
|
||||
from forms import HRApplicationCommentForm
|
||||
from forms import HRApplicationSearchForm
|
||||
from eveonline.models import EveCorporationInfo
|
||||
@ -23,202 +27,157 @@ logger = logging.getLogger(__name__)
|
||||
@login_required
|
||||
def hr_application_management_view(request):
|
||||
logger.debug("hr_application_management_view called by user %s" % request.user)
|
||||
personal_app = None
|
||||
corp_applications = None
|
||||
|
||||
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:
|
||||
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))
|
||||
|
||||
corp_applications = Application.objects.filter(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():
|
||||
corp_applications = ApplicationForm.objects.get(corp__corporation_id=main_char.corporation_id).applications.filter(approved=None)
|
||||
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,
|
||||
'search_form': HRApplicationSearchForm()}
|
||||
return render_to_response('registered/hrapplicationmanagement.html', context, context_instance=RequestContext(request))
|
||||
|
||||
@login_required
|
||||
def hr_application_create_view(request):
|
||||
logger.debug("hr_application_create_view called by user %s" % request.user)
|
||||
success = False
|
||||
|
||||
if request.method == 'POST':
|
||||
form = HRApplicationForm(request.POST)
|
||||
logger.debug("Request type POST with form valid: %s" % form.is_valid())
|
||||
if form.is_valid():
|
||||
application = HRApplication()
|
||||
application.user = request.user
|
||||
application.character_name = form.cleaned_data['character_name']
|
||||
application.corp = EveCorporationInfo.objects.get(corporation_id=form.cleaned_data['corp'])
|
||||
application.is_a_spi = form.cleaned_data['is_a_spi']
|
||||
application.about = form.cleaned_data['about']
|
||||
application.extra = form.cleaned_data['extra']
|
||||
application.save()
|
||||
success = True
|
||||
logger.info("Created HRApplication for user %s to corp %s" % (request.user, application.corp))
|
||||
def hr_application_create_view(request, form_id=None):
|
||||
if form_id:
|
||||
app_form = get_object_or_404(ApplicationForm, id=form_id)
|
||||
if request.method == "POST":
|
||||
if Application.objects.filter(user=request.user).filter(form=app_form).exists():
|
||||
logger.warn("User %s attempting to duplicate application to %s" % (request.user, app_form.corp))
|
||||
else:
|
||||
application = Application(user=request.user, form=app_form)
|
||||
application.save()
|
||||
for question in app_form.questions.all():
|
||||
response = ApplicationResponse(question=question, application=application)
|
||||
response.answer = request.POST.get(str(question.pk), "Failed to retrieve answer provided by applicant.")
|
||||
response.save()
|
||||
logger.info("%s created %s" % (request.user, application))
|
||||
return redirect('auth_hrapplications_view')
|
||||
else:
|
||||
questions = app_form.questions.all()
|
||||
return render_to_response('registered/hrapplicationcreate.html', {'questions':questions, 'corp':app_form.corp}, context_instance=RequestContext(request))
|
||||
else:
|
||||
logger.debug("Providing empty form.")
|
||||
form = HRApplicationForm()
|
||||
|
||||
context = {'form': form, 'success': success}
|
||||
return render_to_response('registered/hrcreateapplication.html',
|
||||
context, context_instance=RequestContext(request))
|
||||
|
||||
choices = []
|
||||
for app_form in ApplicationForm.objects.all():
|
||||
if not Application.objects.filter(user=request.user).filter(form=app_form).exists():
|
||||
choices.append((app_form.id, app_form.corp.corporation_name))
|
||||
return render_to_response('registered/hrapplicationcorpchoice.html', {'choices':choices}, context_instance=RequestContext(request))
|
||||
|
||||
@login_required
|
||||
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))
|
||||
if HRApplication.objects.filter(id=app_id).exists():
|
||||
application = HRApplication.objects.get(id=app_id)
|
||||
logger.debug("Got application id %s: %s" % (app_id, application))
|
||||
if application.user != request.user:
|
||||
logger.warn("HRApplication id %s user %s does not match request user %s - returning blank application." % (app_id, application.user, request.user))
|
||||
application = HRApplication()
|
||||
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),
|
||||
'form': None,
|
||||
'apis': [],
|
||||
}
|
||||
return render_to_response('registered/hrapplicationview.html', context, context_instance=RequestContext(request))
|
||||
else:
|
||||
logger.error("Unable to locate HRApplication matching id %s - returning blank application to user %s" % (app_id, request.user))
|
||||
application = HRApplication()
|
||||
apis = request.user.eveapikeypair_set.all()
|
||||
context = {
|
||||
'application': application,
|
||||
'apis': apis,
|
||||
}
|
||||
return render_to_response('registered/hrapplicationview.html',
|
||||
context, context_instance=RequestContext(request))
|
||||
|
||||
logger.warn("User %s not authorized to view %s" % (request.user, app))
|
||||
return redirect('auth_hrapplications_view')
|
||||
|
||||
|
||||
@login_required
|
||||
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))
|
||||
if HRApplication.objects.filter(id=app_id).exists():
|
||||
application = HRApplication.objects.get(id=app_id)
|
||||
if application.user == request.user:
|
||||
application.delete()
|
||||
logger.info("Deleted HRApplication with id %s for user %s to corp %s" % (app_id, request.user, application.corp))
|
||||
else:
|
||||
logger.error("HRapplication id %s user %s does not match request user %s - refusing to delete." % (app_id, application.user, request.user))
|
||||
return HttpResponseRedirect("/hr_application_management/")
|
||||
|
||||
app = get_object_or_404(Application, pk=app_id)
|
||||
if app.user == request.user:
|
||||
logger.info("User %s deleting %s" % (request.user, app))
|
||||
app.delete()
|
||||
else:
|
||||
logger.warn("User %s not authorized to delete %s" % (request.user, app))
|
||||
return redirect('auth_hrapplications_view')
|
||||
|
||||
@login_required
|
||||
@permission_required('auth.human_resources')
|
||||
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_hrapplicationcomment'):
|
||||
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():
|
||||
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 = ApplicationComment()
|
||||
comment.application = app
|
||||
comment.user = request.user
|
||||
comment.text = form.cleaned_data['comment']
|
||||
comment.save()
|
||||
logger.info("Saved comment by user %s to hrapplication %s" % (request.user, comment.application))
|
||||
logger.info("Saved comment by user %s to %s" % (request.user, app))
|
||||
else:
|
||||
logger.warn("User %s does not have permission to add HRApplicationComments" % request.user)
|
||||
logger.warn("User %s does not have permission to add ApplicationComments" % request.user)
|
||||
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)
|
||||
|
||||
apis = []
|
||||
if request.user.has_perm('hrapplications.view_apis'):
|
||||
apis = app.user.eveapikeypair_set.all()
|
||||
context = {
|
||||
'application': application,
|
||||
'comments': comments,
|
||||
'comment_form': form,
|
||||
'apis': application.user.eveapikeypair_set.all(),
|
||||
}
|
||||
'app': app,
|
||||
'responses': ApplicationResponse.objects.filter(application=app),
|
||||
'buttons': True,
|
||||
'apis': app.apis,
|
||||
'comments': ApplicationComment.objects.filter(application=app),
|
||||
'form': form,
|
||||
}
|
||||
return render_to_response('registered/hrapplicationview.html', context, context_instance=RequestContext(request))
|
||||
|
||||
return render_to_response('registered/hrapplicationview.html',
|
||||
context, context_instance=RequestContext(request))
|
||||
|
||||
@login_required
|
||||
@permission_required('auth.human_resources')
|
||||
@permission_required('hrapplications.delete_hrapplication')
|
||||
@permission_required('hrapplications.delete_application')
|
||||
def hr_application_remove(request, app_id):
|
||||
logger.debug("hr_application_remove called by user %s for app id %s" % (request.user, app_id))
|
||||
if HRApplication.objects.filter(id=app_id).exists():
|
||||
application = HRApplication.objects.get(id=app_id)
|
||||
if application:
|
||||
logger.info("Deleted HRApplication id %s on behalf of user %s" % (app_id, request.user))
|
||||
notify(application.user, "Application Deleted", message="Your application to %s was deleted.")
|
||||
application.delete()
|
||||
else:
|
||||
logger.error("Unable to delete HRApplication with id %s on behalf of user %s: application is NoneType" % (app_id, request.user))
|
||||
else:
|
||||
logger.error("Unable to delete HRApplication with id %s on behalf of user %s: application not found." % (app_id, request.user))
|
||||
|
||||
return HttpResponseRedirect("/hr_application_management/")
|
||||
|
||||
app = get_object_or_404(Application, pk=app_id)
|
||||
logger.info("User %s deleting %s" % (request.user, app))
|
||||
app.delete()
|
||||
notify(app.user, "Application Deleted", message="Your application to %s was deleted." % app.form.corp)
|
||||
return redirect('auth_hrapplications_view')
|
||||
|
||||
@login_required
|
||||
@permission_required('auth.human_resources')
|
||||
@permission_required('hrapplications.approve_hrapplication')
|
||||
@permission_required('hrapplications.approve_application')
|
||||
def hr_application_approve(request, app_id):
|
||||
logger.debug("hr_application_approve called by user %s for app id %s" % (request.user, app_id))
|
||||
if HRApplication.objects.filter(id=app_id).exists():
|
||||
auth_info = AuthServicesInfo.objects.get(user=request.user)
|
||||
application = HRApplication.objects.get(id=app_id)
|
||||
application.approved_denied = True
|
||||
application.reviewer_user = request.user
|
||||
application.reviewer_character = EveCharacter.objects.get(character_id=auth_info.main_char_id)
|
||||
application.save()
|
||||
logger.info("HRApplication for user %s to corp %s approved by %s" % (application.user, application.corp, request.user))
|
||||
notify(application.user, "Application Accepted", message="Your application to %s has been approved." % application.corp, level="success")
|
||||
app = get_object_or_404(Application, pk=app_id)
|
||||
if request.user.is_superuser or request.user == app.reviewer:
|
||||
logger.info("User %s approving %s" % (request.user, app))
|
||||
app.approved = True
|
||||
app.save()
|
||||
notify(app.user, "Application Accepted", message="Your application to %s has been approved." % app.form.corp, level="success")
|
||||
else:
|
||||
logger.error("User %s unable to approve HRApplication id %s - hrapplication with that id not found." % (request.user, app_id))
|
||||
|
||||
return HttpResponseRedirect("/hr_application_management/")
|
||||
|
||||
logger.warn("User %s not authorized to approve %s" % (request.user, app))
|
||||
return redirect('auth_hrapplications_view')
|
||||
|
||||
@login_required
|
||||
@permission_required('auth.human_resources')
|
||||
@permission_required('hrapplications.reject_hrapplication')
|
||||
@permission_required('hrapplications.reject_application')
|
||||
def hr_application_reject(request, app_id):
|
||||
logger.debug("hr_application_reject called by user %s for app id %s" % (request.user, app_id))
|
||||
if HRApplication.objects.filter(id=app_id).exists():
|
||||
auth_info = AuthServicesInfo.objects.get(user=request.user)
|
||||
application = HRApplication.objects.get(id=app_id)
|
||||
application.approved_denied = False
|
||||
application.reviewer_user = request.user
|
||||
application.reviewer_character = EveCharacter.objects.get(character_id=auth_info.main_char_id)
|
||||
application.save()
|
||||
logger.info("HRApplication for user %s to corp %s rejected by %s" % (application.user, application.corp, request.user))
|
||||
notify(application.user, "Application Rejected", message="Your application to %s has been rejected." % application.corp, level="danger")
|
||||
app = get_object_or_404(Application, pk=app_id)
|
||||
if request.user.is_superuser or request.user == app.reviewer:
|
||||
logger.info("User %s rejecting %s" % (request.user, app))
|
||||
app.approved = False
|
||||
app.save()
|
||||
notify(app.user, "Application Rejected", message="Your application to %s has been rejected." % app.form.corp, level="danger")
|
||||
else:
|
||||
logger.error("User %s unable to reject HRApplication id %s - hrapplication with that id not found." % (request.user, app_id))
|
||||
|
||||
return HttpResponseRedirect("/hr_application_management/")
|
||||
|
||||
logger.warn("User %s not authorized to reject %s" % (request.user, app))
|
||||
return redirect('auth_hrapplications_view')
|
||||
|
||||
@login_required
|
||||
@permission_required('auth.human_resources')
|
||||
@ -231,13 +190,16 @@ def hr_application_search(request):
|
||||
# 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 = []
|
||||
applications = set([])
|
||||
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))
|
||||
for application in Application.objects.all():
|
||||
if application.main_character:
|
||||
if searchstring in application.main_character.character_name:
|
||||
applications.add(application)
|
||||
if searchstring in application.user.username:
|
||||
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()}
|
||||
|
||||
@ -253,19 +215,23 @@ def hr_application_search(request):
|
||||
logger.debug("Returning empty search form for user %s" % request.user)
|
||||
return HttpResponseRedirect("/hr_application_management/")
|
||||
|
||||
|
||||
@login_required
|
||||
@permission_required('auth.human_resources')
|
||||
def hr_application_mark_in_progress(request, app_id):
|
||||
logger.debug("hr_application_mark_in_progress called by user %s for app id %s" % (request.user, app_id))
|
||||
if HRApplication.objects.filter(id=app_id).exists():
|
||||
app = get_object_or_404(Application, pk=app_id)
|
||||
if not app.reviewer:
|
||||
logger.info("User %s marking %s in progress" % (request.user, app))
|
||||
auth_info = AuthServicesInfo.objects.get(user=request.user)
|
||||
application = HRApplication.objects.get(id=app_id)
|
||||
application.reviewer_inprogress_character = EveCharacter.objects.get(character_id=auth_info.main_char_id)
|
||||
application.save()
|
||||
logger.info("Marked HRApplication for user %s to corp %s in progress by user %s" % (application.user, application.corp, request.user))
|
||||
notify(application.user, "Application In Progress", message="Your application to %s is being reviewed by %s" % (application.corp, application.reviewer_inprogress_character))
|
||||
try:
|
||||
character = EveCharacter.objects.get(character_id=auth_info.main_char_id)
|
||||
except:
|
||||
logger.warn("User %s marking %s in review has no main character" % (request.user, app))
|
||||
character = None
|
||||
app.reviewer = request.user
|
||||
app.reviewer_character = character
|
||||
app.save()
|
||||
notify(app.user, "Application In Progress", message="Your application to %s is being reviewed by %s" % (app.form.corp, app.reviewer_str))
|
||||
else:
|
||||
logger.error("Unable to mark HRApplication id %s in progress by user %s - hrapplication matching id not found." % (app_id, request.user))
|
||||
|
||||
logger.warn("User %s unable to mark %s in progress: already being reviewed by %s" % (request.user, app, app.reviewer))
|
||||
return HttpResponseRedirect("/hr_application_view/" + str(app_id))
|
||||
|
25
stock/templates/registered/hrapplicationcorpchoice.html
Normal file
25
stock/templates/registered/hrapplicationcorpchoice.html
Normal file
@ -0,0 +1,25 @@
|
||||
{% extends "public/base.html" %}
|
||||
{% load staticfiles %}
|
||||
{% block title %}Choose a Corp{% endblock %}
|
||||
{% block page_title %}Choose a Corp{% endblock page_title %}
|
||||
{% block content %}
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header text-center">Choose a Corp</h1>
|
||||
{% if choices %}
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">Available Corps</div>
|
||||
<table class="table table-responsive">
|
||||
{% for choice in choices %}
|
||||
<tr>
|
||||
<td class="text-center">
|
||||
<a href="{% url 'auth_hrapplication_create_view' choice.0 %}" class="btn btn-primary" title="Apply">{{ choice.1 }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="alert alert-danger">No corps are accepting applications at this time.</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock content %}
|
30
stock/templates/registered/hrapplicationcreate.html
Normal file
30
stock/templates/registered/hrapplicationcreate.html
Normal file
@ -0,0 +1,30 @@
|
||||
{% extends "public/base.html" %}
|
||||
{% load staticfiles %}
|
||||
{% block page_title %}Apply To {{ corp.corporation_name }}{% endblock page_title %}
|
||||
{% block content %}
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header text-center">Apply To {{ corp.corporation_name }}</h1>
|
||||
<div class="container-fluid">
|
||||
<div class="col-md-4 col-md-offset-4">
|
||||
<div class="row">
|
||||
<form class="form-signin">
|
||||
{% csrf_token %}
|
||||
{% for question in questions %}
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="id_{{ question.pk }}">{{ question.title }}</label>
|
||||
<div class=" ">
|
||||
{% if question.help_text %}
|
||||
<div cass="text-center">{{ question.extra_text }}</div>
|
||||
{% endif %}
|
||||
<textarea class="form-control" cols="40" id="id_{{ question.pk }}" name="{{ question.pk }}" rows="10"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit" formmethod="post">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@ -24,7 +24,6 @@
|
||||
<table class="table table-bordered table-condensed">
|
||||
<tr>
|
||||
<th class="text-center">Username</th>
|
||||
<th class="text-center">Main Character</th>
|
||||
<th class="text-center">Corporation
|
||||
<th class="text-center">Status</th>
|
||||
<th class="text-center">Actions</th>
|
||||
@ -32,15 +31,14 @@
|
||||
{% for personal_app in personal_apps %}
|
||||
<tr>
|
||||
<td class="text-center">{{ personal_app.user.username }}</td>
|
||||
<td class="text-center">{{ personal_app.character_name }}</td>
|
||||
<td class="text-center">{{ personal_app.corp.corporation_name }}</td>
|
||||
<td class="text-center">{{ personal_app.form.corp.corporation_name }}</td>
|
||||
<td class="text-center">
|
||||
{% if personal_app.approved_denied == None %}
|
||||
<div class="panel panel-warning" role="alert">Pending</div>
|
||||
{% elif personal_app.approved_denied == True %}
|
||||
<div class="panel panel-success" role="alert">Approved</div>
|
||||
{% if personal_app.approved == None %}
|
||||
<div class="label label-warning">Pending</div>
|
||||
{% elif personal_app.approved == True %}
|
||||
<div class="label label-success">Approved</div>
|
||||
{% else %}
|
||||
<div class="panel panel-danger" role="alert">Rejected</div>
|
||||
<div class="label label-danger">Rejected</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
@ -83,8 +81,8 @@
|
||||
<tr>
|
||||
<td class="text-center">{{ app.id }}</td>
|
||||
<td class="text-center">{{ app.user.username }}</td>
|
||||
<td class="text-center">{{ app.character_name }}</td>
|
||||
<td class="text-center">{{ app.corp.corporation_name }}</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 %}
|
||||
<div class="panel panel-warning" role="alert">Pending</div>
|
||||
|
@ -31,16 +31,16 @@
|
||||
{% for app in applications %}
|
||||
<tr>
|
||||
<td class="text-center">{{ app.id }}</td>
|
||||
<td class="text-center">{{ app.user.username }}</td>
|
||||
<td class="text-center">{{ app.character_name }}</td>
|
||||
<td class="text-center">{{ app.corp.corporation_name }}</td>
|
||||
<td class="text-center">{{ app.user }}</td>
|
||||
<td class="text-center">{{ app.main_character }}</td>
|
||||
<td class="text-center">{{ app.form.corp }}</td>
|
||||
<td class="text-center">
|
||||
{% if app.approved_denied == None %}
|
||||
<div class="panel panel-warning" role="alert">Pending</div>
|
||||
{% elif app.approved_denied == True %}
|
||||
<div class="panel panel-success" role="alert">Approved</div>
|
||||
{% if app.approved == None %}
|
||||
<div class="label label-warning">Pending</div>
|
||||
{% elif app.approved == True %}
|
||||
<div class="label label-success">Approved</div>
|
||||
{% else %}
|
||||
<div class="panel panel-danger" role="alert">Rejected</div>
|
||||
<div class="label label-danger">Rejected</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
|
312
stock/templates/registered/hrapplicationview.html
Executable file → Normal file
312
stock/templates/registered/hrapplicationview.html
Executable file → Normal file
@ -1,239 +1,109 @@
|
||||
{% extends "public/base.html" %}
|
||||
{% load bootstrap %}
|
||||
{% load staticfiles %}
|
||||
|
||||
{% load bootstrap %}
|
||||
{% block title %}Alliance Auth - View Application{% endblock %}
|
||||
|
||||
{% block page_title %}View Application{% endblock page_title %}
|
||||
{% block extra_css %}{% endblock extra_css %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header text-center">View Application</h1>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="col-md-4 col-md-offset-4">
|
||||
<div class="row">
|
||||
<form class="form-signin">
|
||||
<div class="form-group">
|
||||
<label class="control-label " for="id_extra">Status</label>
|
||||
|
||||
<div class=" ">
|
||||
{% if application.approved_denied == None %}
|
||||
<div class="alert alert-warning" role="alert">Pending</div>
|
||||
{% elif application.approved_denied %}
|
||||
<div class="alert alert-success" role="alert">Approved</div>
|
||||
{% else %}
|
||||
<div class="alert alert-danger" role="alert">Rejected</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if app.approved %}
|
||||
<div class="alert alert-success">Approved</div>
|
||||
{% elif app.approved == False %}
|
||||
<div class="alert alert-danger">Denied</div>
|
||||
{% else %}
|
||||
<div class="alert alert-warning">Pending</div>
|
||||
{% endif %}
|
||||
{% if app.reviewer_str %}
|
||||
<div class="alert alert-info">Reviewer: {{ app.reviewer_str }}</div>
|
||||
{% endif %}
|
||||
{% for response in responses %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">{{ response.question.title }}</div>
|
||||
<div class="alert">{{ response.answer }}</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label " for="id_extra">Reviewer</label>
|
||||
|
||||
<div class=" ">
|
||||
{% if application.reviewer_inprogress_character == None %}
|
||||
<div class="alert alert-info" role="alert">pending</div>
|
||||
{% else %}
|
||||
<div class="alert alert-info"
|
||||
role="alert">{{ application.reviewer_inprogress_character.character_name }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="id_character_name">User Account</label>
|
||||
|
||||
<div class=" ">
|
||||
<input class=" form-control" value="{{ application.user.username }}" disabled>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="id_character_name">Main Character Name</label>
|
||||
|
||||
<div class=" ">
|
||||
<input class=" form-control" value="{{ application.character_name }}" disabled>
|
||||
</div>
|
||||
</div>
|
||||
{% if perms.hrapplications.view_apis %}
|
||||
{% for api in apis %}
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="id_full_api_id">API ID</label>
|
||||
|
||||
<div class=" ">
|
||||
<input class=" form-control" value="{{ api.api_id }}" disabled>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label " for="id_full_api_key">API Verification Code</label>
|
||||
|
||||
<div class=" ">
|
||||
<input class=" form-control" value="{{ api.api_key }}" disabled>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<div class="form-group">
|
||||
<label class="control-label " for="id_corp">Corp</label>
|
||||
|
||||
<div class=" ">
|
||||
<select class=" form-control" id="id_corp" name="corp" disabled>
|
||||
<option value="98076553">{{ application.corp.corporation_name }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label " for="id_is_a_spi">Is a spy</label>
|
||||
|
||||
<div class=" ">
|
||||
<select class=" form-control" id="id_is_a_spi" name="is_a_spi" disabled>
|
||||
<option value="">{{ application.is_a_spi }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label " for="id_about">About</label>
|
||||
|
||||
<div class=" ">
|
||||
<textarea class=" form-control" cols="40" id="id_about" name="about" rows="10"
|
||||
disabled>{{ application.about }}</textarea>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label " for="id_extra">Extra Application Info</label>
|
||||
|
||||
<div class=" ">
|
||||
<textarea class=" form-control" cols="40" id="id_extra" name="extra" rows="10"
|
||||
disabled>{{ application.extra }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if perms.auth.human_resources %}
|
||||
<div class="form-group text-center">
|
||||
<label class="control-label text-center" for="id_extra">Actions</label>
|
||||
|
||||
<div class="container-fluid well">
|
||||
|
||||
<div class="row text-center">
|
||||
{% if application.reviewer_inprogress_character != None %}
|
||||
{% if perms.hrapplications.approve_hrapplication %}
|
||||
<a href="/hr_application_approve/{{ application.id }}">
|
||||
<button type="button" class="btn btn-lg btn-success">Approve</button>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if perms.hrapplications.reject_hrapplication %}
|
||||
<a href="/hr_application_reject/{{ application.id }}">
|
||||
<button type="button" class="btn btn-lg btn-info">Reject</button>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if perms.hrapplications.delete_hrapplication %}
|
||||
<a href="/hr_application_remove/{{ application.id }}">
|
||||
<button type="button" class="btn btn-lg btn-danger">Delete</button>
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
<a href="/hr_mark_in_progress/{{ application.id }}">
|
||||
<button type="button" class="btn btn-lg btn-warning">Mark In Progress
|
||||
</button>
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
<div class="row text-center">
|
||||
{% if perms.hrapplications.view_apis %}
|
||||
{% for api in apis %}
|
||||
<a href="{{ JACK_KNIFE_URL }}?usid={{ api.api_id }}&apik={{ api.api_key }}"
|
||||
target="_blank">
|
||||
<button type="button" class="btn btn-lg btn-primary">API {{ api.api_id }}</button>
|
||||
</a>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if perms.hrapplications.add_hrapplicationcomment %}
|
||||
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal"
|
||||
data-target="#myModal">
|
||||
Comment
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading" role="tab" id="headingThree">
|
||||
<h4 class="panel-title">
|
||||
<a class="collapsed" data-toggle="collapse" data-parent="#accordion"
|
||||
href="#collapseThree" aria-expanded="false"
|
||||
aria-controls="collapseThree">
|
||||
Comments - {{ comments|length }}
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
<div id="collapseThree" class="panel-collapse collapse" role="tabpanel"
|
||||
aria-labelledby="headingThree">
|
||||
<div class="panel-body">
|
||||
{% for comment in comments %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading" role="tab" id="">
|
||||
<div class="panel-title">{{comment.created_on}} - {{ comment.commenter_character.character_name }}
|
||||
- {{ comment.commenter_character.corporation_name }}</div>
|
||||
</div>
|
||||
<div class="panel-body">{{ comment.comment }}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</form>
|
||||
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{% if buttons %}
|
||||
{% if perms.auth.human_resources %}
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">Actions</div>
|
||||
{% if app.approved == None %}
|
||||
{% if app.reviewer == user %}
|
||||
{% if perms.hrapplications.approve_application %}
|
||||
<a href="/hr_application_approve/{{ app.id }}" class="btn btn-success">Approve</a>
|
||||
{% endif %}
|
||||
{% if perms.hrapplications.reject_application %}
|
||||
<a href="/hr_application_reject/{{ app.id }}" class="btn btn-danger">Reject</a>
|
||||
{% endif %}
|
||||
{% if perms.hrapplications.delete_application %}
|
||||
<a href="/hr_application_remove/{{ app.id }}" class="btn btn-danger">Delete</a>
|
||||
{% endif %}
|
||||
{% elif not app.reviewer %}
|
||||
<a href="/hr_mark_in_progress/{{ app.id }}" class="btn btn-warning">Mark in Progress</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if perms.hrapplications.view_apis %}
|
||||
{% for api in apis %}
|
||||
<a href="{{ JACK_KNIFE_URL }}?usid={{ api.api_id}}&apik={{ api.api_key }}" class="btn btn-info">API {{ api.api_id }}</a>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading" role="tab" id="headingThree">
|
||||
<h4 class="panel-title">
|
||||
<a class="collapsed" data-toggle="collapse" data-parent="#accordion"
|
||||
href="#collapseThree" aria-expanded="false"
|
||||
aria-controls="collapseThree">
|
||||
Comments - {{ comments|length }}
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
<div id="collapseThree" class="panel-collapse collapse" role="tabpanel"
|
||||
aria-labelledby="headingThree">
|
||||
<div class="panel-body">
|
||||
{% for comment in comments %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading" role="tab" id="">
|
||||
<div class="panel-title">{{comment.created_on}} - {{ comment.user }}</div>
|
||||
</div>
|
||||
<div class="panel-body">{{ comment.comment }}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><span
|
||||
aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
||||
<h4 class="modal-title" id="myModalLabel">Add Comment</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="form-signin" role="form" action="" method="POST">
|
||||
{% csrf_token %}
|
||||
{{ form|bootstrap }}
|
||||
<br/>
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit">Add Comment</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if perms.auth.human_resources %}
|
||||
{% if perms.hrapplications.add_hrapplicationcomment %}
|
||||
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><span
|
||||
aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
||||
<h4 class="modal-title" id="myModalLabel">Add Comment</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="form-signin" role="form" action="" method="POST">
|
||||
{% csrf_token %}
|
||||
{{ comment_form.app_id|bootstrap }}
|
||||
{{ comment_form.comment|bootstrap }}
|
||||
<br/>
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit">Add Comment</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endblock content %}
|
||||
{% block extra_script %}
|
||||
$(document).ready(function(){
|
||||
var appid = {{ application.id }};
|
||||
|
||||
$('#id_app_id').val(appid);
|
||||
$('#id_commenter_id').val(commenterid);
|
||||
});
|
||||
{% endblock %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user