+
+VALUE_TYPES = {
+ LegimiCategory: {
+ 'widget': 'select',
+ 'options': [''] + list(Legimi.CATEGORIES.keys()),
+ },
+ Audience: {
+ 'autocomplete': {
+ 'source': '/catalogue/terms/audience/',
+ }
+ },
+ ThemaCategory: {
+ 'autocomplete': {
+ 'source': '/catalogue/terms/thema/',
+ },
+ 'chooser': {
+ 'source': '/catalogue/chooser/thema/',
+ },
+ },
+ MainThemaCategory: {
+ 'autocomplete': {
+ 'source': '/catalogue/terms/thema-main/',
+ },
+ 'chooser': {
+ 'source': '/catalogue/chooser/thema-main/',
+ },
+ },
+ Epoch: {
+ 'autocomplete': {
+ 'source': '/catalogue/terms/epoch/',
+ }
+ },
+ Kind: {
+ 'autocomplete': {
+ 'source': '/catalogue/terms/kind/',
+ }
+ },
+ Genre: {
+ 'autocomplete': {
+ 'source': '/catalogue/terms/genre/',
+ }
+ },
+ WLURI: {
+ "autocomplete": {
+ "source": "/catalogue/terms/wluri/",
+ }
+ },
+ "authors": {
+ "autocomplete": {
+ "source": "/catalogue/terms/author/",
+ }
+ },
+ "translators": {
+ "autocomplete": {
+ "source": "/catalogue/terms/author/",
+ }
+ },
+ "editors": {
+ "autocomplete": {
+ "source": "/catalogue/terms/editor/",
+ }
+ },
+ "technical_editors": {
+ "autocomplete": {
+ "source": "/catalogue/terms/editor/",
+ }
+ },
+ "type": {
+ "autocomplete": {
+ "source": ["text"]
+ }
+ },
+ "title": {
+ "autocomplete": {
+ "source": "/catalogue/terms/book_title/",
+ }
+ },
+
+ "language": {
+ 'widget': 'select',
+ 'options': [
+ '',
+ 'pol',
+ 'eng',
+ 'fre',
+ 'ger',
+ 'lit',
+ ],
+ },
+ "publisher": {
+ "autocomplete": {
+ "source": ["Fundacja Wolne Lektury"]
+ }
+ },
+
+}
+
+
+
+class MetaTagsView(View):
+ def get(self, request):
+ fields = []
+ for f in BookInfo.FIELDS:
+ d = {
+ 'name': f.name,
+ 'required': f.required,
+ 'multiple': f.multiple,
+ 'uri': f.uri,
+ 'value_type': {
+ 'hasLanguage': f.value_type.has_language,
+ 'name': f.value_type.__name__,
+ }
+ }
+ d['value_type'].update(
+ VALUE_TYPES.get(
+ f.value_type,
+ VALUE_TYPES.get(
+ f.name,
+ {}
+ )
+ )
+ )
+ if d['name'] == 'thema':
+ d_loc = d.copy()
+ d_time = d.copy()
+ d['filter'] = {'not': {'startswith': ['1', '3']}}
+ d_loc['filter'] = {'startswith': ['1']}
+ d_loc['name'] += ' (miejsca)'
+ d_time['filter'] = {'startswith': ['3']}
+ d_time['name'] += ' (czas)'
+ fields.extend([d, d_loc, d_time])
+ else:
+ fields.append(d)
+
+ return HttpResponse(
+ 'let META_FIELDS = ' + json.dumps(fields),
+ content_type='text/javascript')
+