Skip to content
Permalink
42bfb3c0d5
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
57 lines (47 sloc) 1.39 KB
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_list = (
('Sources', 'Sources'),
('Studies', 'Studies'),
('Proceedings', 'Proceedings'),
('Textbooks', 'Textbooks'),
)
series = models.CharField(max_length=20, choices=series_list)
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.CASCADE
)
# 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