SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SciPost
SciPost
Commits
155305b2
Commit
155305b2
authored
7 years ago
by
Jorran de Wit
Browse files
Options
Downloads
Patches
Plain Diff
Add Commentary factories
parent
d15aaa8d
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
commentaries/constants.py
+6
-0
6 additions, 0 deletions
commentaries/constants.py
commentaries/factories.py
+29
-17
29 additions, 17 deletions
commentaries/factories.py
commentaries/models.py
+1
-8
1 addition, 8 deletions
commentaries/models.py
with
36 additions
and
25 deletions
commentaries/constants.py
0 → 100644
+
6
−
0
View file @
155305b2
COMMENTARY_PUBLISHED
=
'
published
'
COMMENTARY_PREPRINT
=
'
preprint
'
COMMENTARY_TYPES
=
(
(
COMMENTARY_PUBLISHED
,
'
published paper
'
),
(
COMMENTARY_PREPRINT
,
'
arXiv preprint
'
),
)
This diff is collapsed.
Click to expand it.
commentaries/factories.py
+
29
−
17
View file @
155305b2
import
factory
from
scipost.constants
import
DISCIPLINE
_PHYSIC
S
,
SCIPOST_SUBJECT_AREAS
from
scipost.constants
import
SCIPOST_
DISCIPLINES
,
SCIPOST_SUBJECT_AREAS
from
scipost.factories
import
ContributorFactory
from
scipost.models
import
Contributor
from
journals.constants
import
SCIPOST_JOURNALS_DOMAINS
from
common.helpers
import
random_arxiv_identifier_with_version_number
from
common.helpers
import
random_arxiv_identifier_with_version_number
,
random_external_doi
from
.models
import
Commentary
,
COMMENTARY_TYPES
from
.constants
import
COMMENTARY_TYPES
from
.models
import
Commentary
from
faker
import
Faker
class
CommentaryFactory
(
factory
.
django
.
DjangoModelFactory
):
class
Meta
:
model
=
Commentary
abstract
=
True
requested_by
=
factory
.
SubFactory
(
ContributorFactory
)
vetted_by
=
factory
.
SubFactory
(
ContributorFactory
)
type
=
COMMENTARY_TYPES
[
0
][
0
]
discipline
=
DISCIPLINE_PHYSICS
domain
=
SCIPOST_JOURNALS_DOMAINS
[
0
][
0
]
subject_area
=
SCIPOST_SUBJECT_AREAS
[
0
][
1
][
0
][
0
]
pub_title
=
factory
.
Faker
(
'
bs
'
)
pub_DOI
=
'
10.1103/PhysRevB.92.214427
'
type
=
factory
.
Iterator
(
COMMENTARY_TYPES
,
getter
=
lambda
c
:
c
[
0
])
discipline
=
factory
.
Iterator
(
SCIPOST_DISCIPLINES
,
getter
=
lambda
c
:
c
[
0
])
domain
=
factory
.
Iterator
(
SCIPOST_JOURNALS_DOMAINS
,
getter
=
lambda
c
:
c
[
0
])
subject_area
=
factory
.
Iterator
(
SCIPOST_SUBJECT_AREAS
[
0
][
1
],
getter
=
lambda
c
:
c
[
0
])
pub_title
=
factory
.
Faker
(
'
text
'
)
pub_DOI
=
factory
.
Sequence
(
lambda
n
:
random_external_doi
())
arxiv_identifier
=
factory
.
Sequence
(
lambda
n
:
random_arxiv_identifier_with_version_number
())
author_list
=
factory
.
Faker
(
'
name
'
)
pub_abstract
=
factory
.
Faker
(
'
text
'
)
arxiv_link
=
factory
.
Faker
(
'
uri
'
)
pub_abstract
=
factory
.
lazy_attribute
(
lambda
x
:
Faker
().
paragraph
())
@factory.post_generation
def
arxiv_link
(
self
,
create
,
extracted
,
**
kwargs
):
self
.
arxiv_link
=
'
https://arxiv.org/abs/%s
'
%
self
.
arxiv_identifier
self
.
arxiv_or_DOI_string
=
self
.
arxiv_identifier
@factory.post_generation
def
create_urls
(
self
,
create
,
extracted
,
**
kwargs
):
self
.
parse_links_into_urls
(
commit
=
create
)
class
EmptyCommentaryFactory
(
CommentaryFactory
):
pub_DOI
=
None
arxiv_identifier
=
None
@factory.post_generation
def
add_authors
(
self
,
create
,
extracted
,
**
kwargs
):
contributors
=
list
(
Contributor
.
objects
.
order_by
(
'
?
'
)
.
exclude
(
pk
=
self
.
requested_by
.
pk
).
all
()[:
4
])
for
contrib
in
contributors
:
self
.
author_list
+=
'
, %s %s
'
%
(
contrib
.
user
.
first_name
,
contrib
.
user
.
last_name
)
if
create
:
self
.
authors
.
add
(
contrib
)
class
VettedCommentaryFactory
(
CommentaryFactory
):
vetted
=
True
vetted_by
=
factory
.
SubFactory
(
ContributorFactory
)
class
UnpublishedVettedCommentaryFactory
(
VettedCommentaryFactory
):
...
...
This diff is collapsed.
Click to expand it.
commentaries/models.py
+
1
−
8
View file @
155305b2
...
...
@@ -8,17 +8,10 @@ from scipost.behaviors import ArxivCallable, TimeStampedModel
from
scipost.models
import
Contributor
from
scipost.constants
import
SCIPOST_DISCIPLINES
,
DISCIPLINE_PHYSICS
,
SCIPOST_SUBJECT_AREAS
from
.constants
import
COMMENTARY_TYPES
from
.managers
import
CommentaryManager
COMMENTARY_PUBLISHED
=
'
published
'
COMMENTARY_PREPRINT
=
'
preprint
'
COMMENTARY_TYPES
=
(
(
COMMENTARY_PUBLISHED
,
'
published paper
'
),
(
COMMENTARY_PREPRINT
,
'
arXiv preprint
'
),
)
class
Commentary
(
ArxivCallable
,
TimeStampedModel
):
"""
A Commentary contains all the contents of a SciPost Commentary page for a given publication.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment