SF-3741 Allow admins to apply drafts to books they do not have write access to#3733
SF-3741 Allow admins to apply drafts to books they do not have write access to#3733
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3733 +/- ##
==========================================
- Coverage 81.32% 81.31% -0.02%
==========================================
Files 620 620
Lines 39056 39075 +19
Branches 6374 6351 -23
==========================================
+ Hits 31764 31774 +10
- Misses 6310 6329 +19
+ Partials 982 972 -10 ☔ View full report in Codecov by Sentry. |
RaymondLuong3
left a comment
There was a problem hiding this comment.
@RaymondLuong3 reviewed 10 files and all commit messages, and made 3 comments.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on pmachapman).
src/SIL.XForge.Scripture/Services/MachineApiService.cs line 506 at r1 (raw file):
// Ensure the current user has permission to update the specified books, // adding them if they are missing and are an administrator.
Nit: This comment is a little awkward. I think it should start with "When the user is a project administrator..."
Code quote:
// Ensure the current user has permission to update the specified books,
// adding them if they are missing and are an administrator.src/SIL.XForge.Scripture/Services/ParatextService.cs line 1743 at r1 (raw file):
/// <param name="booksToUpdate"> /// The book numbers to update. /// If specified these books will be updated, otherwise only new books not disk will be updated.
Nit: "not on disk" is what I think it should say
Code quote:
otherwise only new books not disk will be updated.src/SIL.XForge.Scripture/Services/ParatextService.cs line 1776 at r1 (raw file):
TextInfo text = projectDoc.Data.Texts[i]; int bookNum = text.BookNum; if (booksToUpdate.Length == 0 ? scrText.BookPresent(bookNum) : !booksToUpdate.Contains(bookNum))
This is kind of an awkward if statement. Could you simplify this?
Code quote:
if (booksToUpdate.Length == 0 ? scrText.BookPresent(bookNum) : !booksToUpdate.Contains(bookNum))
RaymondLuong3
left a comment
There was a problem hiding this comment.
My understanding is that this PR aims at allowing administrators to successfully import a draft to their project even if they do not have permission. When I try to import a draft to Matthew, it fails because I don't have permission (the book exists but I do not have permission in PT). This seems wrong that I can get to the import step. It should notify me that I cannot import on the first step of the wizard. Or if the aim is to change the behaviour, I should have been able to successfully override the permissions and Matthew should have successfully imported.
@RaymondLuong3 made 1 comment.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on pmachapman).
pmachapman
left a comment
There was a problem hiding this comment.
I should have been able to successfully override the permissions and Matthew should have successfully imported.
Yes, it should have done that. Can you add me to the project you tested this PR with, so I can see why it failed? Also, I am assuming you restarted the dotnet process when testing this PR?
@pmachapman made 4 comments and resolved 2 discussions.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on RaymondLuong3).
src/SIL.XForge.Scripture/Services/MachineApiService.cs line 506 at r1 (raw file):
Previously, RaymondLuong3 (Raymond Luong) wrote…
Nit: This comment is a little awkward. I think it should start with "When the user is a project administrator..."
Done. Is this better?
src/SIL.XForge.Scripture/Services/ParatextService.cs line 1743 at r1 (raw file):
Previously, RaymondLuong3 (Raymond Luong) wrote…
Nit: "not on disk" is what I think it should say
Done. Yes, thank you.
src/SIL.XForge.Scripture/Services/ParatextService.cs line 1776 at r1 (raw file):
Previously, RaymondLuong3 (Raymond Luong) wrote…
This is kind of an awkward if statement. Could you simplify this?
Done. Is this easier to read?
RaymondLuong3
left a comment
There was a problem hiding this comment.
Ok, thanks for giving that a try. I forgot that my user was a translator. When I updated the role to administrator, it successfully imported the draft of Matthew. It is working as expected.
@RaymondLuong3 reviewed 6 files and all commit messages, and made 3 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on pmachapman).
src/SIL.XForge.Scripture/Services/MachineApiService.cs line 506 at r1 (raw file):
Previously, pmachapman (Peter Chapman) wrote…
Done. Is this better?
It should say, "... and do not have permission."
src/SIL.XForge.Scripture/Services/ParatextService.cs line 1776 at r1 (raw file):
Previously, pmachapman (Peter Chapman) wrote…
Done. Is this easier to read?
Yes, that is better.
pmachapman
left a comment
There was a problem hiding this comment.
@pmachapman made 1 comment and resolved 1 discussion.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on pmachapman).
src/SIL.XForge.Scripture/Services/MachineApiService.cs line 506 at r1 (raw file):
Previously, RaymondLuong3 (Raymond Luong) wrote…
It should say, "... and do not have permission."
Done. Thanks!
This PR updates the apply draft logic to add permissions for the current user when applying the draft to an existing book or chapter, and the user does not have permissions for that book/chapter despite being an administrator.
This change is