calibre-web-companion/CalibreWebCompanion/library/forms.py

27 lines
848 B
Python
Raw Normal View History

2020-07-08 16:22:37 +00:00
from django import forms
2020-07-09 13:41:41 +00:00
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
2020-07-08 16:22:37 +00:00
class SearchForm(forms.Form):
title = forms.CharField(label="Title", max_length=200)
author = forms.CharField(label='Author', max_length=100)
2020-07-15 03:34:44 +00:00
identifier = forms.CharField(label='Identifier(ISBN, Google-id, amazon id)', max_length=20)
2020-07-15 13:42:49 +00:00
generic = forms.CharField(label='All', max_length=100, required=False)
2020-07-08 16:22:37 +00:00
2020-07-09 13:41:41 +00:00
class UserCreationForm(UserCreationForm):
email = forms.EmailField(required=True)
class Meta:
model = User
fields = ("username", "email", "password1", "password2")
def save(self, commit=True):
user = super(UserCreationForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
if commit:
user.save()
return user