Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmundy committed Jul 9, 2019
2 parents 249de4c + 52621e2 commit 94a4619
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 17 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,7 @@ We use the [Git-Flow](https://danielkummer.github.io/git-flow-cheatsheet/) branc
## License

This software is distributed under the Apache 2.0 License.

## Autocomplete

Use the fork of Wagtail Autocomplete because of UUID. https://github.com/jcmundy/wagtail-autocomplete
2 changes: 1 addition & 1 deletion apps/cms/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class HomePageAdmin(admin.ModelAdmin):
search_fields = ('featured_volumes', 'featured_collections')
autocomplete_fields = ('featured_volumes', 'featured_collections')
autocomplete_fields = ('featured_volumes',)
class Meta:
model = HomePage

Expand Down
17 changes: 9 additions & 8 deletions apps/cms/models.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
from django.db import models
from django import forms
from ..iiif.kollections.models import Collection
from ..iiif.manifests.models import Manifest

from wagtail.core.models import Page
from modelcluster.models import ClusterableModel
from wagtail.core.fields import RichTextField, StreamField
#from wagtailautocomplete.edit_handlers import AutocompletePanel
from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel, InlinePanel

from modelcluster.fields import ParentalKey, ParentalManyToManyField
from wagtailautocomplete.edit_handlers import AutocompletePanel
from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel, InlinePanel

from .blocks import BaseStreamBlock
from ..iiif.kollections.models import Collection
from ..iiif.manifests.models import Manifest
from ..iiif import manifests



class ContentPage(Page):
Expand Down Expand Up @@ -46,11 +47,11 @@ class HomePage(Page):
volumes = Manifest.objects.all

content_panels = Page.content_panels + [
# AutocompletePanel('featured_volume', target_model='manifests.Manifest'),
FieldPanel('tagline', classname="full"),
FieldPanel('content_display', classname="full"),
FieldPanel('featured_collections', widget=forms.CheckboxSelectMultiple, classname="full"),
FieldPanel('featured_collections_sort_order', classname="full"),
FieldPanel('featured_volumes', widget=forms.CheckboxSelectMultiple, classname="full"),
AutocompletePanel('featured_volumes'),
#FieldPanel('featured_volumes', widget=forms.CheckboxSelectMultiple, classname="full"),
FieldPanel('featured_volumes_sort_order', classname="full"),
]
2 changes: 1 addition & 1 deletion apps/iiif/manifests/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ManifestAdmin(ImportExportModelAdmin, admin.ModelAdmin):
pass
filter_horizontal = ('collections',)
list_display = ('id', 'pid', 'label', 'author', 'published_date', 'published_city', 'publisher')
search_fields = ('label','author','published_date')
search_fields = ('id', 'label','author','published_date')


class NoteAdmin(admin.ModelAdmin):
Expand Down
19 changes: 14 additions & 5 deletions apps/iiif/manifests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@
import config.settings.local as settings
from ..kollections.models import Collection
from django.contrib.postgres.fields import JSONField
#from wagtailautocomplete.edit_handlers import AutocompletePanel
from modelcluster.models import ClusterableModel
from wagtailautocomplete.edit_handlers import AutocompletePanel
from json import JSONEncoder
import uuid
from uuid import UUID
#trying to work with autocomplete
JSONEncoder_olddefault = JSONEncoder.default
def JSONEncoder_newdefault(self, o):
if isinstance(o, UUID): return str(o)
return JSONEncoder_olddefault(self, o)
JSONEncoder.default = JSONEncoder_newdefault

class Manifest(models.Model):
class Manifest(ClusterableModel):
DIRECTIONS = (
('left-to-right', 'Left to Right'),
('right-to-left', 'Right to Left')
Expand All @@ -25,7 +34,7 @@ class Manifest(models.Model):
viewingDirection = models.CharField(max_length=13, choices=DIRECTIONS, default="left-to-right")
created_at = models.DateTimeField(auto_now_add=True)
#starting_page = models.ForeignKey('canvases.Canvas', related_name="first", on_delete=models.SET_NULL, null=True, blank=True, help_text="Choose the page that will show on loading.")
# autocomplete_search_field = 'label'
autocomplete_search_field = 'label'

@property
def note_list(self):
Expand All @@ -44,8 +53,8 @@ def start_canvas(self):
first = self.canvas_set.all().exclude(is_starting_page=False).first()
return first.identifier if first else self.canvas_set.all().first().identifier

# def autocomplete_label(self):
# return self.label
def autocomplete_label(self):
return self.label

def __str__(self):
return self.label
Expand Down
4 changes: 4 additions & 0 deletions apps/readux/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from django.conf.urls import url, include
from django.urls import path
from django.views.generic import RedirectView
from . import views
# from .views import PageRedirectView

urlpatterns = [
#path('', views.CollectionsList.as_view(), name='home' ),
Expand All @@ -9,5 +11,7 @@
# url for page altered to prevent conflict with Wagtail
# TODO: find another way to resolve this conflict
path('col/<collection>/vol/<volume>/page/<page>', views.PageDetail.as_view(), name='page' ),
# path('col/<collection>/vol/<volume>/page/', RedirectView.as_view(pattern_name='page'), name='page 1' ),
# path('col/<collection>/vol/<volume>/page/', PageRedirectView.as_view(), name='page 1' ),
path('col/<collection>/vol/<volume>/export', views.ExportOptions.as_view(), name='export' ),
]
23 changes: 22 additions & 1 deletion apps/readux/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ..iiif.canvases.models import Canvas
from ..iiif.manifests.models import Manifest
from ..iiif.annotations.models import Annotation

from django.views.generic.base import RedirectView

class CollectionsList(ListView):
template_name = "collections.html"
Expand Down Expand Up @@ -67,6 +67,27 @@ def get_context_data(self, **kwargs):
context['user_annotation_count'] = Annotation.objects.filter(owner_id=self.request.user.id).filter(canvas__manifest__id=manifest.id).count()
return context

# class PageRedirect(TemplateView):
# template_name = "page.html"
#
# def get_context_data(self, **kwargs):
# context = super().get_context_data(**kwargs)
# context['page'] = Canvas.objects.first()
# manifest = Manifest.objects.filter(pid=kwargs['volume']).first()
# context['volume'] = manifest
# context['user_annotation_count'] = Annotation.objects.filter(owner_id=self.request.user.id).filter(canvas__manifest__id=manifest.id).count()
# return context
# class PageRedirectView(RedirectView):
#
# permanent = False
# query_string = True
# pattern_name = 'page-redirect'
#
# def get_redirect_url(self, *args, **kwargs):
# page = Manifest.canvas_set.first()
# return super().get_redirect_url(*args, **kwargs)


class ExportOptions(TemplateView):
template_name = "export.html"

Expand Down
Binary file modified apps/static/images/readux_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
# path("accounts/", include("allauth.urls")),
# Your stuff: custom urls includes go here
url(r'^', include('apps.readux.urls')),
url(r'^admin/autocomplete/', include(autocomplete_admin_urls)),
re_path(r'', include(wagtail_urls)),


Expand Down

0 comments on commit 94a4619

Please sign in to comment.