Skip to content
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

Merged
merged 2 commits into from
May 6, 2024

Conversation

fkantelberg
Copy link
Member

This PR continues #231 and has implemented the following:

  • Usage of existing apikeys of Odoo instead of a new model with tokens
  • Offers an advanced mode which helps with more complex iCalendar files (allows to use the defined Odoo functions _get_ics_file to generate events)
  • Add additional help in the form view

@fkantelberg
Copy link
Member Author

FYI @hbrunn @amh-mw

FYI @jans23 In the advanced mode using calendar = record._get_ics_file() for calendar.event should also include VALARM.

)
def get_ical(self, calendar_id, access_token=None):
if not access_token:
raise request.not_found()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

401 Unauthorized

key=access_token,
)
if not user_id:
raise request.not_found()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

401 Unauthorized

from odoo import fields, models


class BaseIcalToken(models.Model):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete unused file

calendar = (
http.request.env["base.ical"]
.sudo()
.search([("id", "=", calendar_id)])
Copy link

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?

Copy link
Member Author

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.


calendar = (
http.request.env["base.ical"]
.sudo()
Copy link

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()
Copy link

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.

Copy link
Member Author

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.

Copy link
Member

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",
Copy link

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?

Copy link
Member Author

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.

if not calendar:
return request.not_found()

records = calendar._get_items()
Copy link
Member

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

Copy link

@amh-mw amh-mw left a 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.

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@hbrunn
Copy link
Member

hbrunn commented May 6, 2024

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 15.0-ocabot-merge-pr-286-by-hbrunn-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 696aa59 into OCA:15.0 May 6, 2024
5 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at ad01df9. Thanks a lot for contributing to OCA. ❤️

SiesslPhillip pushed a commit to grueneerde/OCA-server-backend that referenced this pull request Nov 20, 2024
Syncing from upstream OCA/server-backend (16.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants