basic custom media working
This commit is contained in:
1
.idea/dictionaries/vabene1111.xml
generated
1
.idea/dictionaries/vabene1111.xml
generated
@ -2,6 +2,7 @@
|
|||||||
<dictionary name="vabene1111">
|
<dictionary name="vabene1111">
|
||||||
<words>
|
<words>
|
||||||
<w>dropbox</w>
|
<w>dropbox</w>
|
||||||
|
<w>emoji</w>
|
||||||
</words>
|
</words>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
</component>
|
</component>
|
@ -1,6 +1,17 @@
|
|||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
from django import forms
|
from django import forms
|
||||||
from .models import *
|
from .models import *
|
||||||
|
from django.forms import widgets, TextInput, DateField
|
||||||
|
|
||||||
|
|
||||||
|
class MultiSelectWidget(widgets.SelectMultiple):
|
||||||
|
class Media:
|
||||||
|
js = ('custom/js/from_multiselect.js',)
|
||||||
|
|
||||||
|
|
||||||
|
class EmojiWidget(forms.TextInput):
|
||||||
|
class Media:
|
||||||
|
js = 'custom/js/form_emoji.js'
|
||||||
|
|
||||||
|
|
||||||
class EditRecipeForm(forms.ModelForm):
|
class EditRecipeForm(forms.ModelForm):
|
||||||
@ -16,6 +27,15 @@ class EditRecipeForm(forms.ModelForm):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class EditCategoryForm(forms.ModelForm):
|
||||||
|
class Media:
|
||||||
|
js = ('custom/js/form_emoji.js',)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Category
|
||||||
|
fields = ('name', 'icon', 'description')
|
||||||
|
|
||||||
|
|
||||||
class MonitorForm(forms.Form):
|
class MonitorForm(forms.Form):
|
||||||
path = forms.CharField(label=_('Path'))
|
path = forms.CharField(label=_('Path'))
|
||||||
|
|
||||||
|
3
cookbook/static/custom/js/form_emoji.js
Normal file
3
cookbook/static/custom/js/form_emoji.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
$(document).ready(function () {
|
||||||
|
$('#id_icon').emojioneArea();
|
||||||
|
});
|
3
cookbook/static/custom/js/form_multiselect.js
Normal file
3
cookbook/static/custom/js/form_multiselect.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
$(document).ready(function () {
|
||||||
|
$('#id_keywords').select2();
|
||||||
|
});
|
@ -26,6 +26,9 @@
|
|||||||
<link rel="stylesheet" href="{% static "emojionearea/emojionearea.min.css" %}">
|
<link rel="stylesheet" href="{% static "emojionearea/emojionearea.min.css" %}">
|
||||||
<script type="text/javascript" src="{% static "emojionearea/emojionearea.min.js" %}"></script>
|
<script type="text/javascript" src="{% static "emojionearea/emojionearea.min.js" %}"></script>
|
||||||
|
|
||||||
|
{% block extra_head %} <!-- block for templates to put stuff into header -->
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@media (max-width: 1025px) {
|
@media (max-width: 1025px) {
|
||||||
.container {
|
.container {
|
||||||
|
@ -4,6 +4,10 @@
|
|||||||
|
|
||||||
{% block title %}{% trans 'Edit' %} - {{ title }}{% endblock %}
|
{% block title %}{% trans 'Edit' %} - {{ title }}{% endblock %}
|
||||||
|
|
||||||
|
{% block extra_head %}
|
||||||
|
{{ form.media }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<h3>{% trans 'Edit' %} {{ title }}</h3>
|
<h3>{% trans 'Edit' %} {{ title }}</h3>
|
||||||
@ -14,14 +18,4 @@
|
|||||||
<input type="submit" value="Submit" class="btn btn-success">
|
<input type="submit" value="Submit" class="btn btn-success">
|
||||||
</form>
|
</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 %}
|
{% endblock %}
|
@ -4,7 +4,7 @@ from django.urls import reverse_lazy, reverse
|
|||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
from django.views.generic import UpdateView, DeleteView
|
from django.views.generic import UpdateView, DeleteView
|
||||||
|
|
||||||
from cookbook.forms import EditRecipeForm
|
from cookbook.forms import EditRecipeForm, EditCategoryForm
|
||||||
from cookbook.models import Recipe, Category, Sync, Keyword, RecipeImport
|
from cookbook.models import Recipe, Category, Sync, Keyword, RecipeImport
|
||||||
|
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ class MonitorUpdate(LoginRequiredMixin, UpdateView):
|
|||||||
class CategoryUpdate(LoginRequiredMixin, UpdateView):
|
class CategoryUpdate(LoginRequiredMixin, UpdateView):
|
||||||
template_name = "generic\edit_template.html"
|
template_name = "generic\edit_template.html"
|
||||||
model = Category
|
model = Category
|
||||||
fields = ['name', 'icon', 'description']
|
form_class = EditCategoryForm
|
||||||
|
|
||||||
# TODO add msg box
|
# TODO add msg box
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user