diff options
-rw-r--r-- | app/birds/admin.py | 8 | ||||
-rw-r--r-- | app/utils/views.py | 1 | ||||
-rw-r--r-- | app/utils/widgets.py | 32 | ||||
-rw-r--r-- | design/sass/_writing_details.scss | 10 |
4 files changed, 49 insertions, 2 deletions
diff --git a/app/birds/admin.py b/app/birds/admin.py index b5c6a7e..a8e3a0b 100644 --- a/app/birds/admin.py +++ b/app/birds/admin.py @@ -4,6 +4,7 @@ from birds.models import BirdSighting, BirdAudio, BirdClass, Bird from photos.forms import GalleryForm from utils.util import get_latlon +from utils.widgets import CustomSelectMultiple class BirdClassAdmin(admin.ModelAdmin): @@ -20,9 +21,12 @@ class BirdAdmin(admin.ModelAdmin): class GalleryFormPlus(GalleryForm): def __init__(self, *args, **kwargs): - super(GalleryFormPlus, self).__init__(*args, **kwargs) self.base_fields['seen_by'].widget = CustomSelectMultiple() - + super(GalleryFormPlus, self).__init__(*args, **kwargs) + + class Meta: + model = BirdSighting + fields = '__all__' class BirdSightingAdmin(OSMGeoAdmin): form = GalleryFormPlus diff --git a/app/utils/views.py b/app/utils/views.py index 26253ff..108293e 100644 --- a/app/utils/views.py +++ b/app/utils/views.py @@ -1,6 +1,7 @@ from itertools import chain from django.views.generic import ListView from photos.models import LuxImage, LuxVideo +from django.shortcuts import render_to_response from django.shortcuts import render from django.template import RequestContext diff --git a/app/utils/widgets.py b/app/utils/widgets.py index 240820a..eac4631 100644 --- a/app/utils/widgets.py +++ b/app/utils/widgets.py @@ -25,6 +25,38 @@ def markdown_to_html(txt): return md.convert(txt) +class CustomSelectMultiple(SelectMultiple): + def render_options(self, choices, selected_choices): + if not selected_choices: + # there is CreatView and we have no selected choices - render all selected + render_option = self.render_option + else: + # there is UpdateView and we have selected choices - render as default + render_option = super(CustomSelectMultiple, self).render_option + + selected_choices = set(force_text(v) for v in selected_choices) + output = [] + for option_value, option_label in chain(self.choices, choices): + if isinstance(option_label, (list, tuple)): + output.append(format_html('<optgroup label="{0}">', force_text(option_value))) + for option in option_label: + output.append(render_option(selected_choices, *option)) + output.append('</optgroup>') + else: + + output.append(render_option(selected_choices, option_value, option_label)) + return '\n'.join(output) + + def render_option(self, selected_choices, option_value, option_label): + option_value = force_text(option_value) + selected_html = mark_safe(' selected="selected"') + + return format_html('<option value="{0}"{1}>{2}</option>', + option_value, + selected_html, + force_text(option_label)) + + class TagListFilter(admin.SimpleListFilter): # Human-readable title which will be displayed in the # right admin sidebar just above the filter options. diff --git a/design/sass/_writing_details.scss b/design/sass/_writing_details.scss index 95b8e37..8e011e5 100644 --- a/design/sass/_writing_details.scss +++ b/design/sass/_writing_details.scss @@ -408,6 +408,9 @@ figure.picwide img.picwide { float: right; margin-right: 0; } + figure:first-child { + float:left; + } } .pic66 { max-width: 63.9%; @@ -516,6 +519,13 @@ figure.picwide img.picwide { height: 100%; } +.post--body--single ul { + @include constrain_narrow(); + margin: 1em auto; + text-align: left; + list-style-type: disc; +} + //### PAGE NAVIGATION ### #page-navigation { margin: 2em auto; |