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
09cd25a5
Commit
09cd25a5
authored
8 years ago
by
Jorran de Wit
Browse files
Options
Downloads
Patches
Plain Diff
Remove unwanted/duplicate factories file
parent
86005ddf
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scipost/management/commands/factories.py
+0
-70
0 additions, 70 deletions
scipost/management/commands/factories.py
with
0 additions
and
70 deletions
scipost/management/commands/factories.py
deleted
100644 → 0
+
0
−
70
View file @
86005ddf
import
factory
import
random
from
django.contrib.auth
import
get_user_model
from
django.contrib.auth.models
import
Group
from
.models
import
Contributor
,
EditorialCollege
,
EditorialCollegeMember
class
ContributorFactory
(
factory
.
django
.
DjangoModelFactory
):
class
Meta
:
model
=
Contributor
title
=
"
MR
"
user
=
factory
.
SubFactory
(
'
scipost.factories.UserFactory
'
,
contributor
=
None
)
status
=
1
# normal user
vetted_by
=
factory
.
SubFactory
(
'
scipost.factories.ContributorFactory
'
,
vetted_by
=
None
)
class
VettingEditorFactory
(
ContributorFactory
):
@factory.post_generation
def
add_to_vetting_editors
(
self
,
create
,
extracted
,
**
kwargs
):
if
not
create
:
return
self
.
user
.
groups
.
add
(
Group
.
objects
.
get
(
name
=
"
Vetting Editors
"
))
class
UserFactory
(
factory
.
django
.
DjangoModelFactory
):
class
Meta
:
model
=
get_user_model
()
username
=
factory
.
Faker
(
'
user_name
'
)
password
=
factory
.
PostGenerationMethodCall
(
'
set_password
'
,
'
adm1n
'
)
email
=
factory
.
Faker
(
'
safe_email
'
)
first_name
=
factory
.
Faker
(
'
first_name
'
)
last_name
=
factory
.
Faker
(
'
last_name
'
)
is_active
=
True
# When user object is created, associate new Contributor object to it.
contributor
=
factory
.
RelatedFactory
(
ContributorFactory
,
'
user
'
)
@factory.post_generation
def
groups
(
self
,
create
,
extracted
,
**
kwargs
):
# If the object is not saved, we cannot use many-to-many relationship.
if
not
create
:
return
# If group objects were passed in, use those.
if
extracted
:
for
group
in
extracted
:
self
.
groups
.
add
(
group
)
else
:
self
.
groups
.
add
(
Group
.
objects
.
get
(
name
=
"
Registered Contributors
"
))
class
EditorialCollegeFactory
(
factory
.
django
.
DjangoModelFactory
):
class
Meta
:
model
=
EditorialCollege
django_get_or_create
=
(
'
discipline
'
,
)
discipline
=
random
.
choice
([
'
Physics
'
,
'
Chemistry
'
,
'
Medicine
'
])
class
EditorialCollegeMemberFactory
(
factory
.
django
.
DjangoModelFactory
):
class
Meta
:
model
=
EditorialCollegeMember
title
=
factory
.
Faker
(
'
prefix
'
)
name
=
factory
.
Faker
(
'
name
'
)
link
=
factory
.
Faker
(
'
url
'
)
subtitle
=
factory
.
Faker
(
'
company
'
)
college
=
factory
.
Iterator
(
EditorialCollege
.
objects
.
all
())
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