-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move central information parts to new app eoapublictions2
- Loading branch information
kthoden
committed
Aug 21, 2020
1 parent
353473a
commit 2221eba
Showing
10 changed files
with
257 additions
and
39 deletions.
There are no files selected for viewing
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
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class Eoapublications2Config(AppConfig): | ||
name = 'eoapublications2' |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from django.shortcuts import render | ||
from django.template.defaultfilters import slugify | ||
|
||
# Create your views here. | ||
|
||
class Publication(): | ||
"Publication class" | ||
|
||
def __init__(self, title, serie, number, coverpath, abstract_short, mainlanguage, creators, creator_suffix, translated_and): | ||
self.Title = title | ||
self.Serie = serie | ||
self.Number = number | ||
self.Cover = coverpath | ||
self.Descriptionshort = abstract_short | ||
self.Mainlanguage = mainlanguage | ||
self.Creators = creators | ||
self.Creatorsuffix = creator_suffix | ||
self.Conjunction = translated_and | ||
# def __init__ ends here | ||
|
||
|
||
def __str__(self): | ||
return self.Title | ||
# def __str__ ends here | ||
# class Publication ends here | ||
|
||
|
||
class Chapter(): | ||
"Chapter class" | ||
|
||
def __init__(self, long_title, short_title, abstract, mainlanguage, creators, order, appears_in): | ||
self.Longtitle = long_title | ||
self.Shorttitle = short_title | ||
self.Mainlanguage = mainlanguage | ||
self.Order = order | ||
self.Creators = creators | ||
self.Chapterabstract = abstract | ||
self.Partofpublication = appears_in | ||
# def __init__ ends here | ||
|
||
def __str__(self): | ||
return self.Longtitle | ||
# def __str__ ends here | ||
# class Chapter ends here | ||
|
||
|
||
class Author(): | ||
"Author class" | ||
|
||
def __init__(self, name): | ||
self.Name = name | ||
self.Sortname = slugify(name) | ||
# def __init__ ends here | ||
|
||
def __str__(self): | ||
return self.Name | ||
# def __str__ ends here | ||
# class Author ends here |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
def author_is_creator_of_which_publications(firstname, lastname): | ||
"""Building a personalized xquery string | ||
For debugging purposes, this is authorpublication.xq | ||
""" | ||
|
||
pubquiz_string = """ | ||
xquery version "3.1"; | ||
declare namespace tei = "http://www.tei-c.org/ns/1.0"; | ||
<publications> | ||
{ | ||
let $firstname := '%s' | ||
let $lastname := '%s' | ||
for $book in collection('/db/xml_files/publications') | ||
let $authorid := | ||
concat('#', | ||
$book//tei:respStmt/tei:persName[./tei:forename = $firstname and ./tei:surname = $lastname]/../@xml:id) | ||
let $series := $book//tei:seriesStmt/tei:title/text() | ||
let $number := xs:int($book//tei:seriesStmt/tei:idno/text()) | ||
let $abstract := $book//tei:profileDesc/tei:abstract[@n = 'brief']/tei:p | ||
let $title := $book//tei:titleStmt/tei:title[@type = 'main']/node() | ||
let $coverimage := $book//tei:text/tei:front/tei:figure[@type = 'cover']/tei:graphic/@url | ||
return | ||
<pub>{ | ||
if ($book//tei:fileDesc/tei:titleStmt/(tei:editor[@role = 'volumeeditor'] | tei:author)/@ref = $authorid) | ||
then ( | ||
<title>{$title}</title>, | ||
<series>{$series}</series>, | ||
<number>{$number}</number>, | ||
<abstract>{$abstract}</abstract>, | ||
<coverpath>{ concat("/", lower-case($series), "/", $number, "/", $coverimage) }</coverpath> | ||
) | ||
else | ||
"" | ||
} | ||
</pub> | ||
} | ||
</publications> | ||
""" % (firstname, lastname) | ||
|
||
return pubquiz_string | ||
# def author_is_creator_of_which_publications ends here | ||
|
||
|
||
def author_is_creator_of_which_chapters(firstname, lastname): | ||
"""Return all chapters with author involved. | ||
For debugging purposes, this is chapterauthor.xq | ||
""" | ||
|
||
pubquiz_string = """ | ||
xquery version "3.1"; | ||
declare namespace tei = "http://www.tei-c.org/ns/1.0"; | ||
<publications> | ||
{ | ||
let $firstname := '%s' | ||
let $lastname := '%s' | ||
for $book in collection('/db/xml_files/publications') | ||
let $authorid := | ||
$book//tei:respStmt/tei:persName[./tei:forename = $firstname and ./tei:surname = $lastname]/../@xml:id | ||
let $series := $book//tei:seriesStmt/tei:title/text() | ||
let $number := xs:int($book//tei:seriesStmt/tei:idno/text()) | ||
let $title := $book//tei:titleStmt/tei:title[@type = 'main']/node() | ||
let $chapter := $book//tei:text//tei:div[@type = 'chapter'] | ||
for $bit in $chapter | ||
let $chaptertitle := $bit/tei:head/node() | ||
let $chapterlanguage := xs:string($bit/@xml:lang) | ||
let $chapterabstract := $bit/ab[@type='chapterabstract'] | ||
let $resp := xs:string($bit/@resp) | ||
let $resplist := tokenize($resp, " ") | ||
return | ||
<pub>{ | ||
if ($resplist = concat('#', $authorid)) then | ||
(<title>{ $chaptertitle }</title>, <booktitle>{ $title }</booktitle>, <series>{ $series }</series>, | ||
<number>{ $number }</number>, <order>{ index-of($chapter, $bit) }</order>, <chapterlanguage>{$chapterlanguage}</chapterlanguage>, <chapterabstract>{$chapterabstract}</chapterabstract>,<creators>{$resplist}</creators>) | ||
else | ||
"" | ||
} | ||
</pub> | ||
} | ||
</publications> | ||
""" % (firstname, lastname) | ||
|
||
return pubquiz_string | ||
# def author_is_creator_of_which_chapters ends here | ||
|
||
|
||
def author_is_creator_of_which_other_chapters(firstname, lastname): | ||
"""Return all chapters with author involved except where she or he is | ||
author or volume editor. | ||
For debugging purposes, this is chapterauthor_notinownbook.xq | ||
""" | ||
|
||
pubquiz_string = """ | ||
xquery version "3.1"; | ||
declare namespace tei = "http://www.tei-c.org/ns/1.0"; | ||
<chapters> | ||
{ | ||
let $firstname := '%s' | ||
let $lastname := '%s' | ||
for $book in collection('/db/xml_files/publications') | ||
let $authorid := | ||
$book//tei:respStmt/tei:persName[./tei:forename = $firstname and ./tei:surname = $lastname]/../@xml:id | ||
let $authorrefs := $book//tei:fileDesc/tei:titleStmt/(tei:editor[@role = 'volumeeditor'] | tei:author)/@ref | ||
let $listofcreators := string-join($authorrefs, " ") | ||
let $series := $book//tei:seriesStmt/tei:title/text() | ||
let $number := xs:int($book//tei:seriesStmt/tei:idno/text()) | ||
let $title := $book//tei:titleStmt/tei:title[@type = 'main']/node() | ||
let $chapter := $book//tei:text//tei:div[@type = 'chapter'] | ||
for $bit in $chapter | ||
let $chaptertitle := $bit/tei:head/node() | ||
let $chapterlanguage := xs:string($bit/@xml:lang) | ||
let $chapterabstract := $bit/ab[@type = 'chapterabstract'] | ||
let $resp := xs:string($bit/@resp) | ||
let $resplist := tokenize($resp, " ") | ||
return | ||
<chapter> | ||
{ | ||
if (empty($authorid)) then | ||
"" | ||
else | ||
(if (tokenize($listofcreators, " ") = '#' || $authorid) then | ||
("") | ||
else | ||
(if ($resplist = concat('#', $authorid)) then | ||
(<title>{ $chaptertitle }</title>, <booktitle>{ $title }</booktitle>, | ||
<series>{ $series }</series>, | ||
<number>{ $number }</number>, <order>{ index-of($chapter, $bit) }</order>, | ||
<chapterlanguage>{ $chapterlanguage }</chapterlanguage>, <chapterabstract>{ $chapterabstract }</chapterabstract>, | ||
<authors> | ||
{ | ||
for $pp in $resplist | ||
let $localname := xs:string($book/*//tei:respStmt[@xml:id = substring-after($pp, "#")]/tei:persName/@xml:lang) | ||
let $inbookid := xs:string($book/*//tei:respStmt[@xml:id = substring-after($pp, "#")]/@xml:id) | ||
let $firstname := | ||
$book/*//tei:respStmt[@xml:id = substring-after($pp, | ||
"#")]/tei:persName/tei:forename/node() | ||
let $lastname := | ||
$book/*//tei:respStmt[@xml:id = substring-after($pp, | ||
"#")]/tei:persName/tei:surname/node() | ||
return | ||
<author><fullname>{ | ||
if ($localname = "zh") then | ||
(concat($lastname, ' ', $firstname)) | ||
else | ||
(concat($firstname, ' ', $lastname)) | ||
}</fullname> | ||
<firstname>{ $firstname }</firstname> | ||
<lastname>{ $lastname }</lastname> | ||
<inbookid>{ $inbookid }</inbookid> | ||
</author> | ||
} | ||
</authors>) | ||
else | ||
"" | ||
) | ||
) | ||
} | ||
</chapter> | ||
} | ||
</chapters> | ||
""" % (firstname, lastname) | ||
|
||
return pubquiz_string | ||
# def author_is_creator_of_which_other_chapters ends here |
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