mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2025-12-24 02:39:20 -05:00
cleand up form media
This commit is contained in:
1
.idea/dictionaries/vabene1111.xml
generated
1
.idea/dictionaries/vabene1111.xml
generated
@@ -3,6 +3,7 @@
|
||||
<words>
|
||||
<w>dropbox</w>
|
||||
<w>emoji</w>
|
||||
<w>multiselect</w>
|
||||
</words>
|
||||
</dictionary>
|
||||
</component>
|
||||
@@ -1,17 +1,17 @@
|
||||
from django.utils.translation import gettext as _
|
||||
from django import forms
|
||||
from .models import *
|
||||
from django.forms import widgets, TextInput, DateField
|
||||
from django.forms import widgets
|
||||
|
||||
|
||||
class MultiSelectWidget(widgets.SelectMultiple):
|
||||
class Media:
|
||||
js = ('custom/js/from_multiselect.js',)
|
||||
js = ('custom/js/form_multiselect.js',)
|
||||
|
||||
|
||||
class EmojiWidget(forms.TextInput):
|
||||
class Media:
|
||||
js = 'custom/js/form_emoji.js'
|
||||
js = ('custom/js/form_emoji.js',)
|
||||
|
||||
|
||||
class EditRecipeForm(forms.ModelForm):
|
||||
@@ -25,15 +25,21 @@ class EditRecipeForm(forms.ModelForm):
|
||||
'keywords': _('Keywords'),
|
||||
'path': _('Path'),
|
||||
}
|
||||
widgets = {'keywords': MultiSelectWidget}
|
||||
|
||||
|
||||
class EditCategoryForm(forms.ModelForm):
|
||||
class Media:
|
||||
js = ('custom/js/form_emoji.js',)
|
||||
|
||||
class CategoryForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Category
|
||||
fields = ('name', 'icon', 'description')
|
||||
widgets = {'icon': EmojiWidget}
|
||||
|
||||
|
||||
class KeywordForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Keyword
|
||||
fields = ('name', 'icon', 'description')
|
||||
widgets = {'icon': EmojiWidget}
|
||||
|
||||
|
||||
class MonitorForm(forms.Form):
|
||||
@@ -43,7 +49,10 @@ class MonitorForm(forms.Form):
|
||||
class BatchEditForm(forms.Form):
|
||||
search = forms.CharField(label=_('Search String'))
|
||||
category = forms.ModelChoiceField(queryset=Category.objects.all().order_by('id'), required=False)
|
||||
keyword = forms.ModelMultipleChoiceField(queryset=Keyword.objects.all().order_by('id'), required=False)
|
||||
keywords = forms.ModelMultipleChoiceField(queryset=Keyword.objects.all().order_by('id'), required=False)
|
||||
|
||||
class Media:
|
||||
js = ('custom/js/form_multiselect.js',)
|
||||
|
||||
|
||||
class ImportRecipeForm(forms.ModelForm):
|
||||
@@ -57,3 +66,4 @@ class ImportRecipeForm(forms.ModelForm):
|
||||
'keywords': _('Keywords'),
|
||||
'path': _('Path'),
|
||||
}
|
||||
widgets = {'keywords': MultiSelectWidget}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
$(document).ready(function () {
|
||||
$('#id_keywords').select2();
|
||||
$('.selectmultiple').select2();
|
||||
});
|
||||
@@ -5,6 +5,10 @@
|
||||
|
||||
{% block title %}{% trans 'Batch edit Category' %}{% endblock %}
|
||||
|
||||
{% block extra_head %}
|
||||
{{ form.media }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h3>
|
||||
@@ -23,12 +27,4 @@
|
||||
<input type="submit" value="Submit" class="btn btn-success">
|
||||
</form>
|
||||
|
||||
<script>
|
||||
//TODO clean this up
|
||||
//converts multiselct in recipe edit to searchable multiselect
|
||||
//shitty solution that needs to be redone at some point
|
||||
$(document).ready(function () {
|
||||
$('#id_keyword').select2();
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -4,6 +4,10 @@
|
||||
|
||||
{% block title %}{% trans 'Delete' %} - {{ title }}{% endblock %}
|
||||
|
||||
{% block extra_head %}
|
||||
{{ form.media }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h3>{% trans 'Delete' %} {{ title }}</h3>
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
|
||||
{% block title %}{% trans 'New' %} - {{ title }}{% endblock %}
|
||||
|
||||
{% block extra_head %}
|
||||
{{ form.media }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h3>{% trans 'New' %} {{ title }} </h3>
|
||||
@@ -15,15 +19,4 @@
|
||||
<input type="submit" value="Submit" class="btn btn-success">
|
||||
</form>
|
||||
|
||||
|
||||
<script>
|
||||
//TODO clean this up
|
||||
//converts multiselct in recipe edit to searchable multiselect
|
||||
//shitty solution that needs to be redone at some point
|
||||
$(document).ready(function () {
|
||||
$('#id_keywords').select2();
|
||||
$('#id_icon').emojioneArea();
|
||||
});
|
||||
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -4,7 +4,7 @@ from django.urls import reverse_lazy, reverse
|
||||
from django.utils.translation import gettext as _
|
||||
from django.views.generic import UpdateView, DeleteView
|
||||
|
||||
from cookbook.forms import EditRecipeForm, EditCategoryForm
|
||||
from cookbook.forms import EditRecipeForm, CategoryForm, KeywordForm
|
||||
from cookbook.models import Recipe, Category, Sync, Keyword, RecipeImport
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class MonitorUpdate(LoginRequiredMixin, UpdateView):
|
||||
class CategoryUpdate(LoginRequiredMixin, UpdateView):
|
||||
template_name = "generic\edit_template.html"
|
||||
model = Category
|
||||
form_class = EditCategoryForm
|
||||
form_class = CategoryForm
|
||||
|
||||
# TODO add msg box
|
||||
|
||||
@@ -43,7 +43,7 @@ class CategoryUpdate(LoginRequiredMixin, UpdateView):
|
||||
class KeywordUpdate(LoginRequiredMixin, UpdateView):
|
||||
template_name = "generic\edit_template.html"
|
||||
model = Keyword
|
||||
fields = ['name', 'icon', 'description']
|
||||
form_class = KeywordForm
|
||||
|
||||
# TODO add msg box
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from django.urls import reverse_lazy
|
||||
from django.utils.translation import gettext as _
|
||||
from django.views.generic import CreateView
|
||||
|
||||
from cookbook.forms import ImportRecipeForm, RecipeImport
|
||||
from cookbook.forms import ImportRecipeForm, RecipeImport, CategoryForm, KeywordForm
|
||||
from cookbook.models import Category, Keyword, Recipe
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class RecipeCreate(LoginRequiredMixin, CreateView): # this exists for completen
|
||||
class CategoryCreate(LoginRequiredMixin, CreateView):
|
||||
template_name = "generic\\new_template.html"
|
||||
model = Category
|
||||
fields = ['name', 'icon', 'description']
|
||||
form_class = CategoryForm
|
||||
success_url = reverse_lazy('list_category')
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
@@ -37,7 +37,7 @@ class CategoryCreate(LoginRequiredMixin, CreateView):
|
||||
class KeywordCreate(LoginRequiredMixin, CreateView):
|
||||
template_name = "generic\\new_template.html"
|
||||
model = Keyword
|
||||
fields = ['name', 'icon', 'description']
|
||||
form_class = KeywordForm
|
||||
success_url = reverse_lazy('list_keyword')
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user