forked from RaphaelWimmer/open-access-media-importer
-
Notifications
You must be signed in to change notification settings - Fork 8
/
model.py
58 lines (49 loc) · 1.89 KB
/
model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from elixir import *
from os import path
from helpers import config
def set_source(source):
metadata.bind = 'sqlite:///%s' % config.database_path(source)
class Journal(Entity):
title = Field(UnicodeText, primary_key=True)
articles = OneToMany('Article')
class Category(Entity):
name = Field(UnicodeText, primary_key=True)
articles = ManyToMany('Article')
class Article(Entity):
name = Field(UnicodeText)
doi = Field(UnicodeText)
title = Field(UnicodeText, primary_key=True)
contrib_authors = Field(UnicodeText, primary_key=True)
abstract = Field(UnicodeText)
year = Field(Integer) # should always be there
month = Field(Integer) # or None
day = Field(Integer) # or None
url = Field(UnicodeText)
license_url = Field(UnicodeText)
license_text = Field(UnicodeText)
copyright_statement = Field(UnicodeText)
copyright_holder = Field(UnicodeText)
journal = ManyToOne('Journal')
supplementary_materials = OneToMany('SupplementaryMaterial')
categories = ManyToMany('Category')
def __repr__(self):
return '<Article "%s">' % self.title.encode('utf-8')
class SupplementaryMaterial(Entity):
label = Field(UnicodeText)
title = Field(UnicodeText)
caption = Field(UnicodeText)
mimetype = Field(UnicodeText)
mime_subtype = Field(UnicodeText)
mimetype_reported = Field(UnicodeText)
mime_subtype_reported = Field(UnicodeText)
url = Field(UnicodeText, primary_key=True)
article = ManyToOne('Article')
downloaded = Field(Boolean, default=False)
converting = Field(Boolean, default=False)
converted = Field(Boolean, default=False)
uploaded = Field(Boolean, default=False)
def __repr__(self):
return '<SupplementaryMaterial “%s” of Article “%s”>' % \
(self.label.encode('utf-8'), self.article.title.encode('utf-8'))