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
a28607fa
Commit
a28607fa
authored
7 years ago
by
Jorran de Wit
Browse files
Options
Downloads
Plain Diff
Merge branch 'exportcontribs' into release2017w16
parents
c58efeff
0b5b29f6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
scipost/constants.py
+2
-2
2 additions, 2 deletions
scipost/constants.py
scipost/management/commands/export_contributors.py
+50
-0
50 additions, 0 deletions
scipost/management/commands/export_contributors.py
scipost/views.py
+0
-5
0 additions, 5 deletions
scipost/views.py
with
52 additions
and
7 deletions
scipost/constants.py
+
2
−
2
View file @
a28607fa
...
@@ -125,7 +125,7 @@ subject_areas_dict = {}
...
@@ -125,7 +125,7 @@ subject_areas_dict = {}
for
k
in
subject_areas_raw_dict
.
keys
():
for
k
in
subject_areas_raw_dict
.
keys
():
subject_areas_dict
.
update
(
dict
(
subject_areas_raw_dict
[
k
]))
subject_areas_dict
.
update
(
dict
(
subject_areas_raw_dict
[
k
]))
CONTRIBUTOR_NORMAL
=
1
CONTRIBUTOR_STATUS
=
(
CONTRIBUTOR_STATUS
=
(
# status determine the type of Contributor:
# status determine the type of Contributor:
# 0: newly registered (unverified; not allowed to submit, comment or vote)
# 0: newly registered (unverified; not allowed to submit, comment or vote)
...
@@ -137,7 +137,7 @@ CONTRIBUTOR_STATUS = (
...
@@ -137,7 +137,7 @@ CONTRIBUTOR_STATUS = (
# -3: barred from SciPost (abusive behaviour)
# -3: barred from SciPost (abusive behaviour)
# -4: disabled account (deceased)
# -4: disabled account (deceased)
(
0
,
'
newly registered
'
),
(
0
,
'
newly registered
'
),
(
1
,
'
normal user
'
),
(
CONTRIBUTOR_NORMAL
,
'
normal user
'
),
(
-
1
,
'
not a professional scientist
'
),
(
-
1
,
'
not a professional scientist
'
),
(
-
2
,
'
other account already exists
'
),
(
-
2
,
'
other account already exists
'
),
(
-
3
,
'
barred from SciPost
'
),
(
-
3
,
'
barred from SciPost
'
),
...
...
This diff is collapsed.
Click to expand it.
scipost/management/commands/export_contributors.py
0 → 100644
+
50
−
0
View file @
a28607fa
import
csv
from
datetime
import
datetime
from
django.core.management.base
import
BaseCommand
from
...constants
import
CONTRIBUTOR_NORMAL
from
...models
import
Contributor
class
Command
(
BaseCommand
):
"""
Use this command to export the Contributor table. One could filter the export
by simply using the --group argument.
For example, one could run:
$ ./manage.py export_contributors --group
'
Registered Contributors
'
"""
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'
--group
'
,
dest
=
'
group
'
,
default
=
False
,
type
=
str
,
help
=
'
Filter the contributors by their group name
'
)
def
handle
(
self
,
*
args
,
**
kwargs
):
# File variables
filename
=
'
export_%s_contributors_%s.csv
'
%
(
datetime
.
now
().
strftime
(
'
%Y_%m_%d_%H_%M
'
),
kwargs
.
get
(
'
group
'
,
''
))
filename
=
filename
.
replace
(
'
'
,
'
_
'
)
fieldnames
=
[
'
first_name
'
,
'
last_name
'
,
'
email_address
'
]
# Query
queryset
=
Contributor
.
objects
.
filter
(
user__is_active
=
True
,
status
=
CONTRIBUTOR_NORMAL
)
if
kwargs
[
'
group
'
]:
queryset
=
queryset
.
filter
(
user__groups__name
=
kwargs
[
'
group
'
])
# Open + write the file
with
open
(
filename
,
'
w
'
,
newline
=
''
)
as
_file
:
writer
=
csv
.
writer
(
_file
,
quotechar
=
'
|
'
,
quoting
=
csv
.
QUOTE_MINIMAL
)
writer
.
writerow
(
fieldnames
)
n
=
0
for
contributor
in
queryset
:
user
=
contributor
.
user
writer
.
writerow
([
user
.
first_name
,
user
.
last_name
,
user
.
email
])
n
+=
1
self
.
stdout
.
write
(
self
.
style
.
SUCCESS
(
'
Successfully wrote %i Contributors to file %s.
'
%
(
n
,
filename
)))
This diff is collapsed.
Click to expand it.
scipost/views.py
+
0
−
5
View file @
a28607fa
import
datetime
import
hashlib
import
random
import
re
import
re
import
string
from
django.utils
import
timezone
from
django.utils
import
timezone
from
django.shortcuts
import
get_object_or_404
,
render
from
django.shortcuts
import
get_object_or_404
,
render
...
@@ -17,7 +13,6 @@ from django.core.mail import EmailMessage, EmailMultiAlternatives
...
@@ -17,7 +13,6 @@ from django.core.mail import EmailMessage, EmailMultiAlternatives
from
django.core.paginator
import
Paginator
,
EmptyPage
,
PageNotAnInteger
from
django.core.paginator
import
Paginator
,
EmptyPage
,
PageNotAnInteger
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
django.db.models
import
Q
from
django.db.models
import
Q
from
django.http
import
HttpResponseRedirect
from
django.shortcuts
import
redirect
from
django.shortcuts
import
redirect
from
django.template
import
Context
,
Template
from
django.template
import
Context
,
Template
from
django.utils.http
import
is_safe_url
from
django.utils.http
import
is_safe_url
...
...
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