Skip to content

Commit

Permalink
💣 developing process
Browse files Browse the repository at this point in the history
Signed-off-by: Vildan Safin <safin@it-projects.info>
  • Loading branch information
Enigma228322 committed Feb 28, 2020
1 parent 9dd511b commit 2de738d
Show file tree
Hide file tree
Showing 14 changed files with 266 additions and 33 deletions.
18 changes: 0 additions & 18 deletions .mrbob.ini

This file was deleted.

8 changes: 3 additions & 5 deletions saas_apps/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@
Saas Apps
===========

short
Base module for manage modules in saas.

Loong
Module allows to choose modules that users gona use in their db.

Credits
=======

Contributors
------------
* `saas apps <https://it-projects.info/team/saas-addons>`__:

* :one::zero: init version of the module
* `Vildan Safin <https://www.it-projects.info/team/Enigma228322>`__

Sponsors
--------
Expand Down
11 changes: 7 additions & 4 deletions saas_apps/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

{
"name": """SaaS Apps""",
"summary": """short""",
"summary": """Choose your apps""",
"category": "Marketing",
# "live_test_url": "http://apps.it-projects.info/shop/product/DEMO-URL?version=12.0",
"images": [],
"images": ['/images/attention.jpg'],
"version": "12.0.1.0.0",
"application": False,

Expand All @@ -17,10 +17,13 @@
# "price": 9.00,
# "currency": "EUR",

"depends": [
],
"depends": ['website'],
"external_dependencies": {"python": [], "bin": []},
"data": [
'security/ir.model.access.csv',
'views/calculator.xml',
'views/manage.xml',
'views/assets.xml'
],
"demo": [
],
Expand Down
39 changes: 35 additions & 4 deletions saas_apps/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,40 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo.http import route, request, Controller

from odoo import http
from openerp.http import request
import json

class SaaSAppsController(Controller):
@route('/price', type='http', auth='public')
def index(self, *kw):
return "shit"
@route('/price', auth='public', website=True)
def user_page(self, **kw):
import wdb
wdb.set_trace()
apps = http.request.env['saas.lines']
return http.request.render('saas_apps.index', {
'apps': apps.search([])
})

@route('/manage', auth='public', website=True)
def manager_page(self, **kw):
apps = http.request.env['ir.module.module']
return http.request.render('saas_apps.manage', {
'apps': apps.search([])
})

# @route('/manage/<name>', auth='public', website=True)
# def module_information(self, name):
# return http.request.render('saas_apps.info', {})

@http.route(['/test'], type='json', auth='public', website=True)
def catch_app_click(self, **kw):
import wdb
wdb.set_trace()
# Mark choosen module as saleable
http.request.env['ir.module.module'].search([('name', '=', kw['args'][0])]).allow_to_sell = True
apps = http.request.env['saas.lines']
apps.add_new_module(kw['args'][0])
# request.redirect('/manage/%s' % name)
return {
'apps': kw['args'][0]
}
Binary file added saas_apps/images/attention.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 68 additions & 2 deletions saas_apps/models/saas_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,76 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models
import logging

_logger = logging.getLogger(__name__)

class SAASApps(models.Model):
_name = 'saas.apps'
class SAASBasket(models.Model):
_name = 'saas.basket'
_description = 'Module for selecting applications'

users = fields.Integer(default=0)
module_sets_in_basket = fields.One2many('saas.set', 'basket', ondelete="cascade", delegate=True)
final_basket_price = fields.Float(default=0.0, compute='_compute_price', string="Price of the set")

def _compute_price(self):
for module_set in self.module_set_in_basket:
self.final_basket_price = self.final_basket_price + module_set.price


class SAASLine(models.Model):
_name = 'saas.lines'
_description = 'Model line'

module_name = fields.Char(default="default")
price = fields.Float(default=0.0)
icon_path = fields.Char(compute='_compute_path', string="icon path")
dependencies = fields.Many2one('saas.set', string="Module dependences")

def _compute_path(self):
self.icon_path = "/saas_apps/static/src/img/%s.png" % self.module_name

@api.constrains('price')
def _validate_price(self):
if self.price < 0:
self.price = 0
raise "Price can't be negative."

def add_new_module(self, name):
import wdb
wdb.set_trace()
# for module in self:
# if(module.module_name == name)
# return False
self.create({
'name': name
})
return True


class SAASDependence(models.Model):
_name = 'saas.set'
_description = 'Module with dependencies'

basket = fields.Many2one('saas.basket', string='Modules in basket')
modules = fields.One2many('saas.lines', 'dependencies', ondelete='cascade', delegate=True)
final_set_price = fields.Float(default=0.0, compute='_compute_price', string="Price of the set")

def add_dependence(self, new_module_name, new_module_price):
try:
self.modules.create({
'module_name': new_module_name,
'price': int(new_module_name_price)
})
except:
_logger.error("Can't add new item in dependencies of this module")

def _compute_price(self):
for module in self.modules:
self.final_set_price = self.final_set_price + module.price


# class IrModuleModule(models.Model):
# _inherit = "ir.module.module"

# allow_to_sell = fields.Boolean(default=False)
4 changes: 4 additions & 0 deletions saas_apps/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
access_saas_basket,access_saas_basket,model_saas_basket,base.group_user,1,1,1,1
access_saas_lines,access_saas_lines,model_saas_lines,base.group_user,1,1,1,1
access_saas_set,access_saas_set,model_saas_set,base.group_user,1,1,1,1
9 changes: 9 additions & 0 deletions saas_apps/static/src/css/calculator.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.main-control-pad{
margin-left: 15%;
width: auto;
}

.col-lg-12{
flex: 0 0 100%;
max-width: 100%;
}
Binary file added saas_apps/static/src/img/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions saas_apps/static/src/js/apps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
odoo.define('saas_apps.model', function (require){
'use_strict';

var session = require('web.session');


// function poopup_widjet(args){

// }

window.onclick=function(e){
console.log(e.target.innerText);

if(window.location.pathname === "/manage")
session.rpc('/test', {
args: [e.target.innerText]
}).then(function (result) {
console.log(result);
// poopup_widjet(result);
});
}
});
11 changes: 11 additions & 0 deletions saas_apps/views/assets.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!--Copyright 2020 Vildan Safin <https://github.com/Enigma228322>
License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).-->
<odoo>
<template id="assets_frontend" name="saas_styles" inherit_id="website.assets_frontend">
<xpath expr="." position="inside">
<link rel="stylesheet" type="text/scss" href="/saas_apps/static/src/css/calculator.css"/>
<script type="text/javascript" src="/saas_apps/static/src/js/apps.js"></script>
</xpath>
</template>
</odoo>
70 changes: 70 additions & 0 deletions saas_apps/views/calculator.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<!--Copyright 2020 Vildan Safin <https://github.com/Enigma228322>
License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).-->
<odoo>
<template id="index">
<t t-call="website.layout">
<title>Apps</title>
<div class="row main-control-pad container">
<div class="col-sm-8">
<!-- Users qty -->
<h3 class="mt16 mb8">Choose the number of users</h3>
<div class="row" style="max-width: 30%">
<div class="col-sm">
<input class="openerp_enterprise_pricing_users form-control border text-right pr-2" min="1" id="users" type="number" style="max-width: 120px;" value="1"></input>
</div>
<div class="col-sm">
<label class="px-2 mr-1 mb-0 bg-200 border-top border-right border-bottom">Users</label>
</div>
<div class="col-sm">
<label>
<del class="text-700 ml-1 mr-2 openerp_enterprise_user_pricing_monthly d-none"><span class="openerp_enterprise_pricing_user_amount_monthly_full">15,00</span><span class="openerp_enterprise_pricing_currency">EUR</span></del>
<del class="text-700 ml-1 mr-2 openerp_enterprise_user_pricing_yearly"><span class="openerp_enterprise_pricing_user_amount_yearly_full">12,00</span><span class="openerp_enterprise_pricing_currency">EUR</span></del>
<b class="openerp_enterprise_user_pricing_monthly d-none">
<span class="openerp_enterprise_pricing_user_amount_monthly">12,50</span>;<span class="openerp_enterprise_pricing_currency">EUR</span><small class="fw_semibold">/user/month</small>
</b>
<b class="openerp_enterprise_user_pricing_yearly">
<span class="openerp_enterprise_pricing_user_amount_yearly">10,00</span>;<span class="openerp_enterprise_pricing_currency">EUR</span><small class="fw_semibold">/user/month</small>
</b>
</label>
</div>
</div>
<div class="col-12 col-md-8 col-lg-9">
<!-- App list -->
<h3 class="mt16 mb16">Choose your Apps</h3>
<div class="openerp_enterprise_pricing_step_body mb24">
<div class="form-row">
<t t-foreach="apps" t-as="app">
<p class="col-12 col-sm-6 col-lg-4 shadow p-3 bg-white rounded price-window"><t t-esc="app.module_name"/></p>
</t>
</div>
</div>
</div>
</div>
<div class="col-sm-4">
<!-- Price window -->
<div class="col-12 col-md-4 col-lg-3 mt16">
<span class="shadow p-3 mb-5 bg-white rounded price-window">
░░░░░▄▄▄▄▄░░░░▄██▄░░░░░░░░░░░░░
░░░░░▀████░▄███▀▀██▄▄░░░░░░░░░░
░░░░░░███████▀░▄▄░▀███▄░░░░░░░░
░░░░░░█████▀░▄████▄░▀███▄░░░░░░
░░░░▄███░Here█gonna█be▀███▄▄░░░
░░▄███▀░▄▄███an░window▄░░▀███▄░
▄███▀░▄████████▄▄███████▄▄░▀██▄
▀▀░░▄████████with█price████░░▀▀
░░░░████▀▀▀▀▀▀▀███▀▀▀▀▀▀▀██░░░░
░░░░████░██░██░███░██░██░██░░░░
░░░░████░▄▄░▄▄░███░██░██░██░░░░
░░░░████░▀▀░▀▀░███▄▄▄▄▄▄▄██░░░░
░░░░████░██░██░████████████░░░░
░░░▄████▄▄▄▄▄▄▄████████████▄░░░
░░░█████████████████████████░░░
░░░█████████████████████████░░░
</span>
</div>
</div>
</div>
</t>
</template>
</odoo>
26 changes: 26 additions & 0 deletions saas_apps/views/manage.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--Copyright 2020 Vildan Safin <https://github.com/Enigma228322>
License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).-->
<odoo>
<template id="manage">
<t t-call="website.layout">
<title>Apps</title>
<div class="row container" style="margin-left: 25%">
<div class="col-sm-8">
<!-- App list -->
<div class="col-12 col-md-8 col-lg-9">
<h3 class="mt16 mb16">Choose your Apps</h3>
<h6 class="mt16 mb16">Choosen apps will be available in the store</h6>
<div class="openerp_enterprise_pricing_step_body mb24">
<div class="form-row">
<t t-foreach="apps" t-as="app">
<p id="application" class="col-12 col-sm-6 col-lg-4 shadow p-3 bg-white rounded price-window"><t t-esc="app.name"/></p>
</t>
</div>
</div>
</div>
</div>
</div>
</t>
</template>
</odoo>
11 changes: 11 additions & 0 deletions saas_apps/views/module_info.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!--Copyright 2020 Vildan Safin <https://github.com/Enigma228322>
License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).-->
<odoo>
<template id="info">
<t t-call="website.layout">
<title>Apps info</title>
<h1 style="text-align: center;">Module info</h1>
</t>
</template>
</odoo>

0 comments on commit 2de738d

Please sign in to comment.