mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-13 22:32:15 +00:00
Fixes #289, stops people with no characters creating a recommendation or application
This commit is contained in:
@@ -22,6 +22,11 @@ class RecommendationForm(forms.Form):
|
||||
super(RecommendationForm, self).__init__(*args, **kwargs)
|
||||
self.fields['character'].queryset = EVEPlayerCharacter.objects.filter(eveaccount__user=user, eveaccount__api_status=API_STATUS_OK).distinct()
|
||||
|
||||
def clean_character(self):
|
||||
if not 'character' in self.cleaned_data or self.cleaned_data['character'] is None:
|
||||
raise forms.ValidationError("Please select a character.")
|
||||
return self.cleaned_data['character']
|
||||
|
||||
def clean(self):
|
||||
char = self.cleaned_data.get('character')
|
||||
app = self.cleaned_data.get('application')
|
||||
|
||||
@@ -82,6 +82,12 @@ class HrAddApplication(FormView):
|
||||
|
||||
form_class = ApplicationForm
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
if EVEPlayerCharacter.objects.filter(eveaccount__user=request.user).count() == 0:
|
||||
messages.add_message(request, messages.ERROR, "You need to add a EVE API key before you can create a application.")
|
||||
return HttpResponseRedirect(reverse('sso-profile'))
|
||||
return super(HrAddApplication, self).dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_form_kwargs(self, **kwargs):
|
||||
kwargs = super(HrAddApplication, self).get_form_kwargs(**kwargs)
|
||||
kwargs['user'] = self.request.user
|
||||
@@ -120,6 +126,11 @@ class HrAddRecommendation(FormView):
|
||||
form_class = RecommendationForm
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
|
||||
if EVEPlayerCharacter.objects.filter(eveaccount__user=request.user).count() == 0:
|
||||
messages.add_message(request, messages.ERROR, "You need to add a EVE API key before you can create a recommendation.")
|
||||
return HttpResponseRedirect(reverse('sso-profile'))
|
||||
|
||||
if len(blacklist_values(request.user, BLACKLIST_LEVEL_ADVISORY)):
|
||||
raise Http404
|
||||
return super(HrAddRecommendation, self).dispatch(request, *args, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user