Changes the Services Add form for required input, also redirects user if they have no services to add.

This commit is contained in:
2010-03-15 14:28:50 +00:00
parent c17e4bae8f
commit d7fcc98153
2 changed files with 9 additions and 4 deletions

View File

@@ -34,8 +34,8 @@ def UserServiceAccountForm(user):
class ServiceAccountForm(forms.Form): class ServiceAccountForm(forms.Form):
""" Service Account Form """ """ Service Account Form """
character = forms.ModelChoiceField(queryset=chars) character = forms.ModelChoiceField(queryset=chars, required=True, empty_label=None)
service = forms.ModelChoiceField(queryset=services) service = forms.ModelChoiceField(queryset=services, required=True, empty_label=None)
def clean(self): def clean(self):
if not self.cleaned_data['character'].corporation.group in self.cleaned_data['service'].groups.all(): if not self.cleaned_data['character'].corporation.group in self.cleaned_data['service'].groups.all():

View File

@@ -10,7 +10,7 @@ from eve_api.api_exceptions import APIAuthException, APINoUserIDException
from eve_api.api_puller.accounts import import_eve_account from eve_api.api_puller.accounts import import_eve_account
from eve_api.models.api_player import EVEAccount from eve_api.models.api_player import EVEAccount
from sso.models import ServiceAccount, SSOUser, ExistingUser from sso.models import ServiceAccount, Service, SSOUser, ExistingUser
from sso.forms import EveAPIForm, UserServiceAccountForm, RedditAccountForm, UserLookupForm from sso.forms import EveAPIForm, UserServiceAccountForm, RedditAccountForm, UserLookupForm
from reddit.models import RedditAccount from reddit.models import RedditAccount
@@ -110,7 +110,12 @@ def service_add(request):
return render_to_response('sso/serviceaccount_created.html', { 'account': acc, 'error': error }) return render_to_response('sso/serviceaccount_created.html', { 'account': acc, 'error': error })
else: else:
#defaults = { 'username': request.user.username, 'password': request.user.get_profile().default_service_passwd } #defaults = { 'username': request.user.username, 'password': request.user.get_profile().default_service_passwd }
form = clsform() # An unbound form
availserv = Service.objects.filter(groups__in=request.user.groups.all()).exclude(id__in=ServiceAccount.objects.filter(user=request.user).values('service'))
if len(availserv) == 0:
return HttpResponseRedirect(reverse('sso.views.profile'))
else:
form = clsform() # An unbound form
return render_to_response('sso/serviceaccount.html', locals()) return render_to_response('sso/serviceaccount.html', locals())