Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions website_snippet_calendar/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

================
Calendar Snippet
================

This module adds a new block in the website editor.
The new block is based on the calendar of module Calendar. Use field 'Privacy'
to determine its publicity.
Since it's a block it can be placed anywhere on your website.

Configuration
=============

Privacy setting is per event; in order to change privacy setting go to:

* the event form;
* click Edit Event button;
* go to Options tab.

Usage
=====

To use this module, you need to:

* Go to the website and click Edit;
* Click on Insert Blocks;
* Select the Features section.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/186/9.0

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/website/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback.

Credits
=======

Images
------

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.

Contributors
------------

* Dennis Sluijk <d.sluijk@onestein.nl>

Do not contact contributors directly about support or help with technical issues.

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

To contribute to this module, please visit https://odoo-community.org.
4 changes: 4 additions & 0 deletions website_snippet_calendar/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import controllers
25 changes: 25 additions & 0 deletions website_snippet_calendar/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
'name': 'Calendar Snippet',
'category': 'Website',
'summary': 'Calendar on website.',
'version': '9.0.1.0.0',
'author': 'Onestein,Odoo Community Association (OCA)',
'license': 'AGPL-3',
'website': 'http://www.onestein.eu',
'depends': [
'website',
'calendar',
'web'
],
'data': [
'security/ir.model.access.csv',
'security/security.xml',
'templates/assets.xml',
'templates/snippets.xml',
],
'installable': True,
}
4 changes: 4 additions & 0 deletions website_snippet_calendar/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import main
59 changes: 59 additions & 0 deletions website_snippet_calendar/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from json import dumps
from datetime import datetime

from openerp import http


class WebsiteCalendarSnippet(http.Controller):

@http.route(
['/calendar_snippet/get_events/<int:start>/<int:end>'],
type='http',
auth='public',
website=True)
def get_events(self, start, end, **post):
request = http.request

# Get events
calendar_event_obj = request.env['calendar.event']
calendar_events = calendar_event_obj.search(
[('start', '<', unicode(datetime.fromtimestamp(end))),
('stop', '>', unicode(datetime.fromtimestamp(start)))]
)

contacts = []
if request.website.user_id.id != request.env.uid:
calendar_contact_obj = request.env['calendar.contacts']
calendar_contacts = calendar_contact_obj.search(
[('user_id', '=', request.env.uid)]
)

# Create response (Cannot serialize object)
contacts.append(request.env.user.partner_id.id)
for contact in calendar_contacts:
contacts.append(contact.partner_id.id)

# Events
events = []
for calendar_event in calendar_events:
# Fetch attendees
attendees = []
for attendee_id in calendar_event.attendee_ids:
attendees.append({'id': attendee_id.partner_id.id,
'name': attendee_id.partner_id.name})

events.append(
{'id': calendar_event.id,
'start': calendar_event.start,
'end': calendar_event.stop,
'title': calendar_event.name,
'allDay': calendar_event.allday,
'color': calendar_event.color_partner_id,
'attendees': attendees
})

return dumps({'events': events, 'contacts': contacts})
4 changes: 4 additions & 0 deletions website_snippet_calendar/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
calendar_event_public,calendar_event public,calendar.model_calendar_event,base.group_public,1,0,0,0
calendar_attendee_public,calendar_attendee public,calendar.model_calendar_attendee,base.group_public,1,0,0,0
res_partner_public,res_partner public,base.model_res_partner,base.group_public,1,0,0,0
42 changes: 42 additions & 0 deletions website_snippet_calendar/security/security.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 Onestein
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->

<odoo>
<data>

<record id="website_snippet_calendar_event_public" model="ir.rule">
<field name="name">Calendar event public</field>
<field name="model_id" ref="calendar.model_calendar_event"/>
<field name="domain_force">[('class', '=', 'public')]</field>
<field name="groups" eval="[(4, ref('base.group_public'))]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_unlink" eval="False"/>
</record>

<record id="website_snippet_calendar_attendee_public" model="ir.rule">
<field name="name">Calendar attendee public</field>
<field name="model_id" ref="calendar.model_calendar_attendee"/>
<field name="domain_force">[('event_id.class', '=', 'public')]</field>
<field name="groups" eval="[(4, ref('base.group_public'))]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_unlink" eval="False"/>
</record>

<record id="website_snippet_calendar_partner_public" model="ir.rule">
<field name="name">Partner public</field>
<field name="model_id" ref="base.model_res_partner"/>
<field name="domain_force">[(1, '=', 1)]</field>
<field name="groups" eval="[(4, ref('base.group_public'))]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_unlink" eval="False"/>
</record>

</data>
</odoo>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading