-
-
Notifications
You must be signed in to change notification settings - Fork 282
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
[ADD][15.0] base_ical: Module to expose iCalendar over URL #286
Conversation
42996f8
to
e2a132a
Compare
base_ical/controllers/main.py
Outdated
) | ||
def get_ical(self, calendar_id, access_token=None): | ||
if not access_token: | ||
raise request.not_found() |
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.
401 Unauthorized
base_ical/controllers/main.py
Outdated
key=access_token, | ||
) | ||
if not user_id: | ||
raise request.not_found() |
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.
401 Unauthorized
base_ical/models/base_ical_token.py
Outdated
from odoo import fields, models | ||
|
||
|
||
class BaseIcalToken(models.Model): |
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.
Delete unused file
base_ical/controllers/main.py
Outdated
calendar = ( | ||
http.request.env["base.ical"] | ||
.sudo() | ||
.search([("id", "=", calendar_id)]) |
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.
Replace search(...)
with browse(calendar_id)
and relevant exception handling?
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.
There is a big difference. browse
doesn't check against existing (you would have to use exists
afterwards which also results in a query. Also search
would automatically hide inactive ones. I favor search here.
base_ical/controllers/main.py
Outdated
|
||
calendar = ( | ||
http.request.env["base.ical"] | ||
.sudo() |
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.
Given that users have read access to base.ical model per the security csv, replace sudo()
with with_user(user_id)
from below?
if not calendar: | ||
return request.not_found() | ||
|
||
records = calendar._get_items() |
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.
My suggestion above means that this call to _get_items()
is no longer in sudo() mode and could return fewer results. I'm open to an argument on this.
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.
Before is wasn't su too. because as @hbrunn mention with_user
sets the su flag to false per default. Either way I guess that without sudo would be correct because you don't want to allow access to stuff a user can't see. If you link it with a nextcloud you should do it with an user with proper rights.
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 agree it should be as it is - .with_user but no sudo
"version": "15.0.1.0.0", | ||
"development_status": "Alpha", | ||
"category": "Tools", | ||
"website": "https://github.com/OCA/server-backend", |
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.
Should this land in https://github.com/OCA/calendar instead?
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.
Not sure how we want to sort it. You can publish leaves => holidays. You can publish activities as TODO => social(?). You can publish a calendar => calendar. You can also publish attendance => attendance. server-backend might fit as general place.
You will probably use it in your calendar application but I'm not sure if this is the correct criteria.
e2a132a
to
d7f8964
Compare
if not calendar: | ||
return request.not_found() | ||
|
||
records = calendar._get_items() |
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 agree it should be as it is - .with_user but no sudo
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 still think this would land better in OCA/calendar (especially with regard to adding vobject to requirements.txt), but otherwise have no complaints.
This PR has the |
/ocabot merge nobump |
This PR looks fantastic, let's merge it! |
Congratulations, your PR was merged at ad01df9. Thanks a lot for contributing to OCA. ❤️ |
Syncing from upstream OCA/server-backend (16.0)
This PR continues #231 and has implemented the following:
_get_ics_file
to generate events)