Various fixes and work on the HR application.

This commit is contained in:
2010-04-05 03:10:15 +01:00
parent 956052c25c
commit 586a2727b1
5 changed files with 33 additions and 23 deletions

View File

@@ -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

View File

@@ -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
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

View File

@@ -7,10 +7,10 @@
The person you are recommending needs to have created their application before you can add a recommendation.</p>
<form action="/hr/add/recommendation/" method="post">
<form action="/hr/add/application/" method="post">
<table>
{{ form.as_table }}
</table>
<input type="submit" value="Add Recommendation" />
<input type="submit" value="Apply" />
</form>
{% endblock %}

View File

@@ -0,0 +1,7 @@
{% extends "base.html" %}
{% block title %}Create Application{% endblock %}
{% block content %}
<p>Unfortunatly, no Corporations are accepting applications at the moment.</p>
{% endblock %}

View File

@@ -1,26 +1,22 @@
{% extends "base.html" %}
{% block title %}Recommendations{% endblock %}
{% block title %}Applications{% endblock %}
{% block content %}
<p>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.</p>
{% if recs %}
<p>This list shows your current open applications</p>
{% if apps %}
<table>
<thead>
<tr><th>Recommender</th><th>Recommended Application</th><th>Application Status</th></tr>
</thead>
<tbody>
{% for rec in recs %}
<tr><td>{{ rec.user_character }}</td>
<td>{{ rec.application }}</td>
<td>{{ rec.application.status_description }}</td>
<tr><th>Application ID</th><th>Character</th><th>Corporation</th><th>Application Status</th></tr>
{% for app in apps %}
<tr><td><a href="/hr/applications/{{ app.id }}/">{{ app.id }}</a></td>
<td>{{ app.character }}</td>
<td>{{ app.corporation }}</td>
<td>{{ app.status_description }}</td>
</tr>
</tbody>
{% endfor %}
</table>
{% else %}
<p>You have no current recommendations</p>
<p>You have no current applications</p>
{% endif %}
{% endblock %}