Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F69507294
models.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Jul 2, 03:06
Size
7 KB
Mime Type
text/x-python
Expires
Thu, Jul 4, 03:06 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
18714972
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
models.py
View Options
from
django.db
import
models
from
django.contrib.auth.models
import
User
import
datetime
from
django.utils.translation
import
gettext
as
_
# Ref: database_model_20210421_MB.drawio 21.04.2021
class
Country
(
models
.
Model
):
name
=
models
.
CharField
(
verbose_name
=
"Country name"
,
max_length
=
120
,
null
=
True
)
iso_code
=
models
.
CharField
(
max_length
=
3
,
null
=
True
)
def
__str__
(
self
):
return
f
"{self.name}"
class
Meta
:
ordering
=
(
'name'
,)
class
Language
(
models
.
Model
):
name
=
models
.
CharField
(
verbose_name
=
"Language name"
,
max_length
=
120
,
null
=
True
)
iso_code
=
models
.
CharField
(
max_length
=
3
,
null
=
True
)
def
__str__
(
self
):
return
f
"{self.name}"
class
Meta
:
ordering
=
(
'name'
,)
class
Oa
(
models
.
Model
):
status
=
models
.
CharField
(
max_length
=
1000
,
null
=
True
)
description
=
models
.
CharField
(
max_length
=
1000
,
null
=
True
)
subscription
=
models
.
BooleanField
(
default
=
False
)
accepted_manuscript
=
models
.
BooleanField
(
default
=
False
)
apc
=
models
.
BooleanField
(
default
=
False
)
final_version
=
models
.
BooleanField
(
default
=
False
)
def
__str__
(
self
):
return
f
"{self.status}"
class
Meta
:
ordering
=
(
'-subscription'
,)
class
Publisher
(
models
.
Model
):
name
=
models
.
CharField
(
verbose_name
=
"Publisher name"
,
max_length
=
1000
,
null
=
True
)
city
=
models
.
CharField
(
max_length
=
100
,
null
=
True
)
state
=
models
.
CharField
(
max_length
=
3
,
null
=
True
)
country
=
models
.
ManyToManyField
(
"Country"
)
starting_year
=
models
.
IntegerField
()
website
=
models
.
URLField
(
max_length
=
1000
)
oa_policies
=
models
.
URLField
(
max_length
=
1000
)
def
__str__
(
self
):
return
f
"{self.name}"
class
Meta
:
ordering
=
(
'name'
,)
class
Issn
(
models
.
Model
):
PRINT
=
1
ELECTRONIC
=
2
OTHER
=
3
TYPE_CHOICES
=
(
(
PRINT
,
'Print'
),
(
ELECTRONIC
,
'Electronic'
),
(
OTHER
,
'Other'
),
)
issn
=
models
.
CharField
(
max_length
=
9
,
null
=
False
)
issn_type
=
models
.
CharField
(
choices
=
TYPE_CHOICES
,
max_length
=
10
,
blank
=
True
)
def
__str__
(
self
):
return
f
"{self.issn} ({dict(self.TYPE_CHOICES)[int(self.issn_type)]})"
class
Meta
:
ordering
=
(
'issn'
,)
class
Journal
(
models
.
Model
):
name
=
models
.
CharField
(
verbose_name
=
"Journal name"
,
max_length
=
800
,
blank
=
True
,
null
=
True
)
# search journal with name
name_short_iso_4
=
models
.
CharField
(
max_length
=
300
,
blank
=
True
,
null
=
True
)
publisher
=
models
.
ManyToManyField
(
Publisher
)
website
=
models
.
URLField
(
max_length
=
300
,
blank
=
True
,
null
=
True
)
language
=
models
.
ManyToManyField
(
Language
)
issn
=
models
.
ManyToManyField
(
"Issn"
)
# search journal with ISSN
oa_options
=
models
.
URLField
(
max_length
=
1000
,
blank
=
True
,
null
=
True
)
oa_status
=
models
.
ForeignKey
(
"Oa"
,
on_delete
=
models
.
CASCADE
)
starting_year
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
)
end_year
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
)
doaj_seal
=
models
.
BooleanField
(
default
=
False
)
doaj_status
=
models
.
BooleanField
(
default
=
False
)
lockss
=
models
.
BooleanField
(
default
=
False
)
nlch
=
models
.
BooleanField
(
default
=
False
)
portico
=
models
.
BooleanField
(
default
=
False
)
qoam_av_score
=
models
.
DecimalField
(
decimal_places
=
2
,
max_digits
=
5
,
blank
=
True
,
null
=
True
)
def
__str__
(
self
):
return
f
"{self.name} from {self.website}"
class
Meta
:
ordering
=
(
'name'
,)
class
Organization
(
models
.
Model
):
name
=
models
.
CharField
(
verbose_name
=
"Organization name"
,
max_length
=
600
,
null
=
True
)
website
=
models
.
URLField
(
max_length
=
600
,
blank
=
True
,
null
=
True
)
country
=
models
.
ManyToManyField
(
"Country"
)
ror
=
models
.
CharField
(
max_length
=
255
,
blank
=
True
,
null
=
True
)
fundref
=
models
.
CharField
(
max_length
=
255
,
blank
=
True
,
null
=
True
)
starting_year
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
)
is_funder
=
models
.
BooleanField
(
default
=
False
)
def
__str__
(
self
):
return
f
"{self.name}"
class
Meta
:
ordering
=
(
'name'
,)
class
Version
(
models
.
Model
):
description
=
models
.
CharField
(
max_length
=
300
,
null
=
False
)
def
__str__
(
self
):
return
f
"{self.description}"
class
Licence
(
models
.
Model
):
name_or_abbrev
=
models
.
CharField
(
max_length
=
300
,
null
=
False
)
website
=
models
.
URLField
(
max_length
=
600
,
null
=
True
)
def
__str__
(
self
):
return
f
"{self.name_or_abbrev}"
class
Cost_factor_type
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
300
,
null
=
False
)
def
__str__
(
self
):
return
f
"{self.name}"
class
Cost_factor
(
models
.
Model
):
cost_factor_type
=
models
.
ForeignKey
(
Cost_factor_type
,
on_delete
=
models
.
CASCADE
,
blank
=
True
,
null
=
True
)
amount
=
models
.
IntegerField
(
null
=
False
)
symbol
=
models
.
CharField
(
max_length
=
10
,
null
=
False
)
comment
=
models
.
CharField
(
max_length
=
120
,
default
=
""
)
def
__str__
(
self
):
return
f
"{self.amount} {self.symbol}"
class
Term
(
models
.
Model
):
version
=
models
.
ManyToManyField
(
Version
)
cost_factor
=
models
.
ManyToManyField
(
Cost_factor
)
embargo_months
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
)
ir_archiving
=
models
.
BooleanField
(
default
=
False
)
licence
=
models
.
ManyToManyField
(
Licence
)
comment
=
models
.
CharField
(
max_length
=
600
,
null
=
True
)
source
=
models
.
URLField
(
max_length
=
600
,
null
=
True
)
def
__str__
(
self
):
try
:
return
f
"{self.id} - {';'.join([str(x) for x in self.version.all()])} - {';'.join([str(x) for x in self.cost_factor.all()])} - {self.comment}"
except
RecursionError
:
# The JSON import in the admin module somehow throws a ValueError during the loading process
# probably due to incomplete information in the many2many relationships
# Then the error log apparently triggers a cascade of errors until
# the RecursionError level is hit. Falling back to a basic __str__
# for the RecursionError seems to bypass the problem.
return
f
"{self.id} - {self.comment}"
class
Meta
:
ordering
=
(
'-ir_archiving'
,
'embargo_months'
,
'comment'
)
class
ConditionType
(
models
.
Model
):
condition_issuer
=
models
.
CharField
(
max_length
=
300
,
null
=
False
)
def
__str__
(
self
):
return
f
"{self.condition_issuer}"
class
ConditionSet
(
models
.
Model
):
condition_type
=
models
.
ForeignKey
(
ConditionType
,
on_delete
=
models
.
CASCADE
,
blank
=
True
,
null
=
True
)
organization
=
models
.
ManyToManyField
(
Organization
,
through
=
'OrganizationCondition'
,
through_fields
=
(
'condition_set'
,
'organization'
)
)
journal
=
models
.
ManyToManyField
(
Journal
,
through
=
'JournalCondition'
,
through_fields
=
(
'condition_set'
,
'journal'
)
)
term
=
models
.
ManyToManyField
(
Term
)
comment
=
models
.
CharField
(
max_length
=
100
,
null
=
True
,
blank
=
True
)
def
__str__
(
self
):
return
f
"{self.id} {self.condition_type}|{self.comment}"
class
Meta
:
ordering
=
(
'-condition_type__pk'
,
'comment'
)
class
OrganizationCondition
(
models
.
Model
):
organization
=
models
.
ForeignKey
(
Organization
,
on_delete
=
models
.
CASCADE
,
blank
=
True
,
null
=
True
)
condition_set
=
models
.
ForeignKey
(
ConditionSet
,
on_delete
=
models
.
CASCADE
,
blank
=
True
,
null
=
True
)
valid_from
=
models
.
DateField
(
blank
=
True
,
null
=
True
)
valid_until
=
models
.
DateField
(
blank
=
True
,
null
=
True
)
def
__str__
(
self
):
return
f
"{self.id} {self.organization}/{self.condition_set}"
class
JournalCondition
(
models
.
Model
):
journal
=
models
.
ForeignKey
(
Journal
,
on_delete
=
models
.
CASCADE
,
blank
=
True
,
null
=
True
)
condition_set
=
models
.
ForeignKey
(
ConditionSet
,
on_delete
=
models
.
CASCADE
,
blank
=
True
,
null
=
True
)
valid_from
=
models
.
DateField
(
blank
=
True
,
null
=
True
)
valid_until
=
models
.
DateField
(
blank
=
True
,
null
=
True
)
def
__str__
(
self
):
return
f
"{self.id} {self.journal.name}/{self.condition_set}"
Event Timeline
Log In to Comment