diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e3aab5b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/eoaforthcoming/migrations/ +/dist/ +/django_eoaforthcoming.egg-info/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..65eddd9 --- /dev/null +++ b/LICENSE @@ -0,0 +1 @@ +Coffeeware \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..c727bcd --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,5 @@ +include LICENSE +include README.rst +recursive-include eoaforthcoming/static * +recursive-include eoaforthcoming/templates * +recursive-include docs * \ No newline at end of file diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..86d1209 --- /dev/null +++ b/README.rst @@ -0,0 +1,17 @@ +===== +EOA List of Forthcoming books +===== + +EOA Forthcoming is a Django app for displaying forthcoming books of the Edition Open Access. + +Quick start +----------- + +1. Add "eoaforthcoming" to your INSTALLED_APPS setting like this:: + + INSTALLED_APPS = [ + ... + 'eoaforthcoming', + ] + +2. Run `python manage.py migrate` to create the models. diff --git a/eoaforthcoming/__init__.py b/eoaforthcoming/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/eoaforthcoming/admin.py b/eoaforthcoming/admin.py new file mode 100644 index 0000000..c6496c0 --- /dev/null +++ b/eoaforthcoming/admin.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8; mode: python -*- + +from django.contrib import admin +from .models import Forthcoming + + +# Register your models here: +admin.site.register(Forthcoming) diff --git a/eoaforthcoming/apps.py b/eoaforthcoming/apps.py new file mode 100644 index 0000000..4374de8 --- /dev/null +++ b/eoaforthcoming/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class EOAForthcomingConfig(AppConfig): + name = 'eoaforthcoming' + verbose_name = 'EOA Forthcoming' diff --git a/eoaforthcoming/cms_plugins.py b/eoaforthcoming/cms_plugins.py new file mode 100644 index 0000000..91963dd --- /dev/null +++ b/eoaforthcoming/cms_plugins.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8; mode: python -*- +from cms.plugin_base import CMSPluginBase +from cms.plugin_pool import plugin_pool +# from django.contrib import admin +from django.conf import settings + +from . import models + +@plugin_pool.register_plugin # register the plugin +class EOAForthcomingList(CMSPluginBase): + model = models.EOAForthcomingListModel + name = "EOA Forthcoming list" + render_template = 'eoaforthcoming/eoa-forthcominglist.html' + allow_children = True + child_classes = ['EOAForthcoming'] + +@plugin_pool.register_plugin # register the plugin +class EOAForthcoming(CMSPluginBase): + model = models.EOAForthcomingModel + name = "EOA Forthcoming" + render_template = 'eoaforthcoming/eoa-forthcoming.html' + require_parent = True + parent_classes = ['EOAForthcomingList'] diff --git a/eoaforthcoming/models.py b/eoaforthcoming/models.py new file mode 100644 index 0000000..27be912 --- /dev/null +++ b/eoaforthcoming/models.py @@ -0,0 +1,53 @@ +from django.db import models + +# Create your models here. +from cms.models import CMSPlugin, Model + +class Forthcoming(Model): + title = models.CharField( + max_length=200, + unique=True + ) + series = models.CharField( + max_length=200, + unique=True + ) + author = models.CharField( + max_length=200, + unique=True + ) + description = models.CharField( + max_length=1000 + ) + cover = models.ImageField( + upload_to='eoaforthcoming/images' + ) + + # functions: + def __str__(self): + return self.title + +class EOAForthcomingListModel(CMSPlugin): + + # functions: + def __str__(self): + return str(self.id) + +class EOAForthcomingModel(CMSPlugin): + eoaforthcoming = models.ForeignKey( + Forthcoming, on_delete=models.PROTECT + ) + + # functions: + def __str__(self): + return self.eoaforthcoming.title + + @property + def layout(self): + instance, plugin_class = self.parent.get_plugin_instance() + return instance.layout + + def copy_relations(self, oldinstance): + # Because we have a ForeignKey, it's required to copy over + # the reference to the referenced instance to the new plugin. + self.eoaforthcoming = oldinstance.eoaforthcoming diff --git a/eoaforthcoming/templates/eoaforthcoming/eoa-forthcoming.html b/eoaforthcoming/templates/eoaforthcoming/eoa-forthcoming.html new file mode 100644 index 0000000..b08d041 --- /dev/null +++ b/eoaforthcoming/templates/eoaforthcoming/eoa-forthcoming.html @@ -0,0 +1,20 @@ +{% load cms_tags %} + +
+
+ +
+
+
{{ instance.eoaforthcoming.series }}
+

{{ instance.eoaforthcoming.title }}

+
+
+
+

{{ instance.eoaforthcoming.description }}

+
More +
+
+
{{ instance.eoaforthcoming.author}}
+
+
+
diff --git a/eoaforthcoming/templates/eoaforthcoming/eoa-forthcominglist.html b/eoaforthcoming/templates/eoaforthcoming/eoa-forthcominglist.html new file mode 100644 index 0000000..655d33c --- /dev/null +++ b/eoaforthcoming/templates/eoaforthcoming/eoa-forthcominglist.html @@ -0,0 +1,8 @@ +{% load cms_tags %} + +
+

Forthcoming

+ {% for plugin in instance.child_plugin_instances %} + {% render_plugin plugin %} + {% endfor %} +
diff --git a/eoaforthcoming/tests.py b/eoaforthcoming/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/eoaforthcoming/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/eoaforthcoming/views.py b/eoaforthcoming/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/eoaforthcoming/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..1315631 --- /dev/null +++ b/setup.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8; mode: python -*- + +import os +from setuptools import find_packages, setup + +with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as readme: + README = readme.read() + +# allow setup.py to be run from any path +os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) + +setup( + name='django-eoaforthcoming', + version='1.0', + packages=find_packages(), + include_package_data=True, + license='Coffeeware', # example license + description='A Django app for displaying forthcoming EOA books.', + long_description=README, + url='http://www.edition-open-access.de/', + author='Klaus Thoden', + author_email='kthoden@mpiwg-berlin.mpg.de', + classifiers=[ + 'Environment :: Web Environment', + 'Framework :: Django', + 'Framework :: Django :: 1.8', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: Coffeeware', + 'Operating System :: OS Independent', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Topic :: Internet :: WWW/HTTP', + 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', + ], +)