mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-20 13:19:24 +00:00
Reorganise the file structure into a project tree
This commit is contained in:
49
app/hr/forms.py
Normal file
49
app/hr/forms.py
Normal file
@@ -0,0 +1,49 @@
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
|
||||
from hr.app_defines import *
|
||||
from hr.models import Application, Audit
|
||||
from eve_api.models import EVEPlayerCharacter, EVEPlayerCorporation
|
||||
|
||||
def CreateRecommendationForm(user):
|
||||
""" Generate a Recommendation form based on the user's permissions """
|
||||
|
||||
characters = EVEPlayerCharacter.objects.filter(eveaccount__user=user)
|
||||
applications = Application.objects.filter(status=APPLICATION_STATUS_NOTSUBMITTED)
|
||||
|
||||
class RecommendationForm(forms.Form):
|
||||
""" Service Account Form """
|
||||
|
||||
character = forms.ModelChoiceField(queryset=characters, required=True, empty_label=None)
|
||||
application = forms.ModelChoiceField(queryset=applications, required=True, empty_label=None)
|
||||
|
||||
return RecommendationForm
|
||||
|
||||
|
||||
def CreateApplicationForm(user):
|
||||
""" Generate a Application form based on the user's permissions """
|
||||
|
||||
characters = EVEPlayerCharacter.objects.filter(eveaccount__user=user)
|
||||
corporations = EVEPlayerCorporation.objects.filter(applications=True)
|
||||
|
||||
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_character(self):
|
||||
|
||||
if not 'character' in self.cleaned_data or not self.cleaned_data['character']:
|
||||
raise forms.ValidationError("Please select a character to apply with")
|
||||
|
||||
if Application.objects.filter(character=self.cleaned_data['character']).exclude(status__in=[APPLICATION_STATUS_COMPLETED, APPLICATION_STATUS_REJECTED]).count():
|
||||
raise forms.ValidationError("This character already has a open application")
|
||||
|
||||
return self.cleaned_data['character']
|
||||
|
||||
return ApplicationForm
|
||||
|
||||
class NoteForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = Audit
|
||||
exclude = ('application', 'user', 'event')
|
||||
Reference in New Issue
Block a user