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

:tada: saas_public #17

@@ -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
===============

This module can be useful when creating public builds for ready-made templates by link.
This conversation was marked as resolved by trojikman

This comment has been minimized.

Copy link
@yelizariev

yelizariev Jul 2, 2019

Member

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

HTML Description: https://apps.odoo.com/apps/modules/12.0/saas_public/
This conversation was marked as resolved by trojikman

This comment has been minimized.

Copy link
@yelizariev

yelizariev Jul 8, 2019

Member

SaaS modules are not published at apps store


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 {ODOO_COMMIT_SHA_TO_BE_UPDATED}
This conversation was marked as resolved by trojikman

This comment has been minimized.

Copy link
@yelizariev

yelizariev Jul 2, 2019

Member

👎

@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import controllers, models
@@ -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.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",
# ]
}
@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import saas_public
@@ -0,0 +1,14 @@
# 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 = {}
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')
@@ -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_operator" model="saas.template.operator">
<field name="public_access" eval="True"/>
</record>
</odoo>
@@ -0,0 +1,4 @@
`1.0.0`
-------

- **Init version**
@@ -0,0 +1,25 @@
===============
SaaS Public
===============

Installation
============
* Installation is similar to SaaS Base module
This conversation was marked as resolved by trojikman

This comment has been minimized.

Copy link
@yelizariev

yelizariev Jul 2, 2019

Member

I don't like it


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

* Open menu ``[[ SaaS ]] >> Templates``
* Open your template or create new for which you need to create a build
* Choose or create Template's deployments for which you can open public access
* Check the box ``Public Access``
This conversation was marked as resolved by trojikman

This comment has been minimized.

Copy link
@yelizariev

yelizariev Jul 8, 2019

Member

Docs seems not updated after moving the field

This comment has been minimized.

Copy link
@yelizariev

yelizariev Jul 9, 2019

Member

Use special formatting for checkboxes

This comment has been minimized.

Copy link
@yelizariev
* RESULT: Now you can create public builds on the template

Usage
=====

* Open menu ``[[ SaaS ]]>> Templates``
This conversation was marked as resolved by trojikman

This comment has been minimized.

Copy link
@yelizariev

yelizariev Jul 2, 2019

Member

wrong format (you missed a space)

* Choose or create Template that has Template's deployment(s) with public access
* Copy link from Fast URL field
This conversation was marked as resolved by trojikman

This comment has been minimized.

* Open that link in browser either as logged in or logged out user
* RESULT: You will be redirected to the newly created build
@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import saas_template
@@ -0,0 +1,16 @@
# Copyright 2019 Denis Mudarisov <https://it-projects.info/team/trojikman>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

import random
from odoo import models, fields, api


class SAASTemplateOPerator(models.Model):
_inherit = 'saas.template.operator'

public_access = fields.Boolean(default=False)
This conversation was marked as resolved by trojikman

This comment has been minimized.

Copy link
@yelizariev

yelizariev Jul 2, 2019

Member

It must be per template, not per template-operator


@api.multi
def random_ready_operator(self):
ready_operators = self.filtered(lambda r: r.state == 'done' and r.public_access)
This conversation was marked as resolved by trojikman

This comment has been minimized.

Copy link
@yelizariev

yelizariev Jul 2, 2019

Member

no need to filter public_access only

return random.choice(ready_operators)
@@ -0,0 +1,15 @@
# Copyright 2018-2019 Denis Mudarisov <https://it-projects.info/team/trojikman>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo.tests.common import tagged, HttpCase
from odoo.service import db


# @tagged('post_install', 'at_install')
# class TestSaas(HttpCase):
# def test_saas_public(self):
# template_id = self.saas_template_1.id
# url = '/saas/{}/create-fast-build'.format(template_id)
# r = self.url_open(url)
# self.assertEqual(r.status_code, 200, 'User must be redirected to the build')
# self.assertIn('fast_build_001', db.list_dbs())
# self.assert_no_error_in_db('fast_build_001')
This conversation was marked as resolved by trojikman

This comment has been minimized.

Copy link
@yelizariev

yelizariev Jul 2, 2019

Member

Why it's commented?

@@ -0,0 +1,15 @@
<!--# Copyright 2019 Denis Mudarisov <https://www.it-projects.info/team/trojikman>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).-->

<odoo>
<record id="saas_template_operator_form_view" model="ir.ui.view">
<field name="name">saas.template.operator</field>
<field name="model">saas.template.operator</field>
<field name="inherit_id" ref="saas.saas_template_operator_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='operator_id']" position="after">
<field name="public_access"/>
</xpath>
</field>
</record>
</odoo>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.