Website to manage tibia accounts and characters
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

forms.py 849B

1234567891011121314151617181920212223242526
  1. from django import forms
  2. from accounts.models import Accounts
  3. from accounts.utils import LoginHelper, VocationHelper
  4. class LoginForm(forms.Form):
  5. account_name = forms.CharField()
  6. password = forms.CharField(widget=forms.PasswordInput)
  7. def is_valid(self):
  8. if not super(LoginForm, self).is_valid():
  9. return False
  10. account = Accounts.objects.get(name=self.cleaned_data['account_name'])
  11. hashed_password = LoginHelper.hash_password(self.cleaned_data['password'])
  12. if account.password == hashed_password:
  13. return True
  14. else:
  15. return False
  16. class CreateCharacterForm(forms.Form):
  17. name = forms.CharField()
  18. #vocation = forms.ChoiceField(
  19. # choices=VocationHelper.get_base_vocation_choices())
  20. sex = forms.ChoiceField(choices=((0, 'female'), (1, 'male')))