mirror of
https://github.com/nikdoof/test-auth.git
synced 2026-01-31 08:28:15 +00:00
Various fixes and work on the HR application.
This commit is contained in:
@@ -3,7 +3,7 @@ import settings
|
|||||||
|
|
||||||
from hr.app_defines import *
|
from hr.app_defines import *
|
||||||
from hr.models import Application
|
from hr.models import Application
|
||||||
from eve_api.models import EVEPlayerCharacter
|
from eve_api.models import EVEPlayerCharacter, EVEPlayerCorporation
|
||||||
|
|
||||||
def CreateRecommendationForm(user):
|
def CreateRecommendationForm(user):
|
||||||
""" Generate a Recommendation form based on the user's permissions """
|
""" Generate a Recommendation form based on the user's permissions """
|
||||||
@@ -28,7 +28,13 @@ def CreateApplicationForm(user):
|
|||||||
|
|
||||||
class ApplicationForm(forms.Form):
|
class ApplicationForm(forms.Form):
|
||||||
character = forms.ModelChoiceField(queryset=characters, required=True, empty_label=None)
|
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
|
return ApplicationForm
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
13
hr/views.py
13
hr/views.py
@@ -7,6 +7,8 @@ from django.contrib.auth.models import User
|
|||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
|
|
||||||
|
from eve_api.models import EVEPlayerCorporation
|
||||||
|
|
||||||
from hr.forms import CreateRecommendationForm, CreateApplicationForm
|
from hr.forms import CreateRecommendationForm, CreateApplicationForm
|
||||||
from hr.models import Recommendation, Application
|
from hr.models import Recommendation, Application
|
||||||
|
|
||||||
@@ -46,15 +48,16 @@ def add_application(request):
|
|||||||
app.corporation = form.cleaned_data['corporation']
|
app.corporation = form.cleaned_data['corporation']
|
||||||
app.save()
|
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'))
|
return HttpResponseRedirect(reverse('hr.views.view_applications'))
|
||||||
else:
|
|
||||||
return HttpResponseRedirect(reverse('hr.views.add_application'))
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
form = clsform() # An unbound form
|
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
|
### Recommendation Management
|
||||||
|
|
||||||
@@ -90,8 +93,6 @@ def add_recommendation(request):
|
|||||||
|
|
||||||
request.user.message_set.create(message="Recommendation added to %s's application" % rec.application )
|
request.user.message_set.create(message="Recommendation added to %s's application" % rec.application )
|
||||||
return HttpResponseRedirect(reverse('hr.views.view_recommendations'))
|
return HttpResponseRedirect(reverse('hr.views.view_recommendations'))
|
||||||
else:
|
|
||||||
return HttpResponseRedirect(reverse('hr.views.add_recommendation'))
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
form = clsform() # An unbound form
|
form = clsform() # An unbound form
|
||||||
|
|||||||
@@ -7,10 +7,10 @@
|
|||||||
|
|
||||||
The person you are recommending needs to have created their application before you can add a recommendation.</p>
|
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>
|
<table>
|
||||||
{{ form.as_table }}
|
{{ form.as_table }}
|
||||||
</table>
|
</table>
|
||||||
<input type="submit" value="Add Recommendation" />
|
<input type="submit" value="Apply" />
|
||||||
</form>
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
7
templates/hr/applications/noadd.html
Normal file
7
templates/hr/applications/noadd.html
Normal 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 %}
|
||||||
@@ -1,26 +1,22 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% block title %}Recommendations{% endblock %}
|
{% block title %}Applications{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<p>This list shows your current open recommendations that are yet to be submitted, as
|
<p>This list shows your current open applications</p>
|
||||||
soon as the recommended user submits their application your recommendation will be removed from this list.</p>
|
{% if apps %}
|
||||||
{% if recs %}
|
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<tr><th>Application ID</th><th>Character</th><th>Corporation</th><th>Application Status</th></tr>
|
||||||
<tr><th>Recommender</th><th>Recommended Application</th><th>Application Status</th></tr>
|
{% for app in apps %}
|
||||||
</thead>
|
<tr><td><a href="/hr/applications/{{ app.id }}/">{{ app.id }}</a></td>
|
||||||
<tbody>
|
<td>{{ app.character }}</td>
|
||||||
{% for rec in recs %}
|
<td>{{ app.corporation }}</td>
|
||||||
<tr><td>{{ rec.user_character }}</td>
|
<td>{{ app.status_description }}</td>
|
||||||
<td>{{ rec.application }}</td>
|
|
||||||
<td>{{ rec.application.status_description }}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>You have no current recommendations</p>
|
<p>You have no current applications</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user