diff --git a/cookbook/forms.py b/cookbook/forms.py
index 5015e0c23..663106329 100644
--- a/cookbook/forms.py
+++ b/cookbook/forms.py
@@ -3,7 +3,9 @@ from django.forms import widgets
from django.utils.translation import gettext_lazy as _
from emoji_picker.widgets import EmojiPickerTextInput
-from .models import *
+from .models import (Comment, Food, InviteLink, Keyword, MealPlan, Recipe,
+ RecipeBook, RecipeBookEntry, Storage, Sync, Unit, User,
+ UserPreference)
class SelectWidget(widgets.Select):
@@ -16,7 +18,8 @@ class MultiSelectWidget(widgets.SelectMultiple):
js = ('custom/js/form_multiselect.js',)
-# yes there are some stupid browsers that still dont support this but i dont support people using these browsers
+# Yes there are some stupid browsers that still dont support this but
+# I dont support people using these browsers.
class DateWidget(forms.DateInput):
input_type = 'date'
@@ -30,20 +33,26 @@ class UserPreferenceForm(forms.ModelForm):
class Meta:
model = UserPreference
- fields = ('default_unit', 'use_fractions', 'theme', 'nav_color', 'sticky_navbar', 'default_page', 'show_recent', 'search_style', 'plan_share', 'ingredient_decimals', 'shopping_auto_sync', 'comments')
+ fields = (
+ 'default_unit', 'use_fractions', 'theme', 'nav_color',
+ 'sticky_navbar', 'default_page', 'show_recent', 'search_style',
+ 'plan_share', 'ingredient_decimals', 'shopping_auto_sync',
+ 'comments'
+ )
help_texts = {
- 'nav_color': _('Color of the top navigation bar. Not all colors work with all themes, just try them out!'),
- 'default_unit': _('Default Unit to be used when inserting a new ingredient into a recipe.'),
- 'use_fractions': _('Enables support for fractions in ingredient amounts (e.g. convert decimals to fractions automatically)'),
- 'plan_share': _('Users with whom newly created meal plan/shopping list entries should be shared by default.'),
- 'show_recent': _('Show recently viewed recipes on search page.'),
- 'ingredient_decimals': _('Number of decimals to round ingredients.'),
- 'comments': _('If you want to be able to create and see comments underneath recipes.'),
+ 'nav_color': _('Color of the top navigation bar. Not all colors work with all themes, just try them out!'), # noqa: E501
+ 'default_unit': _('Default Unit to be used when inserting a new ingredient into a recipe.'), # noqa: E501
+ 'use_fractions': _('Enables support for fractions in ingredient amounts (e.g. convert decimals to fractions automatically)'), # noqa: E501
+ 'plan_share': _('Users with whom newly created meal plan/shopping list entries should be shared by default.'), # noqa: E501
+ 'show_recent': _('Show recently viewed recipes on search page.'), # noqa: E501
+ 'ingredient_decimals': _('Number of decimals to round ingredients.'), # noqa: E501
+ 'comments': _('If you want to be able to create and see comments underneath recipes.'), # noqa: E501
'shopping_auto_sync': _(
- 'Setting to 0 will disable auto sync. When viewing a shopping list the list is updated every set seconds to sync changes someone else might have made. Useful when shopping with multiple people but might use a little bit '
- 'of mobile data. If lower than instance limit it is reset when saving.'),
- 'sticky_navbar': _('Makes the navbar stick to the top of the page.')
+ 'Setting to 0 will disable auto sync. When viewing a shopping list the list is updated every set seconds to sync changes someone else might have made. Useful when shopping with multiple people but might use a little bit ' # noqa: E501
+ 'of mobile data. If lower than instance limit it is reset when saving.' # noqa: E501
+ ),
+ 'sticky_navbar': _('Makes the navbar stick to the top of the page.') # noqa: E501
}
widgets = {
@@ -59,18 +68,25 @@ class UserNameForm(forms.ModelForm):
fields = ('first_name', 'last_name')
help_texts = {
- 'first_name': _('Both fields are optional. If none are given the username will be displayed instead')
+ 'first_name': _('Both fields are optional. If none are given the username will be displayed instead') # noqa: E501
}
class ExternalRecipeForm(forms.ModelForm):
file_path = forms.CharField(disabled=True, required=False)
- storage = forms.ModelChoiceField(queryset=Storage.objects.all(), disabled=True, required=False)
+ storage = forms.ModelChoiceField(
+ queryset=Storage.objects.all(),
+ disabled=True,
+ required=False
+ )
file_uid = forms.CharField(disabled=True, required=False)
class Meta:
model = Recipe
- fields = ('name', 'keywords', 'working_time', 'waiting_time', 'file_path', 'storage', 'file_uid')
+ fields = (
+ 'name', 'keywords', 'working_time', 'waiting_time',
+ 'file_path', 'storage', 'file_uid'
+ )
labels = {
'name': _('Name'),
@@ -88,7 +104,10 @@ class InternalRecipeForm(forms.ModelForm):
class Meta:
model = Recipe
- fields = ('name', 'image', 'working_time', 'waiting_time', 'servings', 'keywords')
+ fields = (
+ 'name', 'image', 'working_time',
+ 'waiting_time', 'servings', 'keywords'
+ )
labels = {
'name': _('Name'),
@@ -106,7 +125,7 @@ class ShoppingForm(forms.Form):
widget=MultiSelectWidget
)
markdown_format = forms.BooleanField(
- help_text=_('Include - [ ] in list for easier usage in markdown based documents.'),
+ help_text=_('Include - [ ] in list for easier usage in markdown based documents.'), # noqa: E501
required=False,
initial=False
)
@@ -128,7 +147,10 @@ class ExportForm(forms.Form):
class ImportForm(forms.Form):
- recipe = forms.CharField(widget=forms.Textarea, help_text=_('Simply paste a JSON export into this textarea and click import.'))
+ recipe = forms.CharField(
+ widget=forms.Textarea,
+ help_text=_('Simply paste a JSON export into this textarea and click import.') # noqa: E501
+ )
class UnitMergeForm(forms.Form):
@@ -195,21 +217,31 @@ class FoodForm(forms.ModelForm):
class StorageForm(forms.ModelForm):
- username = forms.CharField(widget=forms.TextInput(attrs={'autocomplete': 'new-password'}), required=False)
- password = forms.CharField(widget=forms.TextInput(attrs={'autocomplete': 'new-password', 'type': 'password'}),
- required=False,
- help_text=_('Leave empty for dropbox and enter app password for nextcloud.'))
- token = forms.CharField(widget=forms.TextInput(attrs={'autocomplete': 'new-password', 'type': 'password'}),
- required=False,
- help_text=_('Leave empty for nextcloud and enter api token for dropbox.'))
+ username = forms.CharField(
+ widget=forms.TextInput(attrs={'autocomplete': 'new-password'}),
+ required=False
+ )
+ password = forms.CharField(
+ widget=forms.TextInput(
+ attrs={'autocomplete': 'new-password', 'type': 'password'}
+ ),
+ required=False,
+ help_text=_('Leave empty for dropbox and enter app password for nextcloud.') # noqa: E501
+ )
+ token = forms.CharField(
+ widget=forms.TextInput(
+ attrs={'autocomplete': 'new-password', 'type': 'password'}
+ ),
+ required=False,
+ help_text=_('Leave empty for nextcloud and enter api token for dropbox.') # noqa: E501
+ )
class Meta:
model = Storage
fields = ('name', 'method', 'username', 'password', 'token', 'url')
help_texts = {
- 'url': _(
- 'Leave empty for dropbox and enter only base url for nextcloud (/remote.php/webdav/ is added automatically)'),
+ 'url': _('Leave empty for dropbox and enter only base url for nextcloud (/remote.php/webdav/ is added automatically)'), # noqa: E501
}
@@ -229,8 +261,11 @@ class SyncForm(forms.ModelForm):
class BatchEditForm(forms.Form):
search = forms.CharField(label=_('Search String'))
- keywords = forms.ModelMultipleChoiceField(queryset=Keyword.objects.all().order_by('id'), required=False,
- widget=MultiSelectWidget)
+ keywords = forms.ModelMultipleChoiceField(
+ queryset=Keyword.objects.all().order_by('id'),
+ required=False,
+ widget=MultiSelectWidget
+ )
class ImportRecipeForm(forms.ModelForm):
@@ -260,20 +295,29 @@ class MealPlanForm(forms.ModelForm):
cleaned_data = super(MealPlanForm, self).clean()
if cleaned_data['title'] == '' and cleaned_data['recipe'] is None:
- raise forms.ValidationError(_('You must provide at least a recipe or a title.'))
+ raise forms.ValidationError(
+ _('You must provide at least a recipe or a title.')
+ )
return cleaned_data
class Meta:
model = MealPlan
- fields = ('recipe', 'title', 'meal_type', 'note', 'servings', 'date', 'shared')
+ fields = (
+ 'recipe', 'title', 'meal_type', 'note',
+ 'servings', 'date', 'shared'
+ )
help_texts = {
- 'shared': _('You can list default users to share recipes with in the settings.'),
- 'note': _('You can use markdown to format this field. See the docs here')
+ 'shared': _('You can list default users to share recipes with in the settings.'), # noqa: E501
+ 'note': _('You can use markdown to format this field. See the docs here') # noqa: E501
}
- widgets = {'recipe': SelectWidget, 'date': DateWidget, 'shared': MultiSelectWidget}
+ widgets = {
+ 'recipe': SelectWidget,
+ 'date': DateWidget,
+ 'shared': MultiSelectWidget
+ }
class InviteLinkForm(forms.ModelForm):
@@ -281,11 +325,19 @@ class InviteLinkForm(forms.ModelForm):
model = InviteLink
fields = ('username', 'group', 'valid_until')
help_texts = {
- 'username': _('A username is not required, if left blank the new user can choose one.')
+ 'username': _('A username is not required, if left blank the new user can choose one.') # noqa: E501
}
class UserCreateForm(forms.Form):
name = forms.CharField(label='Username')
- password = forms.CharField(widget=forms.TextInput(attrs={'autocomplete': 'new-password', 'type': 'password'}))
- password_confirm = forms.CharField(widget=forms.TextInput(attrs={'autocomplete': 'new-password', 'type': 'password'}))
+ password = forms.CharField(
+ widget=forms.TextInput(
+ attrs={'autocomplete': 'new-password', 'type': 'password'}
+ )
+ )
+ password_confirm = forms.CharField(
+ widget=forms.TextInput(
+ attrs={'autocomplete': 'new-password', 'type': 'password'}
+ )
+ )