Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kthoden committed Aug 19, 2019
0 parents commit 92d2a23
Show file tree
Hide file tree
Showing 14 changed files with 186 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/eoaforthcoming/migrations/
/dist/
/django_eoaforthcoming.egg-info/
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Coffeeware
5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include LICENSE
include README.rst
recursive-include eoaforthcoming/static *
recursive-include eoaforthcoming/templates *
recursive-include docs *
17 changes: 17 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -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.
Empty file added eoaforthcoming/__init__.py
Empty file.
8 changes: 8 additions & 0 deletions eoaforthcoming/admin.py
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 6 additions & 0 deletions eoaforthcoming/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class EOAForthcomingConfig(AppConfig):
name = 'eoaforthcoming'
verbose_name = 'EOA Forthcoming'
23 changes: 23 additions & 0 deletions eoaforthcoming/cms_plugins.py
Original file line number Diff line number Diff line change
@@ -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']
53 changes: 53 additions & 0 deletions eoaforthcoming/models.py
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions eoaforthcoming/templates/eoaforthcoming/eoa-forthcoming.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% load cms_tags %}

<div class="project-teaser">
<div class="project-teaser__image">
<img src="{{ instance.eoaforthcoming.cover.url }}" data-object-fit="cover"/>
</div>
<div class="project-teaser-info">
<div class="project-teaser-info__category">{{ instance.eoaforthcoming.series }}</div>
<h2 class="project-teaser-info__title">{{ instance.eoaforthcoming.title }}</h2>
<div class="project-teaser-info__description">
<div class="expand-block">
<div class="expand-block__content">
<p>{{ instance.eoaforthcoming.description }}</p>
</div><a class="expand-block__more link" href="#">More</a>
</div>
</div>
<div class="project-teaser-info-authors"><span class="project-teaser-info__author-link">{{ instance.eoaforthcoming.author}}</span></div>
<div class="project-teaser-info__buttons"> </div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% load cms_tags %}

<section class="index__comin-soon">
<h1>Forthcoming</h1>
{% for plugin in instance.child_plugin_instances %}
{% render_plugin plugin %}
{% endfor %}
</section>
3 changes: 3 additions & 0 deletions eoaforthcoming/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions eoaforthcoming/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
36 changes: 36 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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',
],
)

0 comments on commit 92d2a23

Please sign in to comment.