-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
added funtion get_allow_discussion_value #1655
Conversation
@Akshat2Jain thanks for creating this Pull Request and helping to improve Plone! TL;DR: Finish pushing changes, pass all other checks, then paste a comment:
To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically. Happy hacking! |
✅ Deploy Preview for plone-restapi canceled.
|
@Akshat2Jain see if you can create a branch in the repository itself in |
Hey @wesleybl, I don't have access rights to create a branch |
To allow tests to run on PRs from forks, we need to update the GitHub Workflows, similar to what we did in Volto: plone/volto@5808b78 We restricted access across the Plone GitHub organization for members of I created a new issue to deal with the above at #1656 @Akshat2Jain meanwhile would you please add a change log entry, per instructions in https://6.docs.plone.org/contributing/index.html#change-log-entry. Thank you! |
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.
Please make the code conditional, because soon, for Plone 6.1, plone.app.discussion becomes an optional core addon. It can be absent as a package or not installed via GenricSetup.
@jensens checking if the object has the |
hmm i think checking if the |
I think this will be a more desirable solution approach because the code remains compatible with Plone 6.1 irrespective of whether the plone.app.discussion package is present or not. Could you please advise on which approach you recommend and also how to do it? @wesleybl |
@Akshat2Jain I think it would be something like: if "allow_discussion" in result:
result["allow_discussion"] = get_allow_discussion_value(self.context, self.request) You need to rebase with master before continuing. |
Yeah! This is also correct but I have done something this.
But this will increase no of lines of code! Thanks! |
Some remarks:
|
Today it is already used. See: plone.restapi/src/plone/restapi/serializer/dxcontent.py Lines 128 to 130 in 053a266
|
@wesleybl . I have made the changes. Can you review it. |
@Akshat2Jain by having several commits, I suspect that you were making the commits through the github website. I recommend that next time, you make a clone of the repository and put several files in one commit. That way we won't have multiple commits. |
@jensens since Do we plan to have a |
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 left some comments. See also that Black and flake8 are failing:
https://github.com/plone/plone.restapi/actions/runs/5355874837/jobs/9714682689?pr=1655
https://github.com/plone/plone.restapi/actions/runs/5355874859/jobs/9714682668?pr=1655
Conditional support is fine. It is the same as currently with p.a.iterate, in near future with multilingual and there may add up other packages. Plan is to reduce the Plone core (the packages between plone.base and CMFPlone) and add them as core-addons to the space between CMFPlone and the Plone integration package. Distributions then can choose to have them or not. |
@wesleybl can you review it? |
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.
Pease make a clone of the repository and put several files in one commit. That way we won't have multiple commits.
Checks at Some checks were not successful
:
must pass.
@wesleybl . I have made the changes. |
@Akshat2Jain the github action output itself says what needs to be changed. to see: https://github.com/plone/plone.restapi/actions/runs/5462642539/jobs/9942277773?pr=1655#step:5:20 But ideally, you have The |
news/4758.bugfix
Outdated
@@ -0,0 +1,6 @@ | |||
add the function |
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.
Use the PR number in the file name.
news/4758.bugfix
Outdated
def get_allow_discussion_value(context, request): | ||
return getMultiAdapter((context, request), name="conversation_view").enabled() |
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.
It is not necessary to have code in Changes.
if "allow_discussion" in result: | ||
result["allow_discussion"] = get_allow_discussion_value(self.context, self.request, result) |
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.
The test is being done inside the function. So we shouldn't do the test here. Assignment is also being done in the function.
if "allow_discussion" in result: | |
result["allow_discussion"] = get_allow_discussion_value(self.context, self.request, result) | |
get_allow_discussion_value(self.context, self.request, result) |
src/plone/restapi/serializer/site.py
Outdated
@@ -121,6 +122,8 @@ def __call__(self, version=None): | |||
for brain in batch | |||
] | |||
|
|||
result["allow_discussion"] = get_allow_discussion_value(self.context, self.request, result) |
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.
The assignment is being done inside the function. So we shouldn't do assignment here.
result["allow_discussion"] = get_allow_discussion_value(self.context, self.request, result) | |
get_allow_discussion_value(self.context, self.request, result) |
This should go into the documentation: https://6.docs.plone.org/plone.restapi/docs/source/contributing/index.html. It's not in the README. At the very least, an output of the |
I have run the |
It shouldn't format so many files. What version of ./bin/black --version Can you please also inform the output of |
@wesleybl
output of
|
@Akshat2Jain the Makefile is installing the latest from Line 47 in 815dbb6
Meanwhile, CI is installing version of plone.restapi/.github/workflows/black.yml Line 25 in 9097cfc
Would you like to do another PR, to install the version of black and click that is in versions.cfg in Makefile? You could also upgrade to the latest versions of click and black in versions.cfg You need to update your fork's master branch with the original repository's master branch first. |
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.
Tests are failing. At the end of the CI tracebak it indicates the error. For example:
https://github.com/plone/plone.restapi/actions/runs/5572932135/jobs/10179541947?pr=1655#step:10:789
You can run the tests locally with make test
while running
|
@Akshat2Jain did you issue the command from the root of the Volto repository? |
did you mean from the root of |
Oops, yes. Sorry, I am multitasking. |
Actually, I tried So I issued just |
|
Yup, Now it is running but I don't know why, I did these steps 2-3 times and at that time it was not running for me. |
b4c1888
to
18f7340
Compare
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 reviewed only the news item. It still needs review by a maintainer.
news/1665.bugfix
Outdated
@@ -0,0 +1 @@ | |||
added the function get_allow_discussion_value(context, request) returns True if discussion is allowed and False if not, based on the enabled status of the "conversation_view" adapter.@Akshat2Jain |
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.
added the function get_allow_discussion_value(context, request) returns True if discussion is allowed and False if not, based on the enabled status of the "conversation_view" adapter.@Akshat2Jain | |
Added the function `get_allow_discussion_value(context, request)`. It returns `True` if discussion is allowed, or `False` if not, based on the enabled status of the `conversation_view` adapter. @Akshat2Jain |
@jensens @sneridagh a test was made to try to verify that
However, when
See: https://github.com/plone/plone.restapi/actions/runs/5586686877/jobs/10211032234?pr=1655#step:10:33 Any other test to see if So I ask, is it ok if we don't have the |
d819614
to
b7c9acf
Compare
@jensens @sneridagh any opinions here? |
@davisagli any opinions here? See comment on @jensens' review and #1655 (comment). |
@davisagli @jensens any suggestions? we are close to completing this |
@jensens @sneridagh @davisagli as @Akshat2Jain please remove the test. |
78f7e3a
to
24f25d7
Compare
I mistakenly committed the changes without updating the branch, should I create a new branch within the repo? |
@wesleybl , Can You help me with this? |
@Akshat2Jain you can reset this commit: But if you think it's better, you can create a new branch and a new PR. |
Description
This pr aims to add the function
in
dxcontent.py
andsite.py
Why
Plone Site serializer and the Dexterity serializer return the same value for the "allow_discussion" field. Rather than duplicating the code, creating a separate function that can be called by both serializers to set the value consistently.
This pr related to the issue mentioned in volto project
fixes plone/volto#4758