Skip to content

Commit

Permalink
Merge pull request #911 from bcgov/dev
Browse files Browse the repository at this point in the history
9.5.10 release - merge dev to test
  • Loading branch information
nkan-aot2 authored Mar 26, 2024
2 parents cae9afa + 58951fd commit e78106e
Show file tree
Hide file tree
Showing 11 changed files with 2,007 additions and 17,760 deletions.
51 changes: 27 additions & 24 deletions MCS.FOI.S3FileConversion/MCS.FOI.DocToPDF/DocFileProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,33 +48,36 @@ public DocFileProcessor(Stream SourceStream)
{
SourceStream.Position = 0;

using (var docXML = WordprocessingDocument.Open(SourceStream, false))
if (wordDocument.ActualFormatType == FormatType.Docx)
{

DocumentFormat.OpenXml.Wordprocessing.Body body = docXML.MainDocumentPart.Document.Body;
List<String> originalDates = new List<String>();
foreach (var textItem in body.Descendants<FieldCode>().Where(textItem => textItem.Text.Contains("DATE")))
{
var datetext = textItem.Parent.NextSibling().NextSibling();
originalDates.Add(datetext.InnerText);
}

List<Entity> datefields = wordDocument.FindAllItemsByProperty(EntityType.Field, "FieldType", FieldType.FieldDate.ToString());
if (datefields != null)
using (var docXML = WordprocessingDocument.Open(SourceStream, false))
{
foreach (var (datefield, i) in datefields.Select((datefield, i) => (datefield, i)))

DocumentFormat.OpenXml.Wordprocessing.Body body = docXML.MainDocumentPart.Document.Body;
List<String> originalDates = new List<String>();
foreach (var textItem in body.Descendants<FieldCode>().Where(textItem => textItem.Text.Contains("DATE")))
{
var datetext = textItem.Parent.NextSibling().NextSibling();
originalDates.Add(datetext.InnerText);
}

List<Entity> datefields = wordDocument.FindAllItemsByProperty(EntityType.Field, "FieldType", FieldType.FieldDate.ToString());
if (datefields != null)
{
var dateField = datefield as WField;
//Takes the owner paragraph.
WParagraph ownerPara = dateField.OwnerParagraph;
int dateFieldIndex = ownerPara.ChildEntities.IndexOf(dateField);
//Removes the date field.
ownerPara.ChildEntities.Remove(dateField);
//Creating a new text range with required date.
WTextRange textRange = new WTextRange(ownerPara.Document);
textRange.Text = originalDates[i];//"February 12, 2023";
//Inserting the date field with the created text range.
ownerPara.ChildEntities.Insert(dateFieldIndex, textRange);
foreach (var (datefield, i) in datefields.Select((datefield, i) => (datefield, i)))
{
var dateField = datefield as WField;
//Takes the owner paragraph.
WParagraph ownerPara = dateField.OwnerParagraph;
int dateFieldIndex = ownerPara.ChildEntities.IndexOf(dateField);
//Removes the date field.
ownerPara.ChildEntities.Remove(dateField);
//Creating a new text range with required date.
WTextRange textRange = new WTextRange(ownerPara.Document);
textRange.Text = originalDates[i];//"February 12, 2023";
//Inserting the date field with the created text range.
ownerPara.ChildEntities.Insert(dateFieldIndex, textRange);
}
}
}
}
Expand Down
32 changes: 32 additions & 0 deletions api/migrations/versions/e0e3a10b850d_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""Add new section (NOT RESPONSIVE)
Revision ID: e0e3a10b850d
Revises: 7db1cd6f0b36
Create Date: 2024-01-29 13:01:30.668629
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = 'e0e3a10b850d'
down_revision = '7db1cd6f0b36'
branch_labels = None
depends_on = None


def upgrade():
#Add new section and make its sort order 26
op.execute(
"""
INSERT INTO public."Sections" (section, description, sortorder, isactive, createdby) VALUES ('NR', 'Not Responsive', 26, True, 'System');
"""
)

def downgrade():
op.execute(
"""
DELETE FROM public."Sections" WHERE section in ('NR');
"""
)
2 changes: 1 addition & 1 deletion api/reviewer_api/models/AnnotationSections.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def getsectionmappingbyrequestid(cls, ministryrequestid, redactionlayerid):
try:
sql = """select as2.annotationname ,
cast("section" AS json) ->> 'redactannotation' as redactannotation,
cast("section" AS json) ->> 'ids' as ids
cast("section" AS json) ->> 'ids' as ids
from "AnnotationSections" as2, "Annotations" a
join (select distinct on (docs.documentid) docs.*
from "Documents" docs
Expand Down
2 changes: 1 addition & 1 deletion api/reviewer_api/services/documentpageflagservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def __getupdatedpageflag(self, pageflag, pages_to_remove):
return [
entry
for entry in pageflag["pageflag"]
if entry["page"] not in pages_to_remove or entry["flagid"] not in [1, 3, 7]
if entry["page"] not in pages_to_remove or entry["flagid"] not in [1, 2, 3, 7]
]

def __createnewpageflag(self, pageflag, data):
Expand Down
Loading

0 comments on commit e78106e

Please sign in to comment.