mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2026-02-05 22:56:20 +01:00
Bulk of the profile work is done.
This commit is contained in:
50
hrapplications/migrations/0002_auto_20170322_2335.py
Normal file
50
hrapplications/migrations/0002_auto_20170322_2335.py
Normal file
@@ -0,0 +1,50 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.5 on 2017-03-22 23:35
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hrapplications', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='hrapplication',
|
||||
name='about',
|
||||
field=models.TextField(default=''),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='hrapplication',
|
||||
name='character_name',
|
||||
field=models.CharField(default='', max_length=254),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='hrapplication',
|
||||
name='extra',
|
||||
field=models.TextField(default=''),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='hrapplication',
|
||||
name='full_api_id',
|
||||
field=models.CharField(default='', max_length=254),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='hrapplication',
|
||||
name='full_api_key',
|
||||
field=models.CharField(default='', max_length=254),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='hrapplication',
|
||||
name='is_a_spi',
|
||||
field=models.CharField(default='', max_length=254),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='hrapplicationcomment',
|
||||
name='comment',
|
||||
field=models.CharField(default='', max_length=254),
|
||||
),
|
||||
]
|
||||
@@ -5,8 +5,6 @@ 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
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
@@ -47,21 +45,12 @@ class Application(models.Model):
|
||||
|
||||
@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
|
||||
return self.user.profile.main_character
|
||||
|
||||
@property
|
||||
def characters(self):
|
||||
return EveCharacter.objects.filter(user=self.user)
|
||||
|
||||
@property
|
||||
def apis(self):
|
||||
return EveApiKeyPair.objects.filter(user=self.user)
|
||||
|
||||
@property
|
||||
def reviewer_str(self):
|
||||
if self.reviewer_character:
|
||||
|
||||
@@ -11,7 +11,6 @@ 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
|
||||
|
||||
import logging
|
||||
|
||||
@@ -19,11 +18,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def create_application_test(user):
|
||||
auth = AuthServicesInfo.objects.get(user=user)
|
||||
if auth.main_char_id:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return bool(user.profile.main_character)
|
||||
|
||||
|
||||
@login_required
|
||||
@@ -31,13 +26,7 @@ def hr_application_management_view(request):
|
||||
logger.debug("hr_application_management_view called by user %s" % request.user)
|
||||
corp_applications = []
|
||||
finished_corp_applications = []
|
||||
auth_info = AuthServicesInfo.objects.get(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 EveCharacter.DoesNotExist:
|
||||
pass
|
||||
main_char = request.user.profile.main_character
|
||||
if request.user.is_superuser:
|
||||
corp_applications = Application.objects.filter(approved=None)
|
||||
finished_corp_applications = Application.objects.exclude(approved=None)
|
||||
@@ -99,7 +88,6 @@ def hr_application_personal_view(request, app_id):
|
||||
'buttons': False,
|
||||
'comments': ApplicationComment.objects.filter(application=app),
|
||||
'comment_form': HRApplicationCommentForm(),
|
||||
'apis': [],
|
||||
}
|
||||
return render(request, 'registered/hrapplicationview.html', context=context)
|
||||
else:
|
||||
@@ -141,17 +129,14 @@ def hr_application_view(request, app_id):
|
||||
return redirect(hr_application_view, app_id)
|
||||
else:
|
||||
logger.warn("User %s does not have permission to add ApplicationComments" % request.user)
|
||||
return redirect(hr_application_view, app_id)
|
||||
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,
|
||||
}
|
||||
@@ -219,11 +204,9 @@ def hr_application_search(request):
|
||||
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 EveCharacter.DoesNotExist:
|
||||
app_list = Application.objects.filter(form__corp__corporation_id=request.user.profile.main_character.corporation_id)
|
||||
except AttributeError:
|
||||
logger.warn(
|
||||
"User %s missing main character model: unable to filter applications to search" % request.user)
|
||||
for application in app_list:
|
||||
@@ -267,14 +250,8 @@ def hr_application_mark_in_progress(request, app_id):
|
||||
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)
|
||||
try:
|
||||
character = EveCharacter.objects.get(character_id=auth_info.main_char_id)
|
||||
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.reviewer_character = request.user.profile.main_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))
|
||||
|
||||
Reference in New Issue
Block a user