Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Debian New Member Process
contributors.debian.org
Commits
1f6b9613
Commit
1f6b9613
authored
Aug 01, 2020
by
Pierre-Elliott Bécue
🚼
Browse files
Merge branch 'master' into 'master'
Improvement and fixes for export/import of public data See merge request
!7
parents
c9b8a965
b4be870b
Pipeline
#161274
passed with stage
in 2 minutes and 3 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
importer/exporter.py
View file @
1f6b9613
...
...
@@ -18,9 +18,12 @@ def export_public_data():
sources
=
cmodels
.
Source
.
export_json
()
hidden_usersourcesettings
=
set
(
cmodels
.
UserSourceSettings
.
objects
.
filter
(
hidden
=
True
).
values_list
(
"user__id"
,
"source__id"
))
conts
=
cmodels
.
Contribution
.
objects
.
filter
(
identifier__hidden
=
False
,
identifier__user__hidden
=
False
)
conts
=
[
c
for
c
in
conts
if
not
c
.
hidden
]
conts
=
[
c
for
c
in
conts
if
(
c
.
identifier
.
user_id
,
c
.
type
.
source_id
)
not
in
hidden_usersourcesettings
]
contributions
=
serializers
.
ContributionSerializer
(
conts
,
many
=
True
).
data
fres
=
{
...
...
importer/management/commands/generate_test_data.py
View file @
1f6b9613
...
...
@@ -72,6 +72,10 @@ class Command(BaseCommand):
create_contributions
(
cmodels
.
ContributionType
.
objects
.
get
(
name
=
name
),
identifier_3
)
cmodels
.
UserSourceSettings
.
objects
.
update_or_create
(
user
=
user_3
,
source
=
cmodels
.
ContributionType
.
objects
.
get
(
name
=
"debian-installer-translator"
).
source
,
hidden
=
True
)
# user 4
user_4
=
create_user
(
"adeakin"
,
"Austin Deakin"
,
hidden
=
True
)
...
...
importer/serializers.py
View file @
1f6b9613
...
...
@@ -4,17 +4,23 @@ from contributors import models as cmodels
from
signon.models
import
Identity
class
UserSerializer
(
serializers
.
ModelSerializer
):
id
=
serializers
.
IntegerField
(
read_only
=
False
)
class
Meta
:
model
=
cmodels
.
User
fields
=
[
"id"
,
"username"
,
"full_name"
,
"is_dd"
,
"is_staff"
,
"is_active"
]
class
IdentifierSerializer
(
serializers
.
ModelSerializer
):
id
=
serializers
.
IntegerField
(
read_only
=
False
)
class
Meta
:
model
=
cmodels
.
Identifier
fields
=
[
"id"
,
"type"
,
"name"
,
"user"
]
class
IdentitySerializer
(
serializers
.
ModelSerializer
):
id
=
serializers
.
IntegerField
(
read_only
=
False
)
class
Meta
:
model
=
Identity
fields
=
[
"id"
,
"person"
,
"issuer"
,
"subject"
,
"profile"
,
"picture"
,
...
...
@@ -26,6 +32,19 @@ class IdentitySerializer(serializers.ModelSerializer):
return
identity
class
ContributionSerializer
(
serializers
.
ModelSerializer
):
id
=
serializers
.
IntegerField
(
read_only
=
False
)
type_name
=
serializers
.
CharField
(
source
=
"type.name"
)
type_source
=
serializers
.
CharField
(
source
=
"type.source.name"
)
class
Meta
:
model
=
cmodels
.
Contribution
fields
=
[
"id"
,
"type"
,
"identifier"
,
"begin"
,
"until"
,
"url"
]
fields
=
[
"id"
,
"identifier"
,
"begin"
,
"until"
,
"url"
,
"type_name"
,
"type_source"
]
def
create
(
self
,
validated_data
):
type
=
validated_data
.
pop
(
"type"
)
contribution
=
cmodels
.
Contribution
(
**
validated_data
)
contribution
.
type
=
cmodels
.
ContributionType
.
objects
.
get
(
name
=
type
[
"name"
],
source__name
=
type
[
"source"
][
"name"
])
contribution
.
save
()
return
contribution
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment