From 586a2727b119088cffe6f70cba4693972a013845 Mon Sep 17 00:00:00 2001
From: Andrew Williams
Date: Mon, 5 Apr 2010 03:10:15 +0100
Subject: [PATCH] Various fixes and work on the HR application.
---
hr/forms.py | 8 +++++++-
hr/views.py | 13 +++++++------
templates/hr/applications/add.html | 4 ++--
templates/hr/applications/noadd.html | 7 +++++++
templates/hr/applications/view_list.html | 24 ++++++++++--------------
5 files changed, 33 insertions(+), 23 deletions(-)
create mode 100644 templates/hr/applications/noadd.html
diff --git a/hr/forms.py b/hr/forms.py
index e3be592..7134da6 100644
--- a/hr/forms.py
+++ b/hr/forms.py
@@ -3,7 +3,7 @@ import settings
from hr.app_defines import *
from hr.models import Application
-from eve_api.models import EVEPlayerCharacter
+from eve_api.models import EVEPlayerCharacter, EVEPlayerCorporation
def CreateRecommendationForm(user):
""" Generate a Recommendation form based on the user's permissions """
@@ -28,7 +28,13 @@ def CreateApplicationForm(user):
class ApplicationForm(forms.Form):
character = forms.ModelChoiceField(queryset=characters, required=True, empty_label=None)
+ corporation = forms.ModelChoiceField(queryset=corporations, required=True, empty_label=None)
+ def clean(self):
+ if len(Application.objects.filter(character=self.cleaned_data['character'], status__in=[APPLICATION_STATUS_NOTSUBMITTED, APPLICATION_STATUS_AWAITINGREVIEW, APPLICATION_STATUS_QUERY])):
+ raise forms.ValidationError("This character already has a open application")
+
+ return self.cleaned_data
return ApplicationForm
diff --git a/hr/views.py b/hr/views.py
index c622a7a..c53f8fa 100644
--- a/hr/views.py
+++ b/hr/views.py
@@ -7,6 +7,8 @@ from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required
from django.template import RequestContext
+from eve_api.models import EVEPlayerCorporation
+
from hr.forms import CreateRecommendationForm, CreateApplicationForm
from hr.models import Recommendation, Application
@@ -46,15 +48,16 @@ def add_application(request):
app.corporation = form.cleaned_data['corporation']
app.save()
- request.user.message_set.create(message="Application has been submitted." % rec.application )
+ request.user.message_set.create(message="Your application to %s has been submitted." % app.corporation)
return HttpResponseRedirect(reverse('hr.views.view_applications'))
- else:
- return HttpResponseRedirect(reverse('hr.views.add_application'))
else:
form = clsform() # An unbound form
- return render_to_response('hr/applications/add.html', locals(), context_instance=RequestContext(request))
+ if len(EVEPlayerCorporation.objects.filter(applications=True)):
+ return render_to_response('hr/applications/add.html', locals(), context_instance=RequestContext(request))
+ else:
+ return render_to_response('hr/applications/noadd.html', locals(), context_instance=RequestContext(request))
### Recommendation Management
@@ -90,8 +93,6 @@ def add_recommendation(request):
request.user.message_set.create(message="Recommendation added to %s's application" % rec.application )
return HttpResponseRedirect(reverse('hr.views.view_recommendations'))
- else:
- return HttpResponseRedirect(reverse('hr.views.add_recommendation'))
else:
form = clsform() # An unbound form
diff --git a/templates/hr/applications/add.html b/templates/hr/applications/add.html
index 4a14c5c..2447ff3 100644
--- a/templates/hr/applications/add.html
+++ b/templates/hr/applications/add.html
@@ -7,10 +7,10 @@
The person you are recommending needs to have created their application before you can add a recommendation.
-
{% endblock %}
diff --git a/templates/hr/applications/noadd.html b/templates/hr/applications/noadd.html
new file mode 100644
index 0000000..24782e9
--- /dev/null
+++ b/templates/hr/applications/noadd.html
@@ -0,0 +1,7 @@
+{% extends "base.html" %}
+
+{% block title %}Create Application{% endblock %}
+
+{% block content %}
+Unfortunatly, no Corporations are accepting applications at the moment.
+{% endblock %}
diff --git a/templates/hr/applications/view_list.html b/templates/hr/applications/view_list.html
index 743d700..ffc2c57 100644
--- a/templates/hr/applications/view_list.html
+++ b/templates/hr/applications/view_list.html
@@ -1,26 +1,22 @@
{% extends "base.html" %}
-{% block title %}Recommendations{% endblock %}
+{% block title %}Applications{% endblock %}
{% block content %}
-This list shows your current open recommendations that are yet to be submitted, as
-soon as the recommended user submits their application your recommendation will be removed from this list.
-{% if recs %}
+This list shows your current open applications
+{% if apps %}
-
-| Recommender | Recommended Application | Application Status |
-
-
-{% for rec in recs %}
-| {{ rec.user_character }} |
- {{ rec.application }} |
- {{ rec.application.status_description }} |
+
| Application ID | Character | Corporation | Application Status |
+{% for app in apps %}
+| {{ app.id }} |
+ {{ app.character }} |
+ {{ app.corporation }} |
+ {{ app.status_description }} |
-
{% endfor %}
{% else %}
-You have no current recommendations
+You have no current applications
{% endif %}
{% endblock %}