Skip to content

Commit

Permalink
Merge 40b5ca4 into ba2186a
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobaeza committed Mar 13, 2019
2 parents ba2186a + 40b5ca4 commit 6886f0b
Show file tree
Hide file tree
Showing 16 changed files with 761 additions and 0 deletions.
102 changes: 102 additions & 0 deletions website_event_questions_free_text/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
=====================================
Free Text Answers on Events Questions
=====================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fevent-lightgray.png?logo=github
:target: https://github.com/OCA/event/tree/11.0/website_event_questions_free_text
:alt: OCA/event
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/event-11-0/event-11-0-website_event_questions_free_text
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/199/11.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows to define free text answers for the event registrations
in the website, so you can answer freely without the need of selecting a
closed list of choices.

**Table of contents**

.. contents::
:local:

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


#. Go to *Events > Events*
#. Create or select one event.
#. On the "Questions" page, create a new question or edit an existing one.
#. Mark the check "Free Text" for marking that question for having a free text
answer.

Usage
=====


#. Go to the website.
#. Go to "Events" section and select one of them.
#. Select ticket quantity and click on "Register".
#. On the popup dialog, fill the text area for the free text question.

Known issues / Roadmap
======================


* Add tests (tour) to the module.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/event/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 <https://github.com/OCA/event/issues/new?body=module:%20website_event_questions_free_text%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* Tecnativa

Contributors
~~~~~~~~~~~~

* `Tecnativa <https://www.tecnativa.com>`_:

* Pedro M. Baeza

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

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

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.

This module is part of the `OCA/event <https://github.com/OCA/event/tree/11.0/website_event_questions_free_text>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions website_event_questions_free_text/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import controllers
from . import models
21 changes: 21 additions & 0 deletions website_event_questions_free_text/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2019 Tecnativa - Pedro M. Baeza
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{
"name": "Free Text Answers on Events Questions",
"version": "11.0.1.0.0",
"category": "Website",
"website": "https://github.com/OCA/event",
"author": "Tecnativa, "
"Odoo Community Association (OCA)",
"license": "LGPL-3",
"installable": True,
"depends": [
"website_event_questions",
],
"data": [
"security/ir.model.access.csv",
"views/event_event_views.xml",
"views/event_templates.xml",
],
}
4 changes: 4 additions & 0 deletions website_event_questions_free_text/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import main
21 changes: 21 additions & 0 deletions website_event_questions_free_text/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo.addons.website_event_questions.controllers.main import WebsiteEvent


class WebsiteEvent(WebsiteEvent):

def _process_registration_details(self, details):
"""Add free answers to the registration"""
registrations = super()._process_registration_details(details)
for registration in registrations:
free_answers = []
for key, value in registration.items():
if key.startswith('answer_free_text-'):
free_answers.append((0, 0, {
'question_id': int(key[17:]),
'answer': value,
}))
registration['free_answer_ids'] = free_answers
return registrations
3 changes: 3 additions & 0 deletions website_event_questions_free_text/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import event_event
56 changes: 56 additions & 0 deletions website_event_questions_free_text/models/event_event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Copyright 2019 Tecnativa - Pedro M. Baeza
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import api, fields, models


class EventRegistration(models.Model):
_inherit = 'event.registration'

free_answer_ids = fields.One2many(
comodel_name='event.answer.free',
inverse_name='registration_id',
string='Free Answers',
)


class EventQuestion(models.Model):
_inherit = 'event.question'

free_text = fields.Boolean(
help="Allow user to introduce a free text as answer."
)


class EventAnswerFree(models.Model):
_name = 'event.answer.free'

registration_id = fields.Many2one(
comodel_name='event.registration',
required=True,
ondelete="cascade",
)
question_id = fields.Many2one(
comodel_name='event.question',
required=True,
ondelete="restrict",
domain="[('free_text', '=', True)]",
)
answer = fields.Char(
required=True,
)

_sql_constraints = [
('unique_registration_question',
'UNIQUE(registration_id, question_id)',
"You can't answer the same question 2 times"),
]

def name_get(self):
result = []
for record in self:
result.append((record.id, "%s: %s" % (
record.question_id.title,
record.answer,
)))
return result
6 changes: 6 additions & 0 deletions website_event_questions_free_text/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#. Go to *Events > Events*
#. Create or select one event.
#. On the "Questions" page, create a new question or edit an existing one.
#. Mark the check "Free Text" for marking that question for having a free text
answer.
3 changes: 3 additions & 0 deletions website_event_questions_free_text/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Tecnativa <https://www.tecnativa.com>`_:

* Pedro M. Baeza
3 changes: 3 additions & 0 deletions website_event_questions_free_text/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This module allows to define free text answers for the event registrations
in the website, so you can answer freely without the need of selecting a
closed list of choices.
2 changes: 2 additions & 0 deletions website_event_questions_free_text/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

* Add tests (tour) to the module.
5 changes: 5 additions & 0 deletions website_event_questions_free_text/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

#. Go to the website.
#. Go to "Events" section and select one of them.
#. Select ticket quantity and click on "Register".
#. On the popup dialog, fill the text area for the free text question.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
event_answer_free_all,event.answer.free.all,model_event_answer_free,,1,0,0,0
event_answer_free_event_user,event.answer.free.event.user,model_event_answer_free,event.group_event_user,1,1,1,1

0 comments on commit 6886f0b

Please sign in to comment.