Permalink
Cannot retrieve contributors at this time
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?
django-eoaforthcoming/eoaforthcoming/models.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
57 lines (47 sloc)
1.39 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |