Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Maják
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
TO
Maják
Commits
9e305481
Commit
9e305481
authored
9 months ago
by
Tomi Valentová
Browse files
Options
Downloads
Patches
Plain Diff
finish octopus import
parent
e3520e8c
No related branches found
No related tags found
2 merge requests
!1097
Release
,
!1095
Add basic Octopus people sync
Pipeline
#19300
passed
9 months ago
Stage: build
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
district/forms.py
+23
-1
23 additions, 1 deletion
district/forms.py
district/models.py
+5
-2
5 additions, 2 deletions
district/models.py
shared/people_import.py
+8
-0
8 additions, 0 deletions
shared/people_import.py
shared/templatetags/people_filters.py
+1
-1
1 addition, 1 deletion
shared/templatetags/people_filters.py
with
37 additions
and
4 deletions
district/forms.py
+
23
−
1
View file @
9e305481
...
@@ -2,6 +2,8 @@ import os
...
@@ -2,6 +2,8 @@ import os
import
tempfile
import
tempfile
from
shared.forms
import
JekyllImportForm
as
SharedJekyllImportForm
from
shared.forms
import
JekyllImportForm
as
SharedJekyllImportForm
from
wagtail.admin.forms
import
WagtailAdminPageForm
from
wagtail.models.media
import
Collection
from
.tasks
import
import_jekyll_articles
from
.tasks
import
import_jekyll_articles
from
.tasks
import
import_people_from_group
from
.tasks
import
import_people_from_group
...
@@ -25,4 +27,24 @@ class JekyllImportForm(SharedJekyllImportForm):
...
@@ -25,4 +27,24 @@ class JekyllImportForm(SharedJekyllImportForm):
url
=
self
.
cleaned_data
[
"
jekyll_repo_url
"
],
url
=
self
.
cleaned_data
[
"
jekyll_repo_url
"
],
dry_run
=
self
.
cleaned_data
[
"
dry_run
"
],
dry_run
=
self
.
cleaned_data
[
"
dry_run
"
],
use_git
=
True
,
use_git
=
True
,
)
)
\ No newline at end of file
class
DistrictPeoplePageForm
(
WagtailAdminPageForm
):
def
save
(
self
,
*
args
,
**
kwargs
):
# If anything inside the content field has changed,
# sync Octopus profiles just in case.
if
"
content
"
in
self
.
changed_data
:
collection_id
=
self
.
instance
.
root_page
.
image_collection_id
if
collection_id
is
None
:
collection_id
=
Collection
.
objects
.
first
().
id
for
shortcut
in
self
.
instance
.
get_syncable_octopus_groups
():
import_people_from_group
.
delay
(
self
.
instance
.
id
,
collection_id
,
shortcut
,
)
return
super
().
save
(
*
args
,
**
kwargs
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
district/models.py
+
5
−
2
View file @
9e305481
...
@@ -71,7 +71,7 @@ from shared.utils import (
...
@@ -71,7 +71,7 @@ from shared.utils import (
)
)
from
.
import
blocks
from
.
import
blocks
from
.forms
import
JekyllImportForm
from
.forms
import
JekyllImportForm
,
DistrictPeoplePageForm
CONTENT_BLOCKS
=
DEFAULT_CONTENT_BLOCKS
+
[
CONTENT_BLOCKS
=
DEFAULT_CONTENT_BLOCKS
+
[
(
"
chart
"
,
ChartBlock
()),
(
"
chart
"
,
ChartBlock
()),
...
@@ -575,6 +575,8 @@ class DistrictPersonPage(MainPersonPageMixin):
...
@@ -575,6 +575,8 @@ class DistrictPersonPage(MainPersonPageMixin):
class
DistrictPeoplePage
(
MainPeoplePageMixin
):
class
DistrictPeoplePage
(
MainPeoplePageMixin
):
base_form_class
=
DistrictPeoplePageForm
### FIELDS
### FIELDS
content
=
StreamField
(
content
=
StreamField
(
...
@@ -614,7 +616,8 @@ class DistrictPeoplePage(MainPeoplePageMixin):
...
@@ -614,7 +616,8 @@ class DistrictPeoplePage(MainPeoplePageMixin):
if
block
.
block_type
==
"
octopus_group
"
:
if
block
.
block_type
==
"
octopus_group
"
:
group_shortcuts
.
append
(
block
.
value
[
"
group_shortcut
"
])
group_shortcuts
.
append
(
block
.
value
[
"
group_shortcut
"
])
return
group_shortcuts
# Don't duplicate groups needlessly
return
list
(
set
(
group_shortcuts
))
class
DistrictCalendarPage
(
SubpageMixin
,
MetadataPageMixin
,
CalendarMixin
,
Page
):
class
DistrictCalendarPage
(
SubpageMixin
,
MetadataPageMixin
,
CalendarMixin
,
Page
):
...
...
This diff is collapsed.
Click to expand it.
shared/people_import.py
+
8
−
0
View file @
9e305481
...
@@ -291,6 +291,14 @@ class PeopleGroupImporter:
...
@@ -291,6 +291,14 @@ class PeopleGroupImporter:
person_page
=
self
.
person_page_model
.
objects
.
filter
(
person
=
person_instance
).
descendant_of
(
self
.
people_parent_page
).
first
()
person_page
=
self
.
person_page_model
.
objects
.
filter
(
person
=
person_instance
).
descendant_of
(
self
.
people_parent_page
).
first
()
if
person_page
is
None
:
if
person_page
is
None
:
if
not
isinstance
(
person_instance
.
display_name
,
str
):
logger
.
warning
(
"
Skipping page creation for user %s, they have no display name
"
,
person_instance
.
username
)
continue
person_page
=
self
.
person_page_model
(
person_page
=
self
.
person_page_model
(
person
=
person_instance
,
person
=
person_instance
,
is_automatically_created
=
True
,
is_automatically_created
=
True
,
...
...
This diff is collapsed.
Click to expand it.
shared/templatetags/people_filters.py
+
1
−
1
View file @
9e305481
...
@@ -8,7 +8,7 @@ def is_first_people_type(content, forloop):
...
@@ -8,7 +8,7 @@ def is_first_people_type(content, forloop):
first_people_type_position
=
None
first_people_type_position
=
None
for
position
,
item
in
enumerate
(
content
):
for
position
,
item
in
enumerate
(
content
):
if
item
.
block_type
in
(
"
people_group
"
,
"
team_group
"
):
if
item
.
block_type
in
(
"
octopus_group
"
,
"
people_group
"
,
"
team_group
"
):
if
first_people_type_position
is
None
:
if
first_people_type_position
is
None
:
first_people_type_position
=
position
first_people_type_position
=
position
break
break
...
...
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