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-eoapublications/eoapublications/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.
287 lines (261 sloc)
12.7 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
# -*- coding: utf-8 -*- | |
from django.db import models | |
def filepath_publication(instance, filename): | |
strPublicationSerie = instance.Serie | |
strPublicationNumber = str(instance.Number) | |
strFilePath = strPublicationSerie.lower() + "/" + strPublicationNumber + "/" + filename | |
return strFilePath | |
def filepath_chapter(instance, filename): | |
strPublicationSerie = instance.Publication.Serie | |
strPublicationNumber = str(instance.Publication.Number) | |
strChapterOrder = str(instance.Order) | |
strFilePath = strPublicationSerie.lower() + "/" + strPublicationNumber + "/" + strChapterOrder + "/" + filename | |
return strFilePath | |
class Publication(models.Model): | |
############################################# | |
# Publication serves as main container # | |
############################################# | |
# Organizational Data | |
Published = models.BooleanField() | |
Featured = models.BooleanField() | |
SERIES = ( | |
('sources', 'Sources'), | |
('studies', 'Studies'), | |
('essays', 'Essays'), | |
('proceedings', 'Proceedings'), | |
('textbooks', 'Textbooks'), | |
) | |
Serie = models.CharField(max_length=20, choices=SERIES) | |
Number = models.IntegerField() | |
# Visible Information | |
Title = models.CharField(max_length=1000) | |
Subtitle = models.CharField(max_length=1000, blank=True) | |
Datepublished = models.DateField() | |
LANGUAGES = ( | |
('de', 'German'), | |
('en', 'English'), | |
('it', 'Italian') | |
) | |
Language = models.CharField(max_length=2, choices=LANGUAGES) | |
LICENSES = ( | |
('by-nc-sa', 'Creative Commons Attribution-Non Commercial-Share Alike 3.0 Germany cc by-nc-sa 3.0 (Standard for EOA)'), | |
('by-sa', 'Creative Commons Attribution-ShareAlike 4.0 International License cc by-sa 4.0'), | |
('commcercial', 'This may be a commercial license in the future.') | |
) | |
Publicationlicense = models.CharField(max_length=10, choices=LICENSES) | |
Doipublication = models.CharField(max_length=1000, blank=True) | |
Isbn = models.CharField(max_length=1000, blank=True) | |
Pages = models.CharField(max_length=10, blank=True) | |
Shoplink = models.CharField(max_length=1000, blank=True) | |
Price = models.CharField(max_length=1000, blank=True) | |
Descriptionshort = models.TextField(blank=True) | |
Descriptionlong = models.TextField(blank=True) | |
Submitter = models.CharField(max_length=1000, blank=True) | |
Editorialcoordination = models.CharField(max_length=1000, blank=True) | |
Copyeditor = models.CharField(max_length=1000, blank=True) | |
Translator = models.CharField(max_length=1000, blank=True) | |
Suggestedcitation = models.CharField(max_length=4000, blank=True) | |
Additionalinfo = models.TextField(blank=True) | |
Dedication = models.CharField(max_length=4000,blank=True) | |
Publicationauthor1 = models.CharField(max_length=200, blank=True) | |
Publicationauthor1number = models.IntegerField(null=True,blank=True) | |
Publicationauthor2 = models.CharField(max_length=200, blank=True) | |
Publicationauthor2number = models.IntegerField(null=True,blank=True) | |
Publicationauthor3 = models.CharField(max_length=200, blank=True) | |
Publicationauthor3number = models.IntegerField(null=True,blank=True) | |
Publicationauthor4 = models.CharField(max_length=200, blank=True) | |
Publicationauthor4number = models.IntegerField(null=True,blank=True) | |
Publicationauthor5 = models.CharField(max_length=200, blank=True) | |
Publicationauthor5number = models.IntegerField(null=True,blank=True) | |
Publicationauthorsuffix = models.CharField(max_length=200, blank=True) | |
Publicationpdffile = models.FileField(upload_to=filepath_publication, blank=True) | |
Publicationebookfile = models.FileField(upload_to=filepath_publication, blank=True) | |
# Cover Images | |
Coverbig = models.ImageField(upload_to=filepath_publication) | |
Coverbigwidth = models.IntegerField(null=True) | |
Coverbigheight = models.IntegerField(null=True) | |
Covermedium = models.ImageField(upload_to=filepath_publication) | |
Covermediumwidth = models.IntegerField(null=True) | |
Covermediumheight = models.IntegerField(null=True) | |
Coversmall = models.ImageField(upload_to=filepath_publication) | |
Coversmallwidth = models.IntegerField(null=True) | |
Coversmallheight = models.IntegerField(null=True) | |
Coversmallright = models.ImageField(upload_to=filepath_publication) | |
Coversmallrightwidth = models.IntegerField(null=True) | |
Coversmallrightheight = models.IntegerField(null=True) | |
def __str__(self): | |
# def __unicode__(self): | |
return self.Title | |
class Chapter(models.Model): | |
############################################# | |
# Chapter linked with Publication # | |
############################################# | |
# Link to Publication | |
Publication = models.ForeignKey(Publication, on_delete=models.CASCADE) | |
# Order within the publication (used for sorting) | |
Order = models.IntegerField(null=False) | |
# Language used for translating various strings like "Footnotes" | |
Chapterlanguage = models.CharField(max_length=20, blank=True) | |
# Alternative Types of Chapters (Facsimile and Imagecollection) | |
Facsimile = models.BooleanField(blank=True,default=False) | |
Imagecollection = models.BooleanField(blank=True,default=False) | |
# Information to be presented to the visitor | |
Number = models.CharField(max_length=20, blank=True) | |
Title = models.CharField(max_length=1000) | |
Chapterauthor1 = models.CharField(max_length=200, blank=True) | |
Chapterauthor1number = models.IntegerField(null=True,blank=True) | |
Chapterauthor1profile = models.BooleanField(blank=True,default=False) | |
Chapterauthor2 = models.CharField(max_length=200, blank=True) | |
Chapterauthor2number = models.IntegerField(null=True,blank=True) | |
Chapterauthor2profile = models.BooleanField(blank=True,default=False) | |
Chapterauthor3 = models.CharField(max_length=200, blank=True) | |
Chapterauthor3number = models.IntegerField(null=True,blank=True) | |
Chapterauthor3profile = models.BooleanField(blank=True,default=False) | |
Chapterauthor4 = models.CharField(max_length=200, blank=True) | |
Chapterauthor4number = models.IntegerField(null=True,blank=True) | |
Chapterauthor4profile = models.BooleanField(blank=True,default=False) | |
Chapterauthor5 = models.CharField(max_length=200, blank=True) | |
Chapterauthor5number = models.IntegerField(null=True,blank=True) | |
Chapterauthor5profile = models.BooleanField(blank=True,default=False) | |
Doichapter = models.CharField(max_length=1000, blank=True) | |
Suggestedchaptercitation = models.CharField(max_length=1000, blank=True) | |
Chapterpdffile = models.FileField(upload_to=filepath_chapter, blank=True) | |
# Special Entry for a Part to be displayed before the chapter | |
Chapterpart = models.CharField(max_length=200, blank=True) | |
def __str__(self): | |
# def __unicode__(self): | |
return self.Title | |
class Element(models.Model): | |
############################################# | |
# Elements linked with Chapter # | |
############################################# | |
# Link to Publication and Chapter | |
Publication = models.ForeignKey(Publication, on_delete=models.CASCADE) | |
Chapter = models.ForeignKey(Chapter, on_delete=models.CASCADE) | |
Order = models.IntegerField() | |
# Definition of the various Kinds of Elements | |
KINDS = ( | |
('eoaparagraph', 'Paragraph'), | |
('eoaquotedparagraph', 'Quoted Paragraph'), | |
('eoafigure', 'Figure'), | |
('eoasection', 'Section'), | |
('eoasubsection', 'Subsection'), | |
('eoasubsubsection', 'Subsubsection'), | |
('eoaequation', 'Equation'), | |
('eoatranscription', 'Transcription'), | |
('eoatheorem', 'Theorem'), | |
('eoatable', 'Table'), | |
('eoafootnote', 'Footnote'), | |
('eoafacsimilepage', 'Facsimile Page'), | |
('eoadescription', 'Description'), | |
# ('eoatheorem', 'Theorem'), | |
('eoaletterhead', 'Letterhead'), | |
('eoadivider', 'Divider') | |
) | |
Kind = models.CharField(max_length=30,choices=KINDS) | |
Boxed = models.BooleanField(default=False) | |
# Various Fields which may show up in an element | |
HIElement = models.TextField(blank=True, default="") | |
Number = models.CharField(max_length=1000,blank=True) | |
Indentation = models.BooleanField(blank=True,default=False) | |
Listcharacter = models.CharField(max_length=1000,blank=True) | |
Fulltext = models.TextField(blank=True) | |
Caption = models.TextField(blank=True) | |
Figureimagebig = models.ImageField(upload_to=filepath_chapter, blank=True) | |
Figureimagebigwidth = models.IntegerField(blank=True,null=True) | |
Figureimagebigheight = models.IntegerField(blank=True,null=True) | |
Figureimagenormal = models.ImageField(upload_to=filepath_chapter, blank=True) | |
Figureimagenormalwidth = models.IntegerField(blank=True,null=True) | |
Figureimagenormalheight = models.IntegerField(blank=True,null=True) | |
Genericimage = models.ImageField(upload_to=filepath_chapter, blank=True) | |
Transcriptionleftpage = models.TextField(blank=True) | |
Transcriptionleftheader = models.CharField(max_length=1000,blank=True) | |
Transcriptionrightpage = models.TextField(blank=True) | |
Transcriptionrightheader = models.CharField(max_length=1000,blank=True) | |
Theoremtitle = models.TextField(blank=True) | |
Theoremdescription = models.TextField(blank=True) | |
Tablehtml = models.TextField(blank=True) | |
Tablewidth = models.CharField(max_length=4,blank=True) | |
Texcode = models.TextField(blank=True) | |
Facsimiletext = models.TextField(blank=True) | |
Facsimilepollux = models.TextField(blank=True) | |
Facsimilexml = models.TextField(blank=True) | |
Letterrecipient = models.TextField(blank=True) | |
Letterarchive = models.TextField(blank=True) | |
Letteradditional = models.TextField(blank=True) | |
Letterpages = models.TextField(blank=True) | |
@property | |
def Supplements(self): | |
return Supplement.objects.filter(Element=self).all() | |
@property | |
def Indexelements(self): | |
return Indexelement.objects.filter(Element=self).all() | |
def __str__(self): | |
# def __unicode__(self): | |
return self.Kind | |
class Indexsection(models.Model): | |
############################################# | |
# Section linked with Publication # | |
############################################# | |
# Link to Publication | |
Publication = models.ForeignKey(Publication, on_delete=models.CASCADE) | |
KINDS = ( | |
('keyword', 'Regular Keyword Index'), | |
('person', 'Person Index'), | |
('location', 'Index of Locations'), | |
) | |
# Definition of some Elements | |
Kind = models.CharField(choices=KINDS,max_length=30) | |
Order = models.IntegerField(null=True) | |
Title = models.CharField(max_length=300, blank=True) | |
Html = models.TextField(blank=True) | |
def __str__(self): | |
# def __unicode__(self): | |
return self.Title | |
class Indexelement(models.Model): | |
############################################# | |
# Indexelement linked with regular Element # | |
############################################# | |
# Link to Element | |
Element = models.ForeignKey(Element, on_delete=models.CASCADE) | |
Html = models.TextField() | |
class Supplement(models.Model): | |
############################################# | |
# Supplements linked with Element # | |
############################################# | |
# Link to Publication and Chapter | |
Element = models.ForeignKey(Element, on_delete=models.CASCADE) | |
# Definition of the various Kinds of Elements | |
KINDS = ( | |
('echolink', 'Link to Echo'), | |
('europeana', 'Link to Europeana'), | |
('arxiv', 'Link to Arxiv'), | |
('ddb', 'Link to Deutsche Digitale Bibliothek'), | |
('googlemaps', 'Location on a Google Map'), | |
('sound', 'An mp3-File'), | |
) | |
Kind = models.CharField(max_length=30,choices=KINDS) | |
Link = models.CharField(max_length=1000,blank=True) | |
Title = models.CharField(max_length=1000) | |
Soundfile = models.FileField(upload_to=filepath_chapter, blank=True) | |
Longitude = models.CharField(max_length=30,blank=True) | |
Latitude = models.CharField(max_length=30,blank=True) | |
def __str__(self): | |
# def __unicode__(self): | |
return self.Title | |
class Author(models.Model): | |
Number = models.IntegerField(unique=True) | |
Authorname = models.CharField(max_length=2000) | |
Sortname = models.CharField(max_length=2000) | |
Homepage = models.CharField(max_length=2000, blank=True) | |
Description = models.TextField() | |
Foto = models.ImageField(upload_to="authors", blank=True) | |
def __str__(self): | |
# def __unicode__(self): | |
return self.Authorname | |
class Review(models.Model): | |
Publication = models.ForeignKey(Publication, on_delete=models.CASCADE) | |
Fulltext = models.TextField() | |
class Report(models.Model): | |
Publication = models.ForeignKey(Publication, on_delete=models.CASCADE) | |
Fulltext = models.TextField() |