mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2026-02-07 15:46:20 +01:00
Adarnof's Little Things (#547)
* Port to Django 1.10 Initial migrations for current states of all models. Requires faking to retain data. Removed all references to render_to_response, replacing with render shortcut. Same for HttpResponseRedirect to render shortcut. Corrected notification signal import to wait for app registry to finish loading. * Correct typos from render conversion * Modify models to suppress Django field warnings * Script for automatic database conversion - fakes initial migrations to preserve data Include LOGIN_URL setting * Correct context processor import typo * Removed pathfinder support. Current pathfinder versions require SSO, not APIs added to database. Conditionally load additional database definitions only if services are enabled. Prevents errors when running auth without creating all possible databases. * Condense context processors * Include Django 1.10 installation in migrate script Remove syncdb/evolve, replace with migrate for update script * Replaced member/blue perms with user state system Removed sigtracker Initial migrations for default perms and groups Removed perm bootstrapping on first run * Clean up services list * Remove fleet fittings page * Provide action feedback via django messaging Display unread notification count Correct left navbar alignment * Stop storing service passwords. Provide them one time upon activation or reset. Closes #177 * Add group sync buttons to admin site Allow searcing of AuthServicesInfo models Display user main character * Correct button CSS to remove underlines on hover * Added bulk actions to notifications Altered notification default ordering * Centralize API key validation. Remove unused error count on API key model. Restructure API key refresh task to queue all keys per user and await completion. Closes #350 * Example configuration files for supervisor. Copy to /etc/supervisor/conf.d and restart to take effect. Closes #521 Closes #266 * Pre-save receiver for member/blue state switching Removed is_blue field Added link to admin site * Remove all hardcoded URLs from views and templates Correct missing render arguments Closes #540 * Correct celeryd process directory * Migration to automatically set user states. Runs instead of waiting for next API refresh cycle. Should make the transition much easier. * Verify service accounts accessible to member state * Restructure project to remove unnecessary apps. (celerytask, util, portal, registraion apps) Added workarounds for python 3 compatibility. * Correct python2 compatibility * Check services against state being changed to * Python3 compatibility fixes * Relocate x2bool py3 fix * SSO integration for logging in to existing accounts. * Add missing url names for fleetup reverse * Sanitize groupnames before syncing. * Correct trailing slash preventing url resolution * Alter group name sanitization to allow periods and hyphens * Correct state check on pre_save model for corp/alliance group assignment * Remove sigtracker table from old dbs to allow user deletion * Include missing celery configuration * Teamspeak error handling * Prevent celery worker deadlock on async group result wait * Correct active navbar links for translated urls. Correct corp status url resolution for some links. Remove DiscordAuthToken model.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
from __future__ import unicode_literals
|
||||
from django.contrib import admin
|
||||
|
||||
from models import Application
|
||||
from models import ApplicationQuestion
|
||||
from models import ApplicationForm
|
||||
from models import ApplicationResponse
|
||||
from models import ApplicationComment
|
||||
from hrapplications.models import Application
|
||||
from hrapplications.models import ApplicationQuestion
|
||||
from hrapplications.models import ApplicationForm
|
||||
from hrapplications.models import ApplicationResponse
|
||||
from hrapplications.models import ApplicationComment
|
||||
|
||||
admin.site.register(Application)
|
||||
admin.site.register(ApplicationComment)
|
||||
|
||||
7
hrapplications/apps.py
Normal file
7
hrapplications/apps.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class HRApplicationsConfig(AppConfig):
|
||||
name = 'hrapplications'
|
||||
@@ -1,8 +1,11 @@
|
||||
from __future__ import unicode_literals
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
||||
class HRApplicationCommentForm(forms.Form):
|
||||
comment = forms.CharField(widget=forms.Textarea, required=False, label=_("Comment"))
|
||||
|
||||
|
||||
class HRApplicationSearchForm(forms.Form):
|
||||
search_string = forms.CharField(max_length=254, required=True, label=_("Search String"))
|
||||
|
||||
127
hrapplications/migrations/0001_initial.py
Normal file
127
hrapplications/migrations/0001_initial.py
Normal file
@@ -0,0 +1,127 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.1 on 2016-09-05 21:39
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('eveonline', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Application',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('approved', models.NullBooleanField(default=None)),
|
||||
('created', models.DateTimeField(auto_now_add=True)),
|
||||
],
|
||||
options={
|
||||
'permissions': (('approve_application', 'Can approve applications'), ('reject_application', 'Can reject applications'), ('view_apis', 'Can view applicant APIs')),
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ApplicationComment',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('text', models.TextField()),
|
||||
('created', models.DateTimeField(auto_now_add=True)),
|
||||
('application', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments', to='hrapplications.Application')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ApplicationForm',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('corp', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='eveonline.EveCorporationInfo')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ApplicationQuestion',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('title', models.CharField(max_length=254)),
|
||||
('help_text', models.CharField(blank=True, max_length=254, null=True)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ApplicationResponse',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('answer', models.TextField()),
|
||||
('application', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='responses', to='hrapplications.Application')),
|
||||
('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='hrapplications.ApplicationQuestion')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='HRApplication',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('character_name', models.CharField(default=b'', max_length=254)),
|
||||
('full_api_id', models.CharField(default=b'', max_length=254)),
|
||||
('full_api_key', models.CharField(default=b'', max_length=254)),
|
||||
('is_a_spi', models.CharField(default=b'', max_length=254)),
|
||||
('about', models.TextField(default=b'')),
|
||||
('extra', models.TextField(default=b'')),
|
||||
('approved_denied', models.NullBooleanField()),
|
||||
('corp', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='eveonline.EveCorporationInfo')),
|
||||
('reviewer_character', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='eveonline.EveCharacter')),
|
||||
('reviewer_inprogress_character', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='inprogress_character', to='eveonline.EveCharacter')),
|
||||
('reviewer_user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='review_user', to=settings.AUTH_USER_MODEL)),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='HRApplicationComment',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('created_on', models.DateTimeField(auto_now_add=True, null=True)),
|
||||
('comment', models.CharField(default=b'', max_length=254)),
|
||||
('application', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='hrapplications.HRApplication')),
|
||||
('commenter_character', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='eveonline.EveCharacter')),
|
||||
('commenter_user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='applicationform',
|
||||
name='questions',
|
||||
field=models.ManyToManyField(to='hrapplications.ApplicationQuestion'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='application',
|
||||
name='form',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='applications', to='hrapplications.ApplicationForm'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='application',
|
||||
name='reviewer',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='application',
|
||||
name='reviewer_character',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='eveonline.EveCharacter'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='application',
|
||||
name='user',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='applications', to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='applicationresponse',
|
||||
unique_together=set([('question', 'application')]),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='application',
|
||||
unique_together=set([('form', 'user')]),
|
||||
),
|
||||
]
|
||||
0
hrapplications/migrations/__init__.py
Normal file
0
hrapplications/migrations/__init__.py
Normal file
@@ -1,3 +1,5 @@
|
||||
from __future__ import unicode_literals
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
@@ -6,6 +8,8 @@ from eveonline.models import EveCorporationInfo
|
||||
from eveonline.models import EveApiKeyPair
|
||||
from authentication.models import AuthServicesInfo
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class ApplicationQuestion(models.Model):
|
||||
title = models.CharField(max_length=254)
|
||||
help_text = models.CharField(max_length=254, blank=True, null=True)
|
||||
@@ -13,6 +17,8 @@ class ApplicationQuestion(models.Model):
|
||||
def __str__(self):
|
||||
return "Question: " + self.title.encode('utf-8')
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class ApplicationForm(models.Model):
|
||||
questions = models.ManyToManyField(ApplicationQuestion)
|
||||
corp = models.OneToOneField(EveCorporationInfo)
|
||||
@@ -20,6 +26,8 @@ class ApplicationForm(models.Model):
|
||||
def __str__(self):
|
||||
return str(self.corp)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Application(models.Model):
|
||||
form = models.ForeignKey(ApplicationForm, on_delete=models.CASCADE, related_name='applications')
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='applications')
|
||||
@@ -32,7 +40,9 @@ class Application(models.Model):
|
||||
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'),)
|
||||
permissions = (
|
||||
('approve_application', 'Can approve applications'), ('reject_application', 'Can reject applications'),
|
||||
('view_apis', 'Can view applicant APIs'),)
|
||||
unique_together = ('form', 'user')
|
||||
|
||||
@property
|
||||
@@ -62,6 +72,7 @@ class Application(models.Model):
|
||||
return None
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class ApplicationResponse(models.Model):
|
||||
question = models.ForeignKey(ApplicationQuestion, on_delete=models.CASCADE)
|
||||
application = models.ForeignKey(Application, on_delete=models.CASCADE, related_name='responses')
|
||||
@@ -73,6 +84,8 @@ class ApplicationResponse(models.Model):
|
||||
class Meta:
|
||||
unique_together = ('question', 'application')
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class ApplicationComment(models.Model):
|
||||
application = models.ForeignKey(Application, on_delete=models.CASCADE, related_name='comments')
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||
@@ -82,12 +95,11 @@ class ApplicationComment(models.Model):
|
||||
def __str__(self):
|
||||
return str(self.user) + " comment on " + str(self.application)
|
||||
|
||||
|
||||
################
|
||||
# Legacy Models
|
||||
################
|
||||
# Can't delete or evolutions explodes.
|
||||
# They do nothing.
|
||||
################
|
||||
@python_2_unicode_compatible
|
||||
class HRApplication(models.Model):
|
||||
character_name = models.CharField(max_length=254, default="")
|
||||
full_api_id = models.CharField(max_length=254, default="")
|
||||
@@ -109,6 +121,7 @@ class HRApplication(models.Model):
|
||||
return self.character_name + " - Application"
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class HRApplicationComment(models.Model):
|
||||
created_on = models.DateTimeField(auto_now_add=True, null=True)
|
||||
comment = models.CharField(max_length=254, default="")
|
||||
|
||||
@@ -1,30 +1,23 @@
|
||||
from django.template import RequestContext
|
||||
from django.shortcuts import render_to_response, get_object_or_404, redirect
|
||||
from __future__ import unicode_literals
|
||||
from django.shortcuts import render, get_object_or_404, redirect
|
||||
from django.contrib.auth.decorators import permission_required
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.decorators import user_passes_test
|
||||
from django.shortcuts import HttpResponseRedirect
|
||||
from notifications import notify
|
||||
from models import HRApplication
|
||||
from models import HRApplicationComment
|
||||
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
|
||||
from hrapplications.models import ApplicationForm
|
||||
from hrapplications.models import Application
|
||||
from hrapplications.models import ApplicationResponse
|
||||
from hrapplications.models import ApplicationComment
|
||||
from hrapplications.forms import HRApplicationCommentForm
|
||||
from hrapplications.forms import HRApplicationSearchForm
|
||||
from eveonline.models import EveCharacter
|
||||
from authentication.models import AuthServicesInfo
|
||||
|
||||
from django.conf import settings
|
||||
from eveonline.managers import EveManager
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def create_application_test(user):
|
||||
auth, c = AuthServicesInfo.objects.get_or_create(user=user)
|
||||
if auth.main_char_id:
|
||||
@@ -32,6 +25,7 @@ def create_application_test(user):
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
@login_required
|
||||
def hr_application_management_view(request):
|
||||
logger.debug("hr_application_management_view called by user %s" % request.user)
|
||||
@@ -42,7 +36,7 @@ def hr_application_management_view(request):
|
||||
if auth_info.main_char_id:
|
||||
try:
|
||||
main_char = EveCharacter.objects.get(character_id=auth_info.main_char_id)
|
||||
except:
|
||||
except EveCharacter.DoesNotExist:
|
||||
pass
|
||||
if request.user.is_superuser:
|
||||
corp_applications = Application.objects.filter(approved=None)
|
||||
@@ -52,7 +46,8 @@ def hr_application_management_view(request):
|
||||
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))
|
||||
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,
|
||||
@@ -60,7 +55,8 @@ def hr_application_management_view(request):
|
||||
'search_form': HRApplicationSearchForm(),
|
||||
'create': create_application_test(request.user)
|
||||
}
|
||||
return render_to_response('registered/hrapplicationmanagement.html', context, context_instance=RequestContext(request))
|
||||
return render(request, 'registered/hrapplicationmanagement.html', context=context)
|
||||
|
||||
|
||||
@login_required
|
||||
@user_passes_test(create_application_test)
|
||||
@@ -75,19 +71,22 @@ def hr_application_create_view(request, form_id=None):
|
||||
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.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))
|
||||
return render(request, 'registered/hrapplicationcreate.html',
|
||||
context={'questions': questions, 'corp': app_form.corp})
|
||||
else:
|
||||
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))
|
||||
return render(request, 'registered/hrapplicationcorpchoice.html', context={'choices': choices})
|
||||
|
||||
|
||||
@login_required
|
||||
def hr_application_personal_view(request, app_id):
|
||||
@@ -102,18 +101,18 @@ def hr_application_personal_view(request, app_id):
|
||||
'comment_form': HRApplicationCommentForm(),
|
||||
'apis': [],
|
||||
}
|
||||
return render_to_response('registered/hrapplicationview.html', context, context_instance=RequestContext(request))
|
||||
return render(request, 'registered/hrapplicationview.html', context=context)
|
||||
else:
|
||||
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))
|
||||
app = get_object_or_404(Application, pk=app_id)
|
||||
if app.user == request.user:
|
||||
if app.approved == None:
|
||||
if app.approved is None:
|
||||
logger.info("User %s deleting %s" % (request.user, app))
|
||||
app.delete()
|
||||
else:
|
||||
@@ -122,6 +121,7 @@ def hr_application_personal_removal(request, app_id):
|
||||
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):
|
||||
@@ -154,7 +154,7 @@ def hr_application_view(request, app_id):
|
||||
'comments': ApplicationComment.objects.filter(application=app),
|
||||
'comment_form': form,
|
||||
}
|
||||
return render_to_response('registered/hrapplicationview.html', context, context_instance=RequestContext(request))
|
||||
return render(request, 'registered/hrapplicationview.html', context=context)
|
||||
|
||||
|
||||
@login_required
|
||||
@@ -168,6 +168,7 @@ def hr_application_remove(request, app_id):
|
||||
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_application')
|
||||
@@ -178,11 +179,13 @@ def hr_application_approve(request, app_id):
|
||||
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")
|
||||
notify(app.user, "Application Accepted", message="Your application to %s has been approved." % app.form.corp,
|
||||
level="success")
|
||||
else:
|
||||
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_application')
|
||||
@@ -193,11 +196,13 @@ def hr_application_reject(request, app_id):
|
||||
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")
|
||||
notify(app.user, "Application Rejected", message="Your application to %s has been rejected." % app.form.corp,
|
||||
level="danger")
|
||||
else:
|
||||
logger.warn("User %s not authorized to reject %s" % (request.user, app))
|
||||
return redirect('auth_hrapplications_view')
|
||||
|
||||
|
||||
@login_required
|
||||
@permission_required('auth.human_resources')
|
||||
def hr_application_search(request):
|
||||
@@ -217,15 +222,16 @@ def hr_application_search(request):
|
||||
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)
|
||||
except EveCharacter.DoesNotExist:
|
||||
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():\
|
||||
if searchstring in application.main_character.alliance_name.lower():
|
||||
applications.add(application)
|
||||
for character in application.characters:
|
||||
if searchstring in character.character_name.lower():
|
||||
@@ -236,21 +242,21 @@ def hr_application_search(request):
|
||||
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))
|
||||
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))
|
||||
return render(request, 'registered/hrapplicationsearchview.html', context=context)
|
||||
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))
|
||||
return render(request, 'registered/hrapplicationsearchview.html', context=context)
|
||||
|
||||
else:
|
||||
logger.debug("Returning empty search form for user %s" % request.user)
|
||||
return HttpResponseRedirect("/hr_application_management/")
|
||||
return redirect("auth_hrapplications_view")
|
||||
|
||||
|
||||
@login_required
|
||||
@permission_required('auth.human_resources')
|
||||
@@ -262,13 +268,15 @@ def hr_application_mark_in_progress(request, app_id):
|
||||
auth_info = AuthServicesInfo.objects.get(user=request.user)
|
||||
try:
|
||||
character = EveCharacter.objects.get(character_id=auth_info.main_char_id)
|
||||
except:
|
||||
except EveCharacter.DoesNotExist:
|
||||
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))
|
||||
notify(app.user, "Application In Progress",
|
||||
message="Your application to %s is being reviewed by %s" % (app.form.corp, app.reviewer_str))
|
||||
else:
|
||||
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))
|
||||
logger.warn(
|
||||
"User %s unable to mark %s in progress: already being reviewed by %s" % (request.user, app, app.reviewer))
|
||||
return redirect("auth_hrapplication_view", app_id)
|
||||
|
||||
Reference in New Issue
Block a user