-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Social Registry: Added region field and self_service module..
- Loading branch information
Showing
46 changed files
with
2,958 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
======================= | ||
G2P Self Service Portal | ||
======================= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:3a6f181ca8e6c6c9908a819106ede1b875fc539e31723b5b654722a4805ba1b4 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Alpha | ||
.. |badge2| image:: https://img.shields.io/badge/github-OpenG2P%2Fopeng2p--self--service--portal-lightgray.png?logo=github | ||
:target: https://github.com/OpenG2P/openg2p-self-service-portal/tree/17.0/g2p_self_service_portal | ||
:alt: OpenG2P/openg2p-self-service-portal | ||
|
||
|badge1| |badge2| | ||
|
||
OpenG2P Self Service Portal | ||
|
||
.. IMPORTANT:: | ||
This is an alpha version, the data model and design can change at any time without warning. | ||
Only for development or testing purpose, do not use in production. | ||
`More details on development status <https://odoo-community.org/page/development-status>`_ | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OpenG2P/openg2p-self-service-portal/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OpenG2P/openg2p-self-service-portal/issues/new?body=module:%20g2p_self_service_portal%0Aversion:%2017.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 | ||
~~~~~~~ | ||
|
||
* OpenG2P | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is part of the `OpenG2P/openg2p-self-service-portal <https://github.com/OpenG2P/openg2p-self-service-portal/tree/17.0/g2p_self_service_portal>`_ project on GitHub. | ||
|
||
You are welcome to contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Part of OpenG2P. See LICENSE file for full copyright and licensing details. | ||
|
||
from . import controllers | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "G2P Self Service Portal", | ||
"category": "G2P", | ||
"version": "17.0.1.0.0", | ||
"sequence": 1, | ||
"author": "OpenG2P", | ||
"website": "https://openg2p.org", | ||
"license": "Other OSI approved licence", | ||
"development_status": "Alpha", | ||
"depends": [ | ||
"g2p_social_registry", | ||
"website", | ||
"web", | ||
"auth_oidc", | ||
], | ||
"data": [ | ||
"data/website_form_action_data.xml", | ||
"views/g2p_self_service_base.xml", | ||
"views/g2p_self_service_login.xml", | ||
"views/g2p_self_service_myprofile.xml", | ||
"views/auth_oauth_provider.xml", | ||
"views/g2p_self_service_form_page_template.xml", | ||
"views/g2p_self_service_submitted_forms.xml", | ||
"views/res_config_settings.xml", | ||
], | ||
"assets": { | ||
"web.assets_backend": [], | ||
"web.assets_frontend": [ | ||
"g2p_self_service_portal/static/src/js/self_service_form_action.js" | ||
], | ||
"web.assets_common": [], | ||
}, | ||
"demo": [], | ||
"images": [], | ||
"application": True, | ||
"installable": True, | ||
"auto_install": False, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
import logging | ||
|
||
from werkzeug.exceptions import Forbidden, Unauthorized | ||
|
||
from odoo import _, http | ||
from odoo.http import request | ||
|
||
from odoo.addons.auth_oidc.controllers.main import OpenIDLogin | ||
from odoo.addons.web.controllers.home import Home | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class SelfServiceController(http.Controller): | ||
@http.route(["/selfservice"], type="http", auth="public", website=True) | ||
def self_service_root(self, **kwargs): | ||
if request.session and request.session.uid: | ||
return request.redirect("/selfservice/apply") | ||
else: | ||
return request.redirect("/selfservice/login") | ||
|
||
@http.route(["/selfservice/login"], type="http", auth="public", website=True) | ||
def self_service_login(self, **kwargs): | ||
if request.session and request.session.uid: | ||
return request.redirect("/selfservice/apply") | ||
request.params["redirect"] = "/" | ||
context = {} | ||
|
||
providers = [] | ||
try: | ||
providers = OpenIDLogin().list_providers( | ||
domain=[("g2p_self_service_allowed", "=", True)] | ||
) | ||
except Exception: | ||
providers = OpenIDLogin().list_providers() | ||
|
||
context.update(dict(providers=providers)) | ||
|
||
if request.httprequest.method == "POST": | ||
res = Home().web_login(**kwargs) | ||
|
||
if not request.params["login_success"]: | ||
context["error"] = "Invalid Credentials" | ||
return request.render( | ||
"g2p_self_service_portal.login_page", qcontext=context | ||
) | ||
|
||
return res | ||
|
||
return request.render("g2p_self_service_portal.login_page", qcontext=context) | ||
|
||
@http.route(["/selfservice/logo"], type="http", auth="public", website=True) | ||
def self_service_logo(self, **kwargs): | ||
config = request.env["ir.config_parameter"].sudo() | ||
attachment_id = config.get_param( | ||
"g2p_self_service_portal.self_service_logo_attachment" | ||
) | ||
return request.redirect("/web/content/%s" % attachment_id) | ||
|
||
@http.route(["/selfservice/myprofile"], type="http", auth="public", website=True) | ||
def self_service_profile(self, **kwargs): | ||
if request.session and request.session.uid: | ||
current_partner = request.env.user.partner_id | ||
return request.render( | ||
"g2p_self_service_portal.profile_page", | ||
{ | ||
"current_partner": current_partner, | ||
}, | ||
) | ||
|
||
@http.route(["/selfservice/apply"], type="http", auth="user", website=True) | ||
def self_service_home(self, **kwargs): | ||
self.self_service_check_roles("REGISTRANT") | ||
|
||
config = request.env["ir.config_parameter"].sudo() | ||
|
||
form_id = config.get_param("g2p_self_service_portal.self_service_form", None) | ||
|
||
view_id = request.env["website.page"].sudo().browse(int(form_id)).view_id | ||
|
||
return request.render( | ||
view_id.id | ||
# {"programs": myprograms, "data": data}, | ||
) | ||
|
||
@http.route( | ||
["/selfservice/submit"], | ||
type="http", | ||
auth="user", | ||
website=True, | ||
csrf=False, | ||
) | ||
def self_service_form_submit(self, **kwargs): | ||
self.self_service_check_roles("REGISTRANT") | ||
_logger.info(kwargs) | ||
self.get_field_to_exclude(kwargs) | ||
return request.render( | ||
"g2p_self_service_portal.self_service_form_submitted", | ||
{ | ||
"user": request.env.user.given_name, | ||
}, | ||
) | ||
|
||
def self_service_check_roles(self, role_to_check): | ||
# And add further role checks and return types | ||
if role_to_check == "REGISTRANT": | ||
if not request.session or not request.env.user: | ||
raise Unauthorized(_("User is not logged in")) | ||
if not request.env.user.partner_id.is_registrant: | ||
raise Forbidden(_("User is not allowed to access the portal")) | ||
|
||
def get_field_to_exclude(self, data): | ||
current_partner = request.env.user.partner_id | ||
keys = [] | ||
for key in data: | ||
if key in current_partner: | ||
current_partner[key] = data[key] | ||
keys.append(key) | ||
|
||
return keys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<!-- <record id="g2p_registry_base.model_res_partner" model="ir.model"> | ||
<field name="website_form_key">update_registry_data</field> | ||
<field name="website_form_default_field_id" ref="g2p_registry_base.field_res_partner__is_registrant" /> | ||
<field name="website_form_access">True</field> | ||
<field name="website_form_label">Update Registry Data</field> | ||
<field name="website_form_key">send_mail</field> | ||
<field name="website_form_default_field_id" ref="mail.field_mail_mail__body_html" /> | ||
<field name="website_form_access">True</field> | ||
<field name="website_form_label">test</field> | ||
</record> --> | ||
|
||
<record id="g2p_registry_base.model_res_partner" model="ir.model"> | ||
<field name="website_form_key">send_mail</field> | ||
<field name="website_form_default_field_id" ref="g2p_registry_base.field_res_partner__is_registrant" /> | ||
<field name="website_form_access">True</field> | ||
<field name="website_form_label">Update Registry Data</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import auth_oauth_provider | ||
from . import res_config_settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from odoo import fields, models | ||
|
||
|
||
class G2PSelfServiceOauthProvider(models.Model): | ||
_inherit = "auth.oauth.provider" | ||
|
||
g2p_self_service_allowed = fields.Boolean( | ||
"Allowed in Self Service Portal", default=False | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from odoo import api, fields, models | ||
|
||
|
||
class ResConfigSettings(models.TransientModel): | ||
_inherit = ["res.config.settings"] | ||
|
||
self_service_logo = fields.Many2one( | ||
"ir.attachment", | ||
config_parameter="g2p_self_service_portal.self_service_logo_attachment", | ||
) | ||
|
||
self_service_form = fields.Many2one( | ||
"website.page", config_parameter="g2p_self_service_portal.self_service_form" | ||
) | ||
|
||
@api.constrains("self_service_form") | ||
def update_form_template(self): | ||
form_view = self.self_service_form.view_id | ||
if form_view: | ||
form_view_template = form_view.arch_db | ||
form_view.write( | ||
{ | ||
"arch_db": form_view_template.replace( | ||
"website.layout", | ||
"g2p_self_service_portal.self_service_form_template", | ||
) | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
`OpenG2P <https://openg2p.org>`__ donated the original code to the project. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
G2P Self Service Portal |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.