-
Notifications
You must be signed in to change notification settings - Fork 6
Remove blocker to add/edit DREF form for other languages. #2003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: project/dref-translation
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -36,7 +36,6 @@ import DrefExportModal from '#components/domain/DrefExportModal'; | |||
import { type FieldReportItem as FieldReportSearchItem } from '#components/domain/FieldReportSearchSelectInput'; | ||||
import FormFailedToLoadMessage from '#components/domain/FormFailedToLoadMessage'; | ||||
import LanguageMismatchMessage from '#components/domain/LanguageMismatchMessage'; | ||||
import NonEnglishFormCreationMessage from '#components/domain/NonEnglishFormCreationMessage'; | ||||
import Link from '#components/Link'; | ||||
import NonFieldError from '#components/NonFieldError'; | ||||
import Page from '#components/Page'; | ||||
|
@@ -383,6 +382,7 @@ export function Component() { | |||
method: 'PATCH', | ||||
pathVariables: isDefined(drefId) ? { id: drefId } : undefined, | ||||
body: (formFields: DrefRequestBody) => formFields, | ||||
useCurrentLanguageForMutation: true, | ||||
onSuccess: (response) => { | ||||
alert.show( | ||||
strings.formSaveRequestSuccessMessage, | ||||
|
@@ -479,6 +479,7 @@ export function Component() { | |||
url: '/api/v2/dref/', | ||||
method: 'POST', | ||||
body: (formFields: DrefRequestPostBody) => formFields, | ||||
useCurrentLanguageForMutation: true, | ||||
onSuccess: (response) => { | ||||
alert.show( | ||||
strings.formSaveRequestSuccessMessage, | ||||
|
@@ -609,13 +610,14 @@ export function Component() { | |||
const disabled = fetchingDref || saveDrefPending; | ||||
|
||||
// New DREFs can only be created in English | ||||
const nonEnglishCreate = isNotDefined(drefId) && currentLanguage !== 'en'; | ||||
// const nonEnglishCreate = isNotDefined(drefId) && currentLanguage !== 'en'; | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's remove these comments. |
||||
|
||||
const languageMismatch = isDefined(drefId) | ||||
&& isDefined(drefResponse) | ||||
&& currentLanguage !== drefResponse?.translation_module_original_language; | ||||
const shouldHideForm = nonEnglishCreate | ||||
|| languageMismatch | ||||
|| fetchingDref | ||||
|
||||
const shouldHideForm = fetchingDref | ||||
// || nonEnglishCreate | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
|| isDefined(drefResponseError); | ||||
|
||||
return ( | ||||
|
@@ -730,11 +732,11 @@ export function Component() { | |||
originalLanguage={drefResponse.translation_module_original_language} | ||||
/> | ||||
)} | ||||
{nonEnglishCreate && ( | ||||
{/* nonEnglishCreate && ( | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's just remove these blocks if we do not block by form langauge anymore |
||||
<NonEnglishFormCreationMessage | ||||
title={strings.formNotAvailableInNonEnglishMessage} | ||||
/> | ||||
)} | ||||
) */} | ||||
{isDefined(drefResponseError) && ( | ||||
<FormFailedToLoadMessage | ||||
title={strings.formLoadErrorTitle} | ||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -43,6 +43,7 @@ import NonFieldError from '#components/NonFieldError'; | |||||
import Page from '#components/Page'; | ||||||
import useCurrentLanguage from '#hooks/domain/useCurrentLanguage'; | ||||||
import useAlert from '#hooks/useAlert'; | ||||||
import { DREF_STATUS_APPROVED } from '#utils/constants'; | ||||||
import { | ||||||
type GoApiResponse, | ||||||
useLazyRequest, | ||||||
|
@@ -313,7 +314,7 @@ export function Component() { | |||||
const prevOperationalUpdateId = useMemo(() => { | ||||||
const currentOpsUpdate = drefResponse | ||||||
?.operational_update_details | ||||||
?.find((ou) => !ou.is_published); | ||||||
?.find((ou) => !(ou.status === DREF_STATUS_APPROVED)); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
if (isNotDefined(currentOpsUpdate)) { | ||||||
return undefined; | ||||||
|
@@ -344,6 +345,7 @@ export function Component() { | |||||
} = useLazyRequest({ | ||||||
url: '/api/v2/dref-op-update/{id}/', | ||||||
method: 'PATCH', | ||||||
useCurrentLanguageForMutation: true, | ||||||
pathVariables: isDefined(opsUpdateId) ? { id: opsUpdateId } : undefined, | ||||||
body: (formFields: OpsUpdateRequestBody) => formFields, | ||||||
onSuccess: (response) => { | ||||||
|
@@ -575,8 +577,8 @@ export function Component() { | |||||
const languageMismatch = isDefined(opsUpdateId) | ||||||
&& isDefined(drefResponse) | ||||||
&& currentLanguage !== opsUpdateResponse?.translation_module_original_language; | ||||||
const shouldHideForm = languageMismatch | ||||||
|| fetchingOpsUpdate | ||||||
|
||||||
const shouldHideForm = fetchingOpsUpdate | ||||||
|| isDefined(opsUpdateResponseError); | ||||||
|
||||||
return ( | ||||||
|
+1 −1 | .pre-commit-config.yaml | |
+39 −1 | api/admin.py | |
+190 −0 | api/admin_reports.py | |
+6 −3 | api/management/commands/ingest_ns_initiatives.py | |
+18 −0 | api/migrations/0224_nsdinitiatives_nsia_risk.py | |
+33 −0 | api/migrations/0225_nsdinitiatives_nsia_risk_ar_and_more.py | |
+1 −0 | api/models.py | |
+140 −0 | api/templates/admin/users_per_permission.html | |
+3 −3 | api/test_views.py | |
+2 −2 | api/translation.py | |
+4 −1 | dref/admin.py | |
+2 −2 | dref/filter_set.py | |
+83 −0 | dref/migrations/0084_dref_original_language_and_more.py | |
+25 −0 | dref/migrations/0085_remove_dref_is_published_and_more.py | |
+32 −21 | dref/models.py | |
+2 −2 | dref/permissions.py | |
+79 −32 | dref/serializers.py | |
+22 −0 | dref/tasks.py | |
+501 −87 | dref/test_views.py | |
+103 −0 | dref/translation.py | |
+106 −19 | dref/views.py | |
+8 −5 | lang/tasks.py | |
+10 −6 | local_units/management/commands/import_health_data.py | |
+0 −3 | local_units/management/commands/import_local_units_health.py | |
+5 −1 | main/urls.py | |
+2 −1 | registrations/tasks.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can DRAFT and COMPLETED both be 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to remove the commented status the status has been updated, and there are new ones added as well.