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
fc00482b
Commit
fc00482b
authored
6 years ago
by
Parbhat Puri
Committed by
Fredrik Jonsson
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Exclude non-text answers like attachment from compare revisions
parent
dd74d79f
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/funds/models/mixins.py
+19
-1
19 additions, 1 deletion
opentech/apply/funds/models/mixins.py
opentech/apply/funds/views.py
+5
-5
5 additions, 5 deletions
opentech/apply/funds/views.py
with
24 additions
and
6 deletions
opentech/apply/funds/models/mixins.py
+
19
−
1
View file @
fc00482b
...
...
@@ -3,7 +3,9 @@ from django.utils.text import mark_safe
from
django.core.files
import
File
from
django.core.files.storage
import
get_storage_class
from
opentech.apply.stream_forms.blocks
import
FormFieldBlock
from
opentech.apply.stream_forms.blocks
import
(
FileFieldBlock
,
FormFieldBlock
,
ImageFieldBlock
,
MultiFileFieldBlock
)
from
opentech.apply.utils.blocks
import
SingleIncludeMixin
from
opentech.apply.stream_forms.blocks
import
UploadableMediaBlock
...
...
@@ -112,6 +114,14 @@ class AccessFormData:
if
isinstance
(
field
.
block
,
FormFieldBlock
):
yield
field_id
@property
def
question_text_field_ids
(
self
):
for
field_id
,
field
in
self
.
fields
.
items
():
if
isinstance
(
field
.
block
,
(
FileFieldBlock
,
ImageFieldBlock
,
MultiFileFieldBlock
)):
pass
elif
isinstance
(
field
.
block
,
FormFieldBlock
):
yield
field_id
@property
def
raw_fields
(
self
):
# Field ids to field class mapping - similar to raw_data
...
...
@@ -168,6 +178,14 @@ class AccessFormData:
for
field_id
in
self
.
normal_blocks
]
def
render_text_blocks_answers
(
self
):
# Returns a list of the rendered answers of type text
return
[
self
.
render_answer
(
field_id
,
include_question
=
True
)
for
field_id
in
self
.
question_text_field_ids
if
field_id
not
in
self
.
named_blocks
]
def
output_answers
(
self
):
# Returns a safe string of the rendered answers
return
mark_safe
(
''
.
join
(
self
.
render_answers
()))
This diff is collapsed.
Click to expand it.
opentech/apply/funds/views.py
+
5
−
5
View file @
fc00482b
...
...
@@ -462,11 +462,11 @@ class RevisionCompareView(DetailView):
def
compare_revisions
(
self
,
from_data
,
to_data
):
self
.
object
.
form_data
=
from_data
.
form_data
from_fields
=
self
.
object
.
render_answers
()
from_
rendered_text_
fields
=
self
.
object
.
render_
text_blocks_
answers
()
from_required
=
self
.
render_required
()
self
.
object
.
form_data
=
to_data
.
form_data
to_fields
=
self
.
object
.
render_answers
()
to_
rendered_text_
fields
=
self
.
object
.
render_
text_blocks_
answers
()
to_required
=
self
.
render_required
()
# Compare all the required fields
...
...
@@ -478,12 +478,12 @@ class RevisionCompareView(DetailView):
setattr
(
self
.
object
,
'
get_{}_display
'
.
format
(
field
),
diff
)
# Compare all the answers
diffed_answers
=
[
diffed_
text_fields_
answers
=
[
compare
(
*
fields
,
should_bleach
=
False
)
for
fields
in
zip
(
from_
fields
,
to
_fields
)
for
fields
in
zip
(
from_
rendered_text_fields
,
to_rendered_text
_fields
)
]
self
.
object
.
output_answers
=
mark_safe
(
''
.
join
(
diffed_answers
))
self
.
object
.
output_answers
=
mark_safe
(
''
.
join
(
diffed_
text_fields_
answers
))
def
render_required
(
self
):
return
[
...
...
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