Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hypha
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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
ots
hypha
Commits
b9e64059
Commit
b9e64059
authored
6 years ago
by
Todd Dembrey
Browse files
Options
Downloads
Patches
Plain Diff
Use the block render method to control display and more robust ordering
parent
69a3cd36
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
opentech/apply/review/views.py
+4
-10
4 additions, 10 deletions
opentech/apply/review/views.py
opentech/apply/utils/blocks.py
+3
-0
3 additions, 0 deletions
opentech/apply/utils/blocks.py
with
7 additions
and
10 deletions
opentech/apply/review/views.py
+
4
−
10
View file @
b9e64059
...
@@ -134,6 +134,8 @@ class ReviewListView(ListView):
...
@@ -134,6 +134,8 @@ class ReviewListView(ListView):
review_data
[
'
recommendation
'
]
=
{
'
question
'
:
'
Recommendation
'
,
'
answers
'
:
list
()}
review_data
[
'
recommendation
'
]
=
{
'
question
'
:
'
Recommendation
'
,
'
answers
'
:
list
()}
review_data
[
'
revision
'
]
=
{
'
question
'
:
'
Revision
'
,
'
answers
'
:
list
()}
review_data
[
'
revision
'
]
=
{
'
question
'
:
'
Revision
'
,
'
answers
'
:
list
()}
responses
=
self
.
object_list
.
count
()
for
i
,
review
in
enumerate
(
self
.
object_list
):
for
i
,
review
in
enumerate
(
self
.
object_list
):
review_data
[
'
title
'
][
'
answers
'
].
append
(
str
(
review
.
author
))
review_data
[
'
title
'
][
'
answers
'
].
append
(
str
(
review
.
author
))
review_data
[
'
score
'
][
'
answers
'
].
append
(
str
(
review
.
score
))
review_data
[
'
score
'
][
'
answers
'
].
append
(
str
(
review
.
score
))
...
@@ -150,16 +152,8 @@ class ReviewListView(ListView):
...
@@ -150,16 +152,8 @@ class ReviewListView(ListView):
if
not
isinstance
(
field
.
block
,
(
RecommendationBlock
,
RichTextBlock
)):
if
not
isinstance
(
field
.
block
,
(
RecommendationBlock
,
RichTextBlock
)):
question
=
field
.
value
[
'
field_label
'
]
question
=
field
.
value
[
'
field_label
'
]
# If we haven't see the question before we backfill with '-'
# If we haven't see the question before we backfill with '-'
review_data
.
setdefault
(
field
.
id
,
{
'
question
'
:
question
,
'
answers
'
:
[
''
]
*
i
})
review_data
.
setdefault
(
field
.
id
,
{
'
question
'
:
question
,
'
answers
'
:
[
''
]
*
responses
})
review_data
[
field
.
id
][
'
answers
'
][
i
]
=
field
.
block
.
render
(
None
,
{
'
data
'
:
data
})
if
isinstance
(
field
.
block
,
ScoreFieldBlock
):
value
=
json
.
loads
(
data
)
rating_value
=
int
(
value
[
1
])
rating
=
RATE_CHOICES_DICT
.
get
(
rating_value
,
RATE_CHOICE_NA
)
comment
=
str
(
value
[
0
])
review_data
[
field
.
id
][
'
answers
'
].
append
(
rating
+
comment
)
else
:
review_data
[
field
.
id
][
'
answers
'
].
append
(
str
(
data
))
return
super
().
get_context_data
(
return
super
().
get_context_data
(
submission
=
self
.
submission
,
submission
=
self
.
submission
,
...
...
This diff is collapsed.
Click to expand it.
opentech/apply/utils/blocks.py
+
3
−
0
View file @
b9e64059
...
@@ -38,6 +38,9 @@ class RichTextFieldBlock(TextFieldBlock):
...
@@ -38,6 +38,9 @@ class RichTextFieldBlock(TextFieldBlock):
def
get_searchable_content
(
self
,
value
,
data
):
def
get_searchable_content
(
self
,
value
,
data
):
return
bleach
.
clean
(
data
or
''
,
tags
=
[],
strip
=
True
)
return
bleach
.
clean
(
data
or
''
,
tags
=
[],
strip
=
True
)
def
no_response
(
self
):
return
'
<p>No response</p>
'
class
CustomFormFieldsBlock
(
StreamBlock
):
class
CustomFormFieldsBlock
(
StreamBlock
):
rich_text
=
RichTextFieldBlock
(
group
=
_
(
'
Fields
'
))
rich_text
=
RichTextFieldBlock
(
group
=
_
(
'
Fields
'
))
...
...
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