-
-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from trojikman/12.0-saas_public-add-module
🎉 saas_public
- Loading branch information
Showing
18 changed files
with
289 additions
and
74 deletions.
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
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from . import test_saas | ||
from . import test_saas, common_saas_test |
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,73 @@ | ||
# Copyright 2019 Denis Mudarisov <https://it-projects.info/team/trojikman> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from odoo.service import db | ||
|
||
DB_TEMPLATE_1 = 'db_template_1' | ||
DB_TEMPLATE_2 = 'db_template_2' | ||
MODULE_TO_INSTALL = 'mail' | ||
TEMPLATE_TEST_SUBJECT = 'Dummy subject name to test that code is applied on template database' | ||
BUILD_TEST_SUBJECT = 'Dummy subject name to test that code is applied on build database' | ||
DEFAULT_BUILD_PYTHON_CODE = """# Available variables: | ||
# - env: Odoo Environment on which the action is triggered | ||
# - time, datetime, dateutil, timezone: useful Python libraries | ||
# - log: log(message, level='info'): logging function to record debug information in ir.logging table | ||
# - Warning: Warning Exception to use with raise | ||
# To return an action, assign: action = {{...}} | ||
# You can specify places for variables that can be passed when creating a build like this: | ||
# env['{key_name_1}'].create({{'subject': '{key_name_2}', }}) | ||
# When you need curly braces in build post init code use doubling for escaping\n\n\n\n""" | ||
|
||
|
||
class Common(object): | ||
def setup_saas_env(self): | ||
self.env = self.env(context=dict( | ||
self.env.context, | ||
test_queue_job_no_delay=True, | ||
)) | ||
|
||
self.saas_template_1 = self.env['saas.template'].create({ | ||
'template_module_ids': [(0, 0, { | ||
'name': MODULE_TO_INSTALL, | ||
})], | ||
'template_post_init': 'env[\'mail.message\'].create({\'subject\': \'' + TEMPLATE_TEST_SUBJECT + '\', })', | ||
'build_post_init': DEFAULT_BUILD_PYTHON_CODE + 'env[\'{mail_message}\'].create({{\'subject\': \'' + BUILD_TEST_SUBJECT + '\', }})', | ||
}) | ||
|
||
self.saas_template_2 = self.env['saas.template'].create({ | ||
'template_module_ids': [(0, 0, { | ||
'name': 'mail', | ||
})], | ||
'template_post_init': 'env[\'mail.message\'].create({\'subject\': \'' + TEMPLATE_TEST_SUBJECT + '\', })', | ||
}) | ||
|
||
self.saas_operator_1 = self.env['saas.operator'].create({ | ||
'type': 'local', | ||
'db_url_template': 'http://{db_name}.{db_id}.127.0.0.1.nip.io:8069', | ||
'master_url': 'http://saas.127.0.0.1.nip.io:8069', | ||
}) | ||
|
||
self.saas_operator_2 = self.env['saas.operator'].create({ | ||
'type': 'local', | ||
'db_url_template': 'http://{db_name}.{db_id}.127.0.0.1.nip.io:8069', | ||
'master_url': 'http://saas.127.0.0.1.nip.io:8069', | ||
}) | ||
|
||
self.saas_template_operator_1 = self.env['saas.template.operator'].create({ | ||
'template_id': self.saas_template_1.id, | ||
'operator_id': self.saas_operator_1.id, | ||
'operator_db_name': DB_TEMPLATE_1, | ||
}) | ||
|
||
self.saas_template_operator_2 = self.env['saas.template.operator'].create({ | ||
'template_id': self.saas_template_2.id, | ||
'operator_id': self.saas_operator_2.id, | ||
'operator_db_name': DB_TEMPLATE_2, | ||
}) | ||
|
||
def drop_dbs(self, db_list=None): | ||
if not db_list: | ||
db_list = [] | ||
db_list += [DB_TEMPLATE_1, DB_TEMPLATE_2, 'template_database'] | ||
for i in db_list: | ||
if i in db.list_dbs(): | ||
db.exp_drop(i) |
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,40 @@ | ||
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png | ||
:target: https://www.gnu.org/licenses/agpl | ||
:alt: License: AGPL-3 | ||
|
||
=============== | ||
SaaS Public | ||
=============== | ||
|
||
Create builds for non-authenticated users: | ||
|
||
* User opens a link and gets a build | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
* `Denis Mudarisov <https://it-projects.info/team/trojikman>`__ | ||
|
||
Sponsors | ||
-------- | ||
* `IT-Projects LLC <https://it-projects.info>`__ | ||
|
||
Maintainers | ||
----------- | ||
* `IT-Projects LLC <https://it-projects.info>`__ | ||
|
||
|
||
Further information | ||
=================== | ||
|
||
Demo: http://runbot.it-projects.info/demo/saas-addons/12.0 | ||
|
||
Usage instructions: `<doc/index.rst>`_ | ||
|
||
Changelog: `<doc/changelog.rst>`_ | ||
|
||
Notifications on updates: `via Atom <https://github.com/it-projects-llc/saas-addons/commits/12.0/saas_public.atom>`_, `by Email <https://blogtrottr.com/?subscribe=https://github.com/it-projects-llc/saas-addons/commits/12.0/saas_public.atom>`_ | ||
|
||
Tested on Odoo 12.0 4b22f1ff5e7c350fa37459c106f52305e26f2ec9 |
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 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from . import controllers, 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,41 @@ | ||
# Copyright 2019 Denis Mudarisov <https://it-projects.info/team/trojikman> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": """SaaS Public""", | ||
"summary": """Module for creating public builds""", | ||
"category": "SaaS", | ||
"images": [], | ||
"version": "12.0.1.0.0", | ||
"application": False, | ||
|
||
"author": "IT-Projects LLC, Denis Mudarisov", | ||
"support": "apps@it-projects.info", | ||
"website": "https://it-projects.info/team/trojikman", | ||
"license": "AGPL-3", | ||
# "price": 9.00, | ||
# "currency": "EUR", | ||
|
||
"depends": [ | ||
"saas", | ||
], | ||
"external_dependencies": {"python": [], "bin": []}, | ||
"data": [ | ||
"views/saas_template_operator_views.xml", | ||
], | ||
"demo": [ | ||
"demo/public_saas_template_demo.xml", | ||
], | ||
"auto_install": False, | ||
"installable": True, | ||
|
||
# "demo_title": "{MODULE_NAME}", | ||
# "demo_addons": [ | ||
# ], | ||
# "demo_addons_hidden": [ | ||
# ], | ||
# "demo_url": "DEMO-URL", | ||
# "demo_summary": "{SHORT_DESCRIPTION_OF_THE_MODULE}", | ||
# "demo_images": [ | ||
# "images/MAIN_IMAGE", | ||
# ] | ||
} |
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 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from . import saas_public |
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,19 @@ | ||
# Copyright 2019 Denis Mudarisov <https://it-projects.info/team/trojikman> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo.http import route, request, Controller | ||
|
||
|
||
class SaaSPublicController(Controller): | ||
@route('/saas_public/<model("saas.template"):template_id>/create-fast-build', type='http', auth='public') | ||
def create_fast_build(self, template_id, **kwargs): | ||
if not kwargs: | ||
kwargs = {} | ||
if template_id and template_id.sudo().public_access: | ||
template_operator_id = template_id.sudo().operator_ids.random_ready_operator() | ||
build = template_operator_id.sudo().create_db(kwargs, with_delay=False) | ||
build_url = build.get_url() | ||
return request.env['auth_quick_master.token'].sudo().redirect_with_token(build_url, build.id, | ||
build_login='admin') | ||
else: | ||
return request.not_found() |
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,7 @@ | ||
<!-- Copyright 2019 Denis Mudarisov <https://it-projects.info/team/trojikman> | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).--> | ||
<odoo> | ||
<record id="saas.saas_template" model="saas.template"> | ||
<field name="public_access" eval="True"/> | ||
</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,4 @@ | ||
`1.0.0` | ||
------- | ||
|
||
- **Init version** |
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,25 @@ | ||
=============== | ||
SaaS Public | ||
=============== | ||
|
||
Installation | ||
============ | ||
|
||
* Follow the insallation instruction of `SaaS Base <https://github.com/it-projects-llc/saas-addons/blob/12.0/saas/doc/index.rst>`__ module | ||
* `Install <https://odoo-development.readthedocs.io/en/latest/odoo/usage/install-module.html>`__ this module in a usual way | ||
|
||
Configuration | ||
============= | ||
|
||
* Open menu ``[[ SaaS ]] >> Templates`` | ||
* Open your template or create new for which you need to create a build | ||
* Set **[x] Public Access** | ||
* RESULT: Now you can create public builds on the template | ||
|
||
Usage | ||
===== | ||
|
||
* Open menu ``[[ SaaS ]] >> Templates`` | ||
* Choose or create Template that has Template's deployment(s) with public access | ||
* Open link `yourdomain.example/saas_public/*template_id*/create-fast-build` in browser either as logged in or logged out user. Instead of *template_id*, insert template id with public access | ||
* RESULT: You will be redirected to the newly created build |
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 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from . import saas_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,10 @@ | ||
# Copyright 2019 Denis Mudarisov <https://it-projects.info/team/trojikman> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import models, fields | ||
|
||
|
||
class SAASTemplate(models.Model): | ||
_inherit = 'saas.template' | ||
|
||
public_access = fields.Boolean(default=False) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from . import test_saas_public |
Oops, something went wrong.