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
001fa430
Commit
001fa430
authored
8 years ago
by
Jorran de Wit
Browse files
Options
Downloads
Patches
Plain Diff
Add management command to populate db with initial data
parent
53fe34a5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scipost/management/commands/populate_db.py
+10
-13
10 additions, 13 deletions
scipost/management/commands/populate_db.py
scipost/management/commands/setup_contributor.py
+20
-0
20 additions, 0 deletions
scipost/management/commands/setup_contributor.py
with
30 additions
and
13 deletions
scipost/management/commands/populate_db.py
+
10
−
13
View file @
001fa430
from
django.core.management.base
import
BaseCommand
from
django.core.management.base
import
BaseCommand
from
django.contrib.auth.models
import
User
from
...
model
s
import
Contribu
tor
from
...
factorie
s
import
EditorialCollegeFactory
,
EditorialCollegeMemberFac
tor
y
class
Command
(
BaseCommand
):
class
Command
(
BaseCommand
):
def
add_arguments
(
self
,
parser
):
def
create_editorial_college
(
self
):
parser
.
add_argument
(
EditorialCollegeFactory
.
create_batch
(
5
)
'
--username
'
,
type
=
str
,
required
=
True
,
self
.
stdout
.
write
(
self
.
style
.
SUCCESS
(
'
Successfully created Editorial College
\'
s.
'
))
help
=
'
Username of user to use for contributor model
'
)
def
create_contributor
(
self
,
username
):
def
create_editorial_college_members
(
self
):
user
=
User
.
objects
.
get
(
username
=
username
)
EditorialCollegeMemberFactory
.
create_batch
(
20
)
contributor
=
Contributor
(
user
=
user
,
status
=
1
,
title
=
"
MR
"
)
self
.
stdout
.
write
(
self
.
style
.
SUCCESS
(
'
Successfully created Editorial College Members.
'
))
contributor
.
vetted_by
=
contributor
contributor
.
save
()
def
handle
(
self
,
*
args
,
**
options
):
def
handle
(
self
,
*
args
,
**
kwargs
):
self
.
create_contributor
(
options
[
'
username
'
])
self
.
create_editorial_college
()
self
.
create_editorial_college_members
()
This diff is collapsed.
Click to expand it.
scipost/management/commands/setup_contributor.py
0 → 100644
+
20
−
0
View file @
001fa430
from
django.core.management.base
import
BaseCommand
from
django.contrib.auth.models
import
User
from
...models
import
Contributor
class
Command
(
BaseCommand
):
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'
--username
'
,
type
=
str
,
required
=
True
,
help
=
'
Username of user to use for contributor model
'
)
def
create_contributor
(
self
,
username
):
user
=
User
.
objects
.
get
(
username
=
username
)
contributor
=
Contributor
(
user
=
user
,
status
=
1
,
title
=
"
MR
"
)
contributor
.
vetted_by
=
contributor
contributor
.
save
()
def
handle
(
self
,
*
args
,
**
options
):
self
.
create_contributor
(
options
[
'
username
'
])
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