moviewyrm/fedireads/forms.py
2020-04-01 11:34:48 -07:00

104 lines
2.4 KiB
Python

''' usin django model forms '''
from django.core.validators import MaxValueValidator, MinValueValidator
from django.forms import ModelForm, PasswordInput, IntegerField
from django import forms
from fedireads import models
class LoginForm(ModelForm):
class Meta:
model = models.User
fields = ['username', 'password']
help_texts = {f: None for f in fields}
widgets = {
'password': PasswordInput(),
}
class RegisterForm(ModelForm):
class Meta:
model = models.User
fields = ['username', 'email', 'password']
help_texts = {f: None for f in fields}
widgets = {
'password': PasswordInput(),
}
class ReviewForm(ModelForm):
class Meta:
model = models.Review
fields = ['name', 'rating', 'content']
help_texts = {f: None for f in fields}
labels = {
'name': 'Title',
'rating': 'Rating (out of 5)',
'content': 'Review',
}
class CommentForm(ModelForm):
class Meta:
model = models.Comment
fields = ['content']
help_texts = {f: None for f in fields}
labels = {
'content': 'Comment',
}
class ReplyForm(ModelForm):
class Meta:
model = models.Status
fields = ['content']
help_texts = {f: None for f in fields}
labels = {'content': 'Comment'}
class EditUserForm(ModelForm):
class Meta:
model = models.User
fields = ['avatar', 'name', 'summary', 'manually_approves_followers']
help_texts = {f: None for f in fields}
class TagForm(ModelForm):
class Meta:
model = models.Tag
fields = ['name']
help_texts = {f: None for f in fields}
labels = {'name': 'Add a tag'}
class CoverForm(ModelForm):
class Meta:
model = models.Book
fields = ['cover']
help_texts = {f: None for f in fields}
class BookForm(ModelForm):
class Meta:
model = models.Book
exclude = [
'created_date',
'updated_date',
'last_sync_date',
'authors',
'parent_work',
'shelves',
'misc_identifiers',
'subjects',
'subject_places',
'source_url',
'connector',
]
class ImportForm(forms.Form):
csv_file = forms.FileField()